-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·35 lines (26 loc) · 733 Bytes
/
app.js
File metadata and controls
executable file
·35 lines (26 loc) · 733 Bytes
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 express = require('express');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const routes = require('./routes');
require('./services/mongo');
const app = express();
app.use(logger('dev'));
app.use(bodyParser.json({ limit: '300kb' }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(routes);
// catch 404 and forward to error handler
app.use((req, res, next) => {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use((err, req, res) => {
res.status(err.status || 500).json({
error: true,
status: err.status || 500,
});
});
module.exports = app;