2017-11-27 07:15:09 +01:00
|
|
|
// @flow
|
|
|
|
import express from 'express';
|
|
|
|
import bodyParser from 'body-parser';
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
export default class ExpressServer {
|
|
|
|
app: any;
|
|
|
|
server: any;
|
2017-11-27 07:15:09 +01:00
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
constructor() {
|
|
|
|
this.app = express();
|
|
|
|
this.server;
|
|
|
|
}
|
|
|
|
|
|
|
|
start(port: number): Promise<any> {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
this.app.use(bodyParser.json());
|
|
|
|
this.app.use(bodyParser.urlencoded({
|
2017-11-27 07:15:09 +01:00
|
|
|
extended: true
|
|
|
|
}));
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
this.server = this.app.listen(port, function starExpressServer() {
|
2017-11-27 07:15:09 +01:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|