-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.js
108 lines (97 loc) · 4.01 KB
/
config.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const log4js = require('log4js');
let logLevel = process.env.LOG_LEVEL || 'info';
if (process.env.NODE_ENV !== 'production') logLevel = 'trace';
log4js.configure({
appenders: { out: { type: 'stdout', layout: { type: 'basic' } } },
categories: { default: { appenders: ['out'], level: logLevel } }
});
const logger = log4js.getLogger('Config');
logger.info(`NODE_ENV :: ${process.env.NODE_ENV}`);
logger.info(`LOG_LEVEL :: ${logLevel}`);
const DATA_STACK_NAMESPACE = process.env.DATA_STACK_NAMESPACE || 'appveen';
function isK8sEnv() {
return process.env.KUBERNETES_SERVICE_HOST && process.env.KUBERNETES_SERVICE_PORT;
}
function get(_service) {
if (isK8sEnv()) {
if (_service == 'ne') return `http://ne.${DATA_STACK_NAMESPACE}`;
if (_service == 'sm') return `http://sm.${DATA_STACK_NAMESPACE}`;
if (_service == 'dm') return `http://dm.${DATA_STACK_NAMESPACE}`;
if (_service == 'user') return `http://user.${DATA_STACK_NAMESPACE}`;
if (_service == 'gw') return `http://gw.${DATA_STACK_NAMESPACE}`;
if (_service == 'sec') return `http://sec.${DATA_STACK_NAMESPACE}`;
if (_service == 'bm') return `http://bm.${DATA_STACK_NAMESPACE}`;
} else {
if (_service == 'ne') return 'http://localhost:10010';
if (_service == 'sm') return 'http://localhost:10003';
if (_service == 'dm') return 'http://localhost:10709';
if (_service == 'user') return 'http://localhost:10004';
if (_service == 'gw') return 'http://localhost:9080';
if (_service == 'sec') return 'http://localhost:10007';
if (_service == 'bm') return 'http://localhost:10011';
}
}
if (isK8sEnv()) {
logger.info('*** K8s environment detected ***');
logger.info('Image version: ' + (process.env.IMAGE_TAG || 'dev'));
} else {
logger.info('*** Local environment detected ***');
}
const e = {
baseUrlSM: get('sm') + '/sm',
baseUrlNE: get('ne') + '/ne',
baseUrlUSR: get('user') + '/rbac',
baseUrlBM: get('bm') + '/bm',
baseUrlFLOW: get('bm') + '/b2b/pipes',
baseUrlSEC: get('sec') + '/sec',
baseUrlDM: get('dm') + '/dm',
baseUrlGW: get('gw'),
isK8sEnv,
imageTag: process.env.IMAGE_TAG || 'dev',
hostname: process.env.HOSTNAME,
port: process.env.PORT || 8080,
httpsPort: process.env.HTTPS_PORT || 8443,
app: process.env.DATA_STACK_APP || 'Adam',
appDB: process.env.DATA_DB || 'datastackB2B',
appNamespace: process.env.DATA_STACK_FLOW_NAMESPACE,
flowId: process.env.DATA_STACK_FLOW_ID || 'FLOW0012',
DATA_STACK_NAMESPACE,
RBAC_JWT_KEY: process.env.RBAC_JWT_KEY || 'u?5k167v13w5fhjhuiweuyqi67621gqwdjavnbcvadjhgqyuqagsduyqtw87e187etqiasjdbabnvczmxcnkzn',
mongoUrl: process.env.MONGO_APPCENTER_URL || 'mongodb://localhost',
authorDB: process.env.MONGO_AUTHOR_DBNAME || 'datastackConfig',
mongoAuthorUrl: process.env.MONGO_AUTHOR_URL || 'mongodb://localhost',
mongoLogUrl: process.env.MONGO_LOGS_URL || 'mongodb://localhost',
logsDB: process.env.MONGO_LOGS_DBNAME || 'datastackLogs',
googleKey: process.env.GOOGLE_API_KEY || '',
queueName: 'webHooks',
streamingConfig: {
url: process.env.STREAMING_HOST || 'nats://127.0.0.1:4222',
user: process.env.STREAMING_USER || '',
pass: process.env.STREAMING_PASS || '',
// maxReconnectAttempts: process.env.STREAMING_RECONN_ATTEMPTS || 500,
// reconnectTimeWait: process.env.STREAMING_RECONN_TIMEWAIT_MILLI || 500
maxReconnectAttempts: process.env.STREAMING_RECONN_ATTEMPTS || 500,
connectTimeout: 2000,
stanMaxPingOut: process.env.STREAMING_RECONN_TIMEWAIT_MILLI || 500
},
mongoAuthorOptions: {
useUnifiedTopology: true,
useNewUrlParser: true,
dbName: process.env.MONGO_AUTHOR_DBNAME || 'datastackConfig',
},
mongoAppCenterOptions: {
useUnifiedTopology: true,
useNewUrlParser: true,
},
mongoLogsOptions: {
useUnifiedTopology: true,
useNewUrlParser: true,
dbName: process.env.MONGO_LOGS_DBNAME || 'datastackLogs'
},
encryptionKey: process.env.ENCRYPTION_KEY || '34857057658800771270426551038148',
get,
serverTimeout: process.env.SERVER_TIMEOUT || '60',
b2bAllowNpmInstall: process.env.B2B_ALLOW_NPM_INSTALL || 'true',
kafkaPollingInterval: process.env.KAFKA_POLLING_INTERVAL || 200
};
module.exports = e;