-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (45 loc) · 1.66 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const express = require('express');
const path = require('path');
const logger = require('morgan');
const fs = require('fs');
const cookieParser = require('cookie-parser');
require('dotenv').config();
// TODO :: Add Swagger for express
// const SwaggerExpress = require('swagger-express-mw');
// const swaggerUi = require('swagger-ui-express');
// const YAML = require('yamljs');
// const swaggerMerger = require('swagger-merger')
const bodyParser = require('body-parser');
const { config } = require('./config');
const api = require('./src/api/index');
// const { passport } = require('./src/passport');
// const { mongoManager } = require('./src/mongo');
// const { onAppStart } = require('./on-start');
const app = express();
// mongoManager.connect();
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
// middleware
app.use(bodyParser.json({
limit: config.bodyLimit,
}));
// Authorization
// app.use(passport.init());
// api routes v1
app.use('/api/v1', api(config));
// TODO :: Add Swagger for express
// register api doc
// const outputSwaggerDir = path.resolve(config.swaggerDirPath, './build');
// const swaggerBuildFilePath = path.resolve(outputSwaggerDir, './swagger.yaml');
// if(!fs.existsSync(outputSwaggerDir)) {
// fs.mkdirSync(outputSwaggerDir);
// }
// swaggerMerger({ input: config.swaggerFilePath, output: swaggerBuildFilePath });
// const swaggerDocument = YAML.load(swaggerBuildFilePath);
// app.use('/api/v1/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// on App start
//onAppStart();
module.exports = app;