-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (29 loc) · 932 Bytes
/
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
'use strict';
const Http = require('http');
const Express = require('express');
const BodyParser = require('body-parser');
const Swaggerize = require('swaggerize-express');
const SwaggerUi = require('swaggerize-ui');
const Path = require('path');
const App = Express();
const Server = Http.createServer(App);
App.use(BodyParser.json());
App.use(BodyParser.urlencoded({
extended: true
}));
App.use(Swaggerize({
api: Path.resolve('./config/swagger.json'),
handlers: Path.resolve('./handlers')
}));
App.use('/api-docs', (req, res) => {
res.json(require('./config/swagger.json'));
});
App.use('/docs', SwaggerUi({
docs: '/api-docs'
}));
Server.listen(process.env.PORT, function () {
App.swagger.api.host = this.address().address + ':' + this.address().port;
/* eslint-disable no-console */
console.log('App running on %s:%d', this.address().address, this.address().port);
/* eslint-disable no-console */
});