This repository was archived by the owner on Mar 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.js
60 lines (54 loc) · 1.59 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (c) 2017 TopCoder, Inc. All rights reserved.
*/
'use strict';
const config = require('config');
const _ = require('lodash');
const kafkaConsumer = require('./utils/kafka-consumer');
const logger = require('./utils/logger');
process.on('uncaughtException', (err) => {
// Check if error related to Dynamodb conn
if (err.code === 'NetworkingError' && err.region) {
logger.error('DynamoDB connection failed.');
}
logger.logFullError(err, 'system');
});
// handle and log unhanled rejection
process.on('unhandledRejection', (err) => {
logger.logFullError(err, 'system');
});
// dump the configuration to logger
const ignoreConfigLog = ['cert', 'key', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET',
'GITLAB_CLIENT_ID', 'GITLAB_CLIENT_SECRET'];
/**
* Print configs to logger
* @param {Object} params the config params
* @param {Number} level the level of param object
*/
function dumpConfigs(params, level) {
Object.keys(params).forEach((key) => {
if (_.includes(ignoreConfigLog, key)) {
return;
}
const item = params[key];
let str = '';
let n = 0;
while (n < level) { // eslint-disable-line no-restricted-syntax
n++;
str += ' ';
}
if (item && _.isObject(item)) {
str += `${key}=`;
logger.debug(str);
dumpConfigs(item, level + 1);
} else {
str += `${key}=${item}`;
logger.debug(str);
}
});
}
logger.debug('--- List of Configurations ---');
dumpConfigs(config, 0);
logger.debug('--- End of List of Configurations ---');
// run the server
kafkaConsumer.run();