@mimik/configuration 4.4.3 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/index.js +26 -13
- package/lib/common.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ The following environment variables are being setup:
|
|
|
50
50
|
| CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
|
|
51
51
|
| LOG_LEVEL | log level for console output | debug | logInfo.logLevel
|
|
52
52
|
| AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
|
|
53
|
-
|
|
|
53
|
+
| MST_SET | to setup configuration without mST and oauth token setup | on | on/off
|
|
54
54
|
|
|
55
55
|
The following environement variables are being used for the configuration:
|
|
56
56
|
|
|
@@ -99,6 +99,8 @@ The following environement variables are being used for the configuration:
|
|
|
99
99
|
|
|
100
100
|
[2]: defined when registering to mST
|
|
101
101
|
|
|
102
|
+
When MST_SET is `off`, registration and cluster should not be enabled, so configuration.cluster.management and configuration.registration.set will be set to `off``
|
|
103
|
+
|
|
102
104
|
When `sumologic` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
|
|
103
105
|
|
|
104
106
|
| Env variable name | Description | Default | Comments |
|
package/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
AWS_S3,
|
|
18
18
|
ALL,
|
|
19
19
|
SET_ON,
|
|
20
|
+
SET_OFF,
|
|
20
21
|
NO_PUBLIC_PROVIDER,
|
|
21
22
|
NO_GENERIC,
|
|
22
23
|
ENV_VARIABLE,
|
|
@@ -89,7 +90,7 @@ const {
|
|
|
89
90
|
let display = true;
|
|
90
91
|
const locParams = [NO_PUBLIC_PROVIDER, ENV_VARIABLE];
|
|
91
92
|
const correlationIdStart = getCorrelationId('config-start');
|
|
92
|
-
const
|
|
93
|
+
const isMSTSet = process.env.MST_SET !== SET_OFF;
|
|
93
94
|
|
|
94
95
|
const setupRedis = () => {
|
|
95
96
|
const domain = process.env.CACHE_IP || DEFAULT_CACHE_IP;
|
|
@@ -134,7 +135,6 @@ const setupRedis = () => {
|
|
|
134
135
|
idTTL: parseInt(process.env.CACHE_API_ID_TTL, 10) || DEFAULT_CACHE_API_ID_TTL,
|
|
135
136
|
optionTTL: parseInt(process.env.CACHE_API_OPTION_TTL, 10) || DEFAULT_CACHE_API_OPTION_TTL,
|
|
136
137
|
},
|
|
137
|
-
isMSTDisabled,
|
|
138
138
|
};
|
|
139
139
|
};
|
|
140
140
|
|
|
@@ -303,22 +303,25 @@ const setupEncryption = (encryptionOpts) => {
|
|
|
303
303
|
};
|
|
304
304
|
|
|
305
305
|
const checkConfig = (config) => {
|
|
306
|
-
const
|
|
306
|
+
const errors = [];
|
|
307
307
|
|
|
308
308
|
function traverseNodeSync(node, path) {
|
|
309
309
|
Object.keys(node).forEach((prop) => {
|
|
310
310
|
if (typeof node[prop] === 'object' && node[prop]) {
|
|
311
311
|
traverseNodeSync(node[prop], `${path}.${prop}`);
|
|
312
312
|
}
|
|
313
|
-
else if (_.isUndefined(node[prop]))
|
|
313
|
+
else if (_.isUndefined(node[prop])) errors.push({ reason: 'missing', value: `${path}.${prop}` });
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
traverseNodeSync(config, 'configuration');
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
// dependency errors
|
|
319
|
+
if (isMSTSet && config.security.apiKeys.length === 0) errors.push({ reason: 'invalid', value: 'config.security.apiKeys', cause: 'isMSTSet' });
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
if (errors.length > 0) {
|
|
322
|
+
const error = new Error('Errors in configuration');
|
|
323
|
+
|
|
324
|
+
logger.error(error, { errors }, correlationIdStart);
|
|
322
325
|
throw error;
|
|
323
326
|
}
|
|
324
327
|
};
|
|
@@ -356,6 +359,7 @@ const configuration = {
|
|
|
356
359
|
customerCode: process.env.CUSTOMER_CODE || DEFAULT_CUSTOMER_CODE,
|
|
357
360
|
customerCodeSep: process.env.CUSTOMER_CODE ? CUSTOMER_CODE_SEP : '',
|
|
358
361
|
securitySet: process.env.SERVER_SECURITY_SET || DEFAULT_SERVER_SECURITY_SET,
|
|
362
|
+
isMSTSet,
|
|
359
363
|
port: process.env.SERVER_PORT,
|
|
360
364
|
interceptError: process.env.INTERCEPT_ERROR || DEFAULT_INTERCEPT_ERROR,
|
|
361
365
|
ip: {
|
|
@@ -370,7 +374,7 @@ const configuration = {
|
|
|
370
374
|
admin: {
|
|
371
375
|
externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
|
|
372
376
|
},
|
|
373
|
-
server:
|
|
377
|
+
server: {
|
|
374
378
|
id: process.env.OAUTH_CLIENT_ID,
|
|
375
379
|
secret: process.env.OAUTH_CLIENT_SECRET,
|
|
376
380
|
accessKey: process.env.OAUTH_CLIENT_ACCESS_KEY,
|
|
@@ -396,7 +400,7 @@ const configuration = {
|
|
|
396
400
|
topic: {
|
|
397
401
|
set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
|
|
398
402
|
},
|
|
399
|
-
dependencies:
|
|
403
|
+
dependencies: {
|
|
400
404
|
mIT: {
|
|
401
405
|
url: process.env.MIT_URL,
|
|
402
406
|
audience: process.env.MIT_AUDIENCE,
|
|
@@ -408,6 +412,13 @@ const configuration = {
|
|
|
408
412
|
},
|
|
409
413
|
};
|
|
410
414
|
|
|
415
|
+
// cross dependencies
|
|
416
|
+
if (!isMSTSet) {
|
|
417
|
+
configuration.registration.set = SET_OFF;
|
|
418
|
+
configuration.cluster.management = SET_OFF;
|
|
419
|
+
configuration.security.server = {};
|
|
420
|
+
configuration.dependencies = {};
|
|
421
|
+
}
|
|
411
422
|
if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
|
|
412
423
|
if (process.env.SWAGGER_API_KEY) configuration.serverSettings.apiKey = process.env.SWAGGER_API_KEY;
|
|
413
424
|
configuration.logInfo = setupLog();
|
|
@@ -439,7 +450,7 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
439
450
|
* | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
|
|
440
451
|
* | LOG_LEVEL | log level for console output | debug | logInfo.logLevel
|
|
441
452
|
* | AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
|
|
442
|
-
* |
|
|
453
|
+
* | MST_SET | to setup configuration without mST and oauth token setup | on | on/off
|
|
443
454
|
*
|
|
444
455
|
* The following environement variables are being used for the configuration:
|
|
445
456
|
*
|
|
@@ -488,6 +499,8 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
488
499
|
*
|
|
489
500
|
* [2]: defined when registering to mST
|
|
490
501
|
*
|
|
502
|
+
* When MST_SET is `off`, registration and cluster should not be enabled, so configuration.cluster.management and configuration.registration.set will be set to `off``
|
|
503
|
+
*
|
|
491
504
|
* When `sumologic` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
|
|
492
505
|
*
|
|
493
506
|
* | Env variable name | Description | Default | Comments |
|
|
@@ -615,7 +628,7 @@ const setConfig = (pack, options) => {
|
|
|
615
628
|
url: process.env[`${configuration.serverSettings.type}_URL`.toUpperCase()] || 'self', // this url should never be needed
|
|
616
629
|
};
|
|
617
630
|
|
|
618
|
-
if (
|
|
631
|
+
if (isMSTSet) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
|
|
619
632
|
|
|
620
633
|
if (options.database) {
|
|
621
634
|
if (options.database.type === 'mongodb') {
|
|
@@ -650,8 +663,8 @@ const setConfig = (pack, options) => {
|
|
|
650
663
|
}
|
|
651
664
|
if (options.dependencies) {
|
|
652
665
|
Object.keys(options.dependencies).forEach((dependency) => {
|
|
653
|
-
if (
|
|
654
|
-
configuration.dependencies[dependency] = options.dependencies[dependency]
|
|
666
|
+
if (isMSTSet) {
|
|
667
|
+
configuration.dependencies[dependency] = options.dependencies[dependency];
|
|
655
668
|
}
|
|
656
669
|
else if (options.dependencies[dependency].apiKey) {
|
|
657
670
|
configuration.dependencies[dependency] = {
|
package/lib/common.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/configuration",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.7",
|
|
4
4
|
"description": "Common configuration for mimik services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@mimik/eslint-plugin-dependencies": "^2.4.1",
|
|
40
40
|
"@mimik/eslint-plugin-document-env": "^1.0.1",
|
|
41
|
-
"eslint": "8.
|
|
41
|
+
"eslint": "8.7.0",
|
|
42
42
|
"eslint-config-airbnb": "18.2.1",
|
|
43
43
|
"eslint-plugin-import": "2.25.4",
|
|
44
44
|
"eslint-plugin-jsx-a11y": "6.5.1",
|