@mdzzohrabi/container
v1.0.1
Published
Dependency Injection Container
Downloads
4
Maintainers
Readme
Container
Usage
Simple usage :
let container = new Container
container.setParams({
dbName: 'myDB'
})
container.set('connection', ($dbName) => {
return $dbName;
})
container.get('connection'); // return "myDb"
Advanced :
let container = new Container({
// Log service
log: ($env) => {
if ($env === 'dev') return (...params) => console.log(...params);
return () => void;
},
// Database connection
db: function dbConnection(log, $dbHost) {
log(`Initialize connection`)
}
}, { env: 'dev', dbHost: 'localhost' })