xpose
v0.2.1
Published
A tiny, flexible dependency injection library
Downloads
5
Maintainers
Readme
xpose
A tiny, flexible dependency injection library for NodeJS.
Installation
$ npm install -S xpose
Example usage
/index.js
const xpose = require('xpose');
const {App} = xpose({
path: 'src/app/**/*.js',
eager: true,
include: [
xpose({
path: 'src/lib/**/*.js',
}),
],
});
/src/app/App.js
module.exports = ({Service}) => {
console.log(Service); // 123
}
/src/app/Service.js
module.exports = ({Helper}) => {
console.log('Access to helper library:', Helper);
return 123;
}
/src/lib/Helper.js
module.exports = () => {
return {
// Lazy-loaded resource
};
}