forked from javascript-tutorial/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·46 lines (32 loc) · 962 Bytes
/
app.js
File metadata and controls
executable file
·46 lines (32 loc) · 962 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
36
37
38
39
40
41
42
43
44
45
46
//require("time-require");
const fs = require('fs');
const config = require('config');
const Application = require('application');
const app = new Application();
if (process.env.NODE_ENV != 'development') {
// only log.error in prod, otherwise just die
process.on('uncaughtException', function(err) {
// let bunyan handle the error
app.log.error({
message: err.message,
name: err.name,
errors: err.errors,
stack: err.stack
});
process.exit(255);
});
}
// The app is always behind Nginx which serves static
// (Maybe behind Cloudflare as well)
// trust all headers from the proxy
// X-Forwarded-Host
// X-Forwarded-Proto
// X-Forwarded-For -> ip
app.proxy = true;
// ========= Helper handlers ===========
config.handlers.forEach(handler => app.requireHandler(handler));
// must be last
app.requireHandler('404');
// uncomment for time-require to work
//process.emit('exit');
module.exports = app;