-
Notifications
You must be signed in to change notification settings - Fork 1
/
components.js
40 lines (34 loc) · 1.02 KB
/
components.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
"use strict";
const option = require("commons/option");
const bunyan = require("bunyan");
const search = require("commons/search");
function init() {
return option().config.then(config => {
for (let key in config) {
if (process.env[`egf_${key}`]) {
try {
config[key] = JSON.parse(process.env[`egf_${key}`]);
} catch (e) {
config[key] = process.env[`egf_${key}`];
}
}
}
const log = bunyan.createLogger({
name: "file",
level: config.log_level
});
log.info({config});
module.exports.config = config;
module.exports.clientData = require("commons/client-data")(config["client-data"]);
module.exports.searcher = new search.Searcher(config.elastic);
module.exports.logger = log;
return module.exports;
})
.catch(err => {
console.error(err);
process.exit(1);
});
}
module.exports = {
init
};