This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
Implement a dependency injection system #14
Labels
discovery
more information is needed
feature
New feature or request
package/core
issues related to @kangojs/core
Milestone
Package Information: kangojs
Describe your feature
Implement a dependency injection (DI) / Inversion of Control (IoC) system into KangoJS.
This would mean you could mark dependencies to inject into controlllers, services etc and KangoJS would handle the depedency creation and injection.
This DI must be recursive, so the application must work down the dependency tree (controller -> service -> other services/helpers etc) and handle injecting everything.
Is your suggestion related to any problems?
For testing (unit tests and e2e) you need to be able to access the dependency instances that are part of the application and also potentially overwrite / mock dependencies.
This will be useful for a number of things during testing:
Additional context
I think this would be done the same / a similar way to how it's done in NesJS or InversifyJS:
Some notes:
@Inject
decorator can be used to mark a dependency as injectable and tells KangoJS what class should be instantiated, passed to the class and stored in a centeral IoC container for later use.Maybe there could also then be a way to manually add/overwrite dependencies too? I don't think this would be a paticualr focus for an MVP of this feature though:
The text was updated successfully, but these errors were encountered: