-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (32 loc) · 1001 Bytes
/
app.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 express = require('express');
var morgan = require('morgan');
var bodyParser = require('body-parser');
var mongoConnection = require('./dao/mongo-connection');
var swaggerTools = require('swagger-tools');
function start() {
mongoConnection.connect();
var app = express();
app.use(morgan('dev'));
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true,
parameterLimit: 50000
}));
app.use(bodyParser.json());
var swaggerOpt = {
swaggerUi: '/swagger.json',
controllers: './controller',
useStubs: process.env.NODE_ENV === 'DEV' ? true : false
};
var swaggerDoc = require('./swagger.json');
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
app.use(middleware.swaggerMetadata());
app.use(middleware.swaggerValidator());
app.use(middleware.swaggerUi());
app.use(middleware.swaggerRouter(swaggerOpt));
});
return app;
}
module.exports = start();