https://github.com/anton-johansson/application-blueprint
https://github.com/anton-johansson/application-blueprint
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/anton-johansson/application-blueprint
- Owner: anton-johansson
- License: apache-2.0
- Created: 2015-03-14T13:08:46.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-06T10:05:39.000Z (about 10 years ago)
- Last Synced: 2025-05-01T02:47:24.658Z (about 1 month ago)
- Language: JavaScript
- Size: 207 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
[](https://travis-ci.org/anton-johansson/application-blueprint)
[](https://codecov.io/github/anton-johansson/application-blueprint)
[](https://nodei.co/npm/application-blueprint/)
## Configuration format
The `create(base, configurationFile);` function below reads a blueprint configuration file. The format looks something like this:
```js
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.