-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.js
More file actions
55 lines (48 loc) · 1.66 KB
/
settings.js
File metadata and controls
55 lines (48 loc) · 1.66 KB
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
47
48
49
50
51
52
53
54
55
const _ = require('lodash');
const config = require('@cheevr/config');
const fs = require('fs');
const Logger = require('@cheevr/logging');
const path = require('path');
const util = require('util');
const cwd = process.cwd();
const application = path.basename(path.dirname(require.main.filename));
const viewDir = config.normalizePath(cwd, config.paths.views);
viewDir.push(path.join(__dirname, 'static/views'));
if (config.printConfig) {
function clean(obj) {
for (let prop in obj) {
let val = obj[prop];
if (_.isObject(val) && !(val instanceof Buffer)){
clean(val);
} else if (_.isArray(val)) {
for (let entry of val) {
clean(entry);
}
} else {
switch (prop) {
case 'password':
case 'salt':
case 'secret':
case 'key':
obj[prop] = '*****'
}
}
}
}
let copy = _.cloneDeep(config);
delete copy._default;
clean(copy);
Logger.server.info('Launch Configuration: ' + util.inspect(copy, {showHidden: false, depth: null}));
}
module.exports = app => {
// Configure the jsonp callback
app.set('jsonp callback name', 'cb');
// Set proper ip address reporting
app.set('trust proxy', true);
// Set view engine to pug
let views = viewDir.filter(dir => fs.existsSync(dir));
app.set('view engine', 'pug');
app.set('views', views);
// Set the process name to something friendly
process.title = application + ' tier:' + config.tier + ' port:' + config.backend.port;
};