-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdefault.js
executable file
·44 lines (38 loc) · 1.2 KB
/
default.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
/**
* Copyright (C) 2017 TopCoder Inc., All Rights Reserved.
*/
/**
* the default config
*
* @author TCSCODER
* @version 1.0
*/
const path = require('path');
const fs = require('fs');
const _ = require('lodash');
let config = {
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
PORT: process.env.PORT || 3003,
API_VERSION: 'api/1.0',
WORK_ROOT: path.join(__dirname, '..'),
IDLE_TIMEOUT_IN_MINS: 30,
IDLE_CONNECTION_POLL_INTERVAL: 1,
MAX_RETRIES: 5,
defaultExternalConfigLink: 'https://raw.githubusercontent.com/jiangliwu/static-files/master/config.json',
defaultExternalConfigFileName: 'defaultExternalCache.json',
externalConfigFileName: 'externalCache.json',
};
/**
* merge json config to config object
* @param fileName the config json file
*/
function mergeConfig(fileName) {
console.log('start check ' + fileName); // eslint-disable-line here use console.log
if (fs.existsSync(path.join(__dirname, fileName))) {
const content = fs.readFileSync(path.join(__dirname, fileName));
config = _.extend({}, config, JSON.parse(content.toString()));
}
}
mergeConfig(config.defaultExternalConfigFileName);
mergeConfig(config.externalConfigFileName);
module.exports = config;