-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
38 lines (30 loc) · 1.12 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
require('./envConfigLoader')(process.env.NODE_ENV); // Load env based config
const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const app = express();
const http = require('http');
const initializeSentry = require('./sentry');
const initializeApp = () => {
initializeSentry(); // Sentry config initialization
/**
* Logger creation and configuration
*/
const logger = require('./logger').makeLogger('APP');
logger.info(`Loading env... ${process.env.NODE_ENV}`);
app.set('view engine', 'ejs');
app.use(function(_req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, jwt");
next();
});
app.use(bodyParser.json());
app.use(cookieParser());
app.use(express.static(`${__dirname}/assets`));
require('./routes')(app);
const httpServer = http.createServer(app);
httpServer.listen(process.env.PORT || 3000, () => logger.info('http 3000'));
return httpServer;
}
const mainApp = initializeApp();
module.exports = mainApp;