appjector
v1.3.0
Published
Appjector is a simple lib that aims to simplify dependencies management and to ease testing for modular node projects
Downloads
14
Maintainers
Readme
Appjector
Appjector is a simple lib that aims to simplify dependencies management and to ease testing for modular node projects
This was an experiment about dependencies injection. There are some nice concepts with these "applicative containers", especially when it comes to testing and sharing components between apps but it seems to add unneeded complexity.
Bootstrap an application
the simple way
//index.js
'use strict';
var appjector = require('appjector');
appjector
.container('./app')
.run();
File format
Principles:
- The filename defines the component's name
- Exports an anonymous function
- The function arguments define the required dependencies
- The function returns the component's value
'use strict';
module.exports = function(dep1, dep2, Dep3) {)
return {} // or Class, [], 'hello', fn ...;
};
Defining containers
Have a look at how appjector.container
works here
Add asynchronous start/stop logics
Have a look at how appjector.AppSwitch
helper works here
How to test
Have a look at how container.isolate
, container.replace
, container.keep
, and container.without
work here