-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (28 loc) · 813 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
const bodyParser = require('body-parser');
const cors = require('cors');
const express = require('express');
const helmet = require('helmet');
const morgan = require('morgan');
const winston = require('./utils/logger');
const app = express();
app.use(morgan('combined', { stream: winston.stream }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors());
app.use(helmet());
app.get('/', function(req, res) {
res.send('Express Module With Docker Setup');
});
// routes
require('./routes/group')(app);
// 404
app.use((req, res, next) => {
const err = new Error(`Route${req.url} Not found.`);
err.status = 404;
next(err);
});
// Any server error
app.use((err, req, res, next) => {
res.status(err.status || 500).send(err.message);
});
module.exports = app;