-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (35 loc) · 1.25 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var Http = require('http');
var Express = require('express');
var BodyParser = require('body-parser');
var Swaggerize = require('swaggerize-express');
var CollectorHandler = require('./collector-handler');
var Path = require('path');
var Log = require('timestamp-log');
var log = new Log(process.env.LOG_LEVEL);
require('dotenv').config();
var App = Express();
var Server = Http.createServer(App);
App.use(BodyParser.json());
App.use(BodyParser.urlencoded({
extended: true
}));
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./config/swagger.json');
App.use('/docs/api', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
App.use(Swaggerize({
api: Path.resolve('./config/swagger.yaml'),
handlers: Path.resolve('controllers')
}));
App.use(function (err, req, res, next) {
log.error('MessageServiceCollector:', err);
res.status(500).send(err);
});
Server.listen(8000, function () {
App.swagger.api.host = this.address().address + ':' + this.address().port;
/* eslint-disable no-console */
log.info('MessageServiceCollector: %s:%d', this.address().address, this.address().port);
/* eslint-disable no-console */
var collectorHandler = new CollectorHandler();
collectorHandler.start();
});