Skip to content

Commit

Permalink
add blog
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed Jan 6, 2024
1 parent 87dabdf commit 8be27a6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: 'Nammatham v2.x: A Type-Safe Evolution with Improved Dependency Injection'
uuid: bcx6ncq
tags:
- blog
- nammatham
- diextra
- typesafe
- decorator
- serverless
- azure
- azureFunctions
- express
- trpc
---


## Introduction:

When developing Nammatham v1.x, I acknowledged that the experience was somewhat limited. The integration with Dependency Injection (Inversify) was overly complex, leading to constraints in scalability and extensibility. πŸ₯²

Nammatham v2.x, on the other hand, underwent a complete overhaul! πŸ₯³ We eliminated the tight coupling with Inversify and reduced the reliance on decorators, making it more type-safe. This version now supports easier expansion, steering away from the limitations of the past.

For instance, it seamlessly integrates with Express for Azure Functions Dev, providing an alternative to the official approach, which suffered from slow startup times and the need to compile to JS before debugging. Additionally, libraries like tRPC are now compatible and contribute to the overall improved developer experience. πŸ€—

## Getting to the Point:

After successfully proving the concept with Nammatham v2.x, supporting Azure Functions v4 models with enhanced type safety and developer experience, a new challenge arose. The existing production code of v1.x heavily relied on Inversify's robust container. How could we address this without the need for a complete code rewrite? 🀩

## The Solution:

We decided to create helper functions that are type-safe and assist in resolving service dependencies for Inversify. This approach allows for a graceful migration from v1.x to v2.x without the need to overhaul the existing codebase. It's a work in progress (all libraries are currently in alpha stage with rigorous testing ongoing), but it holds promise for a smooth transition, as depicted in the image below. πŸ‘‡πŸ‘‡

![](compare.png)

For those interested in the code, feel free to explore and give it a star if you find it useful! πŸ“£

- Nammatham: https://github.com/thaitype/nammatham
- di-extra: https://github.com/thaitype/di-extra

P.S. Nammatham is a TypeScript library designed to facilitate the development of serverless functions, such as Azure Functions and others in the future (assuming contributions are made πŸ™).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8be27a6

Please sign in to comment.