-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.js
More file actions
55 lines (47 loc) · 1.44 KB
/
config.js
File metadata and controls
55 lines (47 loc) · 1.44 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 path = require('path');
const fse = require('fs-extra');
const os = require('os');
const hbs = require('hbs');
const clarg = require('clarg');
const clOpts = clarg().opts;
const appPortRaw = clOpts.port || clOpts.p;
const appPortParsed = parseInt(appPortRaw, 10);
const appPort = (appPortRaw == appPortParsed) ? appPortParsed : 3000;
const appNetworkRaw = (clOpts.network || clOpts.n || '').trim();
const appNetwork = ['public', 'private'].indexOf(appNetworkRaw) === -1 ? 'local' : appNetworkRaw;
const networks = {
public: '0',
private: false,
local: '127.0.0.1'
};
// fixing for DO setup
// const privateInterface = os.networkInterfaces()['eth1'];
// if (privateInterface) {
// networks.private = _.map(_.find(privateInterface, {family: 'IPv4'}), 'address');
// }
const appNetworkInterface = networks[appNetwork];
const config = {
baseUrl: clOpts.url || clOpts.u || 'http://localhost:' + appPort,
appPort,
appNetwork,
appNetworkInterface,
paths: {
public: path.join(__dirname, 'public'),
views: path.join(__dirname, 'views'),
json: path.join(__dirname, 'json'),
logfile: path.join(__dirname, 'requestlog.json')
},
views: {
engine: hbs,
partialsPath: path.join(__dirname, 'views/partials')
},
currentVersion: '6.1'
};
// ensure request log file
try {
fse.accessSync(config.paths.logfile);
} catch (e) {
fse.writeJsonSync(config.paths.logfile, {});
}
module.exports = config;