-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
30 lines (23 loc) · 832 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
'use strict';
const app = require('express')();
const bodyParser = require('body-parser');
const config = require('./config');
const errorHandler = require('./middleware/error');
const middleware = require('./middleware');
const paginationParams = require('./middleware/paginationParams');
const routes = require('./routes');
const deleteFiles = require('./middleware/remove');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false, limit: `${config.files.size}mb`
}));
app.use(middleware.addHeaders);
app.use(middleware.logMiddleware);
// process pagination parameters
app.use(paginationParams);
app.use('/', routes);
app.use(middleware.responseMiddleware);
app.use(middleware.catch404);
app.use(deleteFiles.deleteErrorHangingFiles);
app.use(errorHandler({ env: config.env }));
module.exports = app;