-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
46 lines (35 loc) · 1019 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
36
37
38
39
40
41
42
43
44
45
46
var cors = require('cors');
var express = require('express');
var winston = require('winston');
var nconf = require('nconf');
var settings = require('./settings');
//remove it so to add it with my settings
winston.remove(winston.transports.Console);
var winstonOptions = {
colorize: true,
timestamp: true,
handleExceptions: true,
prettyPrint: true,
};
if (process.env.LOG_LEVEL) {
winstonOptions.level = process.env.LOG_LEVEL;
} else if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
winstonOptions.level = 'debug';
} else {
winstonOptions.level = 'info';
}
winston.add(winston.transports.Console, winstonOptions);
//Initialisations
require('./init')(nconf);
var app = express();
if (settings.server.useCors) {
app.use(cors());
}
var appRoutes = require('./server');
appRoutes(app);
var server = app.listen(settings.server.runPort, function() {
winston.info('Server listening', {
host: server.address().address,
port: server.address().port,
});
});