1.0.0-alpha.1.7 • Published 6 years ago

@midgar/services v1.0.0-alpha.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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'
  ]
}