@midgar/services
v1.0.0-alpha.1.7
Published
A Midgar plugin to add service with dependency injection
Downloads
4
Readme
In Dev don't use this
@midgar/services
It a plugin for Midgar to add services with dependency injection
Installation
$ npm install @midgar/services --save
Plugin dir
This plugin add a services plugin dir. It load all services in this directories.
Get service
This plugin add a function "getService" on Midgar instance
const serviceInstance = await midgar.getService('myService')
or
midgar.getService('myService').then(serviceInstance => {
...
})
Service définition
Function service:
function myService(midgar, db) {
...
}
module.exports = {
service: myService,
dependencies: [
'db'
]
}
Class service:
class MyService {
constructor(midgar, db) {
}
}
module.exports = {
service: myService,
dependencies: [
'db'
]
}