Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/midgarjs/service
Service plugin for Midgar
https://github.com/midgarjs/service
midgar mvcs nodejs plugin service
Last synced: about 1 month ago
JSON representation
Service plugin for Midgar
- Host: GitHub
- URL: https://github.com/midgarjs/service
- Owner: midgarjs
- License: mit
- Created: 2019-12-29T20:27:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T04:52:49.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T14:45:03.624Z (about 2 months ago)
- Topics: midgar, mvcs, nodejs, plugin, service
- Language: JavaScript
- Homepage:
- Size: 2 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://drone.midgar.io/api/badges/Midgar/service/status.svg)](https://drone.midgar.io/Midgar/service)
[![Coverage](https://sonar.midgar.io/api/project_badges/measure?project=midgar-service&metric=coverage)](https://sonar.midgar.io/dashboard?id=midgar-service)# @midgar/service
Système de services avec injection de dépendance pour [Midgar](https://github.com/midgarjs/midgar)
## Installation
```sh
$ npm i @midgar/service
```Si tout s'est bien passé, un message de confirmation s'affiche:
```sh
#midgar-cli
@midgar/service added to plugins.json !
```## Fonctionnement
Ce plugin ajoute un type de module **midgar-service** contenu dans le dossier ./services/.## Module service
### Fonction:
```js
export default {
// Nom du service
name: 'namespace:monService',// Le service s'initialiseras avant le service mid:express
before: ['mid:express']// Service a injecter
dependencies: [
'mid:mongo'
],
// Service
service: (mid, mongoService) => {
....
return service
}
}
```### Class:
```js
// Nom du service
const name = 'namespace:monService'// Le service s'initialiseras avant le service mid:express
const before = ['mid:express']// Service a injecter
const dependencies: [
'mid:mongo'
]// Service
class MyService {
constructor(mid, mongoService) {}init () {
...
}
}export default {
name
before,
dependencies,
service: MyService,
}
```La methode init est appelé automatique lors de la création de l'instance du service.
## Get service
```js
const serviceInstance = mid.getService('namespace:monService')
```[documentation Api](https://midgarjs.github.io/service/).