application-blueprint
v1.0.0
Published
Lightweight dependency injection framework.
Downloads
5
Maintainers
Readme
application-blueprint
application-blueprint is a very lightweight dependency injection framework for Node.js applications. It makes it very easy to unit test, due to the very simple constructor injection pattern.
Configuration format
The create(base, configurationFile);
function below reads a blueprint configuration file. The format looks something like this:
module.exports =
[
{ external: "http" },
"./components/handler",
{ path: './components/service', name: "coolService" },
{ path: './components/simpleExecutor', mapbinder: "executors", name: "executor1" },
{ path: './components/advancedExecutor', mapbinder: "executors", name: "executor2" }
]
As you can see, you can use simple strings in the configuration. Simple strings are equivalent to using { path: '...' }
.
You can register external modules using the external
keyword. application-blueprint will simply require that module and register it in the container.
The name of the modules can be left out. If not specified, it will be derived from other fields. For example, for { path: './components/service' }
, it will use service
as the name of the module. Everything after the last slash is used, if one exists. For external modules, it will use whatever you enter in the external
part, which is usually what you want.