-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87dabdf
commit 8be27a6
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...ammatham-v2x-a-type-safe-evolution-with-improved-dependency-injection/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 π). |
Binary file added
BIN
+698 KB
...matham-v2x-a-type-safe-evolution-with-improved-dependency-injection/compare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.