Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/midgarjs/express
https://github.com/midgarjs/express
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/midgarjs/express
- Owner: midgarjs
- License: mit
- Created: 2020-01-04T15:50:13.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T01:04:36.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T15:13:44.196Z (8 months ago)
- Language: JavaScript
- Size: 1.57 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/express/status.svg)](https://drone.midgar.io/Midgar/express)
[![Coverage](https://sonar.midgar.io/api/project_badges/measure?project=midgar-express&metric=coverage)](https://sonar.midgar.io/dashboard?id=midgar-express)# @midgar/express
Ajoute un service expess [Express](https://expressjs.com/)
## Installation
```sh
$ npm i @midgar/express
```Si tout s'est bien passé, un message de confirmation s'affiche:
```sh
#midgar-cli
@midgar/express added to plugins.json !
```## Fonctionnement
Ajoute un service **mid:express**:
```js
const expressService = mid.getService('mid:express')// App express
const app = expressService.app
```## Ajouter un middlware express
```js
import morgan from 'morgan'
import { Plugin } from '@midgar/midgar'/**
* TestPlugin
*/
class TestPlugin extends Plugin {
init () {
// Listen @midgar/express:afterInit event
this.mid.on('@midgar/express:afterInit', (expressService) => {
expressService.app.use(morgan('combined'))
})
}
}export default TestPlugin
```## Configuration
Ceci est la configuration par défault si elle n'est pas modifié dans la configration de Midgar.
```js
{
...
express: {
port: 3000,
host: 'localhost',
ssl: false,
sslCert: '',
sslKey: ''
}
...
}```
Vous pouvez activer cors depuis cette même configuration:
```js
{
...
express: {
port: 3000,
...
cors: {
origin: 'https://domain.com',
credentials: true,
allowedHeaders: [
'Access-Control-Allow-Headers',
'Origin',
'Accept',
...
]
}
}
...
}```
Vous trouverez plus d'information sur la configuration du module cors [ici](https://www.npmjs.com/package/cors).