1.0.0-aplha.3.0 • Published 5 years ago
@midgar/service v1.0.0-aplha.3.0
@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')
1.0.0-aplha.3.0
5 years ago
1.0.0-beta.2.0
5 years ago
1.0.0-beta.1.0
5 years ago
1.0.0-alpha.1.6
5 years ago
1.0.0-alpha.2.0
5 years ago
1.0.0-alpha.1.4
5 years ago
1.0.0-alpha.1.3
5 years ago
1.0.0-alpha.1.2
6 years ago
1.0.0-alpha.1.1
6 years ago
1.0.0-alpha.1.0
6 years ago