-
Notifications
You must be signed in to change notification settings - Fork 2
/
components.js
42 lines (35 loc) · 1.09 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
41
42
"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: "auth",
level: config.log_level
});
log.info({config});
module.exports.config = config;
module.exports.clientData = require("commons/client-data")(config["client-data"]);
module.exports.logger = log;
var elasticConfig = Object.assign({}, config.elastic);
module.exports.searcher = new search.Searcher(elasticConfig);
return module.exports;
})
.catch(err => {
console.error(err);
process.exit(1);
});
}
module.exports = {
init
};