@midgar/service
A Midgar plugin to add service with dependency injection
Last updated a month ago by edwardlow .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @midgar/service 
SYNC missed versions from official npm registry.

Build Status Coverage

@midgar/service

Système de services avec injection de dépendance pour Midgar

Installation

$ npm i @midgar/service

Fonctionnement

Ce plugin ajoute un type de module midgar-service contenu dans le dossier ./services/ . les fichier service doivent terminer par .service.js

Module service

Fonction:

export default {
  // Service a injecter
  dependencies: [
    'mid-mongo:db'
  ],
  // Service
  service: (mid, mongoService) => {
    ....
    return service
  }
}

Class:

// Nom du service
const name = 'namespace:monService'

// Service a injecter
const dependencies: [
    'mid-mongo:db'
  ]

// Service
class MyService {
  constructor(mid, mongoService) {}

  async init () {
    ...
  }
}

export default {
  dependencies,
  service: MyService,
}

La methode init est appelé automatique lors de la création de l'instance du service. Elle est asynchrone.

Get service

const serviceInstance = await mid.getService('mon-plugin:mon-service')

documentation Api.

Current Tags

  • 1.0.0-beta.2.0                                ...           latest (a month ago)

9 Versions

  • 1.0.0-beta.2.0                                ...           a month ago
  • 1.0.0-beta.1.0                                ...           3 months ago
  • 1.0.0-alpha.2.0                                ...           8 months ago
  • 1.0.0-alpha.1.6                                ...           8 months ago
  • 1.0.0-alpha.1.4                                ...           9 months ago
  • 1.0.0-alpha.1.3                                ...           9 months ago
  • 1.0.0-alpha.1.2                                ...           9 months ago
  • 1.0.0-alpha.1.1                                ...           9 months ago
  • 1.0.0-alpha.1.0                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (17)

Copyright 2014 - 2016 © taobao.org |