-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (24 loc) · 900 Bytes
/
Copy pathapp.js
File metadata and controls
32 lines (24 loc) · 900 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
const express = require('express'),
bodyParser = require('body-parser'),
rollbar = require('rollbar'),
morgan = require('morgan'),
config = require('./config/config').config,
routes = require('./app/routes'),
orm = require('./app/orm');
const init = () => {
const app = express();
module.exports = app;
// Client must send "Content-Type: application/json" header
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
morgan.token('req-params', (req) => req.params);
app.use(morgan('[:date[clf]] :remote-addr - Request ":method :url" with params: :req-params. Response status: :status.'));
orm.init(app);
routes.init(app);
app.use(rollbar.errorHandler(config.common.rollbar.accessToken, {
enabled: !!config.common.rollbar.accessToken,
environment: config.environment
}));
app.listen(config.common.port || 8080);
};
init();