You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To study the replacement of the current module registration and dependency injection system with a decorator-based approach.
The existing mechanism, which relies on explicit imports and manual module registration via Container from "inversify" and AppContainer from "@expressots/core", has served us well but lacks the simplicity and elegance that decorators can provide. By adopting decorators, we aim to streamline the module system, improve developer experience, and align with modern TypeScript best practices.
Proposed Decorator-Based Approach
@container Decorator: This decorator can be used to mark a class as a container that can contain modules.
Current approach:
exportconstappContainer: AppContainer=newAppContainer({autoBindInjectable: false,});exportconstcontainer: Container=appContainer.create([// Add your modules hereAppModule,]);
@container Decorator Improvements: We enhance the @container decorator to accept a configuration object. This decorator is responsible for marking a class as the root container for the application, allowing for centralized configuration of the dependency injection container options and registered modules.
Module Registration: We can further simplify module registration by allowing the @container decorator to automatically include modules listed in its modules array, reducing manual setup.
Simplified Bootstrap Function: The bootstrap function becomes cleaner, focusing solely on application initialization and setup, without directly dealing with container configuration details.
The text was updated successfully, but these errors were encountered:
Description
To study the replacement of the current module registration and dependency injection system with a decorator-based approach.
The existing mechanism, which relies on explicit imports and manual module registration via Container from "inversify" and AppContainer from "@expressots/core", has served us well but lacks the simplicity and elegance that decorators can provide. By adopting decorators, we aim to streamline the module system, improve developer experience, and align with modern TypeScript best practices.
Proposed Decorator-Based Approach
@container Decorator: This decorator can be used to mark a class as a container that can contain modules.
Current approach:
Proposed new approach
To be used in the bootstrap:
Benefits
The text was updated successfully, but these errors were encountered: