@mimik/configuration 4.4.1 → 4.4.5
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 +4 -1
- package/index.js +27 -9
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -49,7 +49,8 @@ The following environment variables are being setup:
|
|
|
49
49
|
| SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
|
|
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
|
-
| AWS_LOCAL_PROPERTIES | internal ip address to access aws
|
|
52
|
+
| AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
|
|
53
|
+
| MST_SET | to setup configuration without mST and oauth token setup | on | on/off
|
|
53
54
|
|
|
54
55
|
The following environement variables are being used for the configuration:
|
|
55
56
|
|
|
@@ -98,6 +99,8 @@ The following environement variables are being used for the configuration:
|
|
|
98
99
|
|
|
99
100
|
[2]: defined when registering to mST
|
|
100
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
|
+
|
|
101
104
|
When `sumologic` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
|
|
102
105
|
|
|
103
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,
|
|
@@ -86,9 +87,10 @@ const {
|
|
|
86
87
|
DEFAULT_INTERCEPT_ERROR,
|
|
87
88
|
} = require('./lib/common');
|
|
88
89
|
|
|
89
|
-
const correlationIdStart = getCorrelationId('config-start');
|
|
90
90
|
let display = true;
|
|
91
91
|
const locParams = [NO_PUBLIC_PROVIDER, ENV_VARIABLE];
|
|
92
|
+
const correlationIdStart = getCorrelationId('config-start');
|
|
93
|
+
const isMSTSet = process.env.MST_SET !== SET_OFF;
|
|
92
94
|
|
|
93
95
|
const setupRedis = () => {
|
|
94
96
|
const domain = process.env.CACHE_IP || DEFAULT_CACHE_IP;
|
|
@@ -133,6 +135,7 @@ const setupRedis = () => {
|
|
|
133
135
|
idTTL: parseInt(process.env.CACHE_API_ID_TTL, 10) || DEFAULT_CACHE_API_ID_TTL,
|
|
134
136
|
optionTTL: parseInt(process.env.CACHE_API_OPTION_TTL, 10) || DEFAULT_CACHE_API_OPTION_TTL,
|
|
135
137
|
},
|
|
138
|
+
isMSTSet,
|
|
136
139
|
};
|
|
137
140
|
};
|
|
138
141
|
|
|
@@ -212,9 +215,6 @@ const setupMongo = (dbOpts) => {
|
|
|
212
215
|
table: dbOpts.table,
|
|
213
216
|
url,
|
|
214
217
|
options: {
|
|
215
|
-
useNewUrlParser: true,
|
|
216
|
-
useUnifiedTopology: true,
|
|
217
|
-
useCreateIndex: true,
|
|
218
218
|
family: parseInt(process.env.MONGO_FAMILY, 10) || DEFAULT_MONGO_FAMILY,
|
|
219
219
|
keepAlive: process.env.MONGO_KEEP_ALIVE || DEFAULT_MONGO_KEEP_ALIVE,
|
|
220
220
|
keepAliveInitialDelay: parseInt(process.env.MONGO_KEEP_ALIVE_INITIAL_DELAY, 10) || DEFAULT_MONGO_KEEP_ALIVE_INITIAL_DELAY,
|
|
@@ -357,6 +357,7 @@ const configuration = {
|
|
|
357
357
|
customerCode: process.env.CUSTOMER_CODE || DEFAULT_CUSTOMER_CODE,
|
|
358
358
|
customerCodeSep: process.env.CUSTOMER_CODE ? CUSTOMER_CODE_SEP : '',
|
|
359
359
|
securitySet: process.env.SERVER_SECURITY_SET || DEFAULT_SERVER_SECURITY_SET,
|
|
360
|
+
isMSTSet,
|
|
360
361
|
port: process.env.SERVER_PORT,
|
|
361
362
|
interceptError: process.env.INTERCEPT_ERROR || DEFAULT_INTERCEPT_ERROR,
|
|
362
363
|
ip: {
|
|
@@ -371,7 +372,7 @@ const configuration = {
|
|
|
371
372
|
admin: {
|
|
372
373
|
externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
|
|
373
374
|
},
|
|
374
|
-
server: {
|
|
375
|
+
server: !isMSTSet ? {} : {
|
|
375
376
|
id: process.env.OAUTH_CLIENT_ID,
|
|
376
377
|
secret: process.env.OAUTH_CLIENT_SECRET,
|
|
377
378
|
accessKey: process.env.OAUTH_CLIENT_ACCESS_KEY,
|
|
@@ -397,7 +398,7 @@ const configuration = {
|
|
|
397
398
|
topic: {
|
|
398
399
|
set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
|
|
399
400
|
},
|
|
400
|
-
dependencies: { //
|
|
401
|
+
dependencies: !isMSTSet ? {} : { // every server will report to mIT unless mST setup is disabled
|
|
401
402
|
mIT: {
|
|
402
403
|
url: process.env.MIT_URL,
|
|
403
404
|
audience: process.env.MIT_AUDIENCE,
|
|
@@ -409,6 +410,10 @@ const configuration = {
|
|
|
409
410
|
},
|
|
410
411
|
};
|
|
411
412
|
|
|
413
|
+
if (!isMSTSet) {
|
|
414
|
+
configuration.registration.set = SET_OFF;
|
|
415
|
+
configuration.cluster.management = SET_OFF;
|
|
416
|
+
}
|
|
412
417
|
if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
|
|
413
418
|
if (process.env.SWAGGER_API_KEY) configuration.serverSettings.apiKey = process.env.SWAGGER_API_KEY;
|
|
414
419
|
configuration.logInfo = setupLog();
|
|
@@ -439,7 +444,8 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
439
444
|
* | SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
|
|
440
445
|
* | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
|
|
441
446
|
* | LOG_LEVEL | log level for console output | debug | logInfo.logLevel
|
|
442
|
-
* | AWS_LOCAL_PROPERTIES | internal ip address to access aws
|
|
447
|
+
* | AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
|
|
448
|
+
* | MST_SET | to setup configuration without mST and oauth token setup | on | on/off
|
|
443
449
|
*
|
|
444
450
|
* The following environement variables are being used for the configuration:
|
|
445
451
|
*
|
|
@@ -488,6 +494,8 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
488
494
|
*
|
|
489
495
|
* [2]: defined when registering to mST
|
|
490
496
|
*
|
|
497
|
+
* 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``
|
|
498
|
+
*
|
|
491
499
|
* When `sumologic` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
|
|
492
500
|
*
|
|
493
501
|
* | Env variable name | Description | Default | Comments |
|
|
@@ -601,6 +609,7 @@ const setConfig = (pack, options) => {
|
|
|
601
609
|
process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
|
|
602
610
|
}
|
|
603
611
|
|
|
612
|
+
// eslint-disable-next-line max-len
|
|
604
613
|
const apiFilename = `${process.env.SWAGGER_FILE_ACCOUNT}${SWAGGER_SEP}${process.env.SWAGGER_FILE_NAME}${SWAGGER_SEP}${process.env.SWAGGER_FILE_VERSION}${SWAGGER_SEP}${SWAGGER_EXT}`;
|
|
605
614
|
|
|
606
615
|
configuration.serverSettings.name = process.env.SERVER_NAME;
|
|
@@ -612,9 +621,10 @@ const setConfig = (pack, options) => {
|
|
|
612
621
|
// default for every server for cluster management
|
|
613
622
|
configuration.dependencies[configuration.serverSettings.type] = {
|
|
614
623
|
url: process.env[`${configuration.serverSettings.type}_URL`.toUpperCase()] || 'self', // this url should never be needed
|
|
615
|
-
audience: process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()],
|
|
616
624
|
};
|
|
617
625
|
|
|
626
|
+
if (isMSTSet) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
|
|
627
|
+
|
|
618
628
|
if (options.database) {
|
|
619
629
|
if (options.database.type === 'mongodb') {
|
|
620
630
|
configuration.mongoSettings = setupMongo(options.database);
|
|
@@ -648,7 +658,15 @@ const setConfig = (pack, options) => {
|
|
|
648
658
|
}
|
|
649
659
|
if (options.dependencies) {
|
|
650
660
|
Object.keys(options.dependencies).forEach((dependency) => {
|
|
651
|
-
|
|
661
|
+
if (isMSTSet) {
|
|
662
|
+
configuration.dependencies[dependency] = options.dependencies[dependency];
|
|
663
|
+
}
|
|
664
|
+
else if (options.dependencies[dependency].apiKey) {
|
|
665
|
+
configuration.dependencies[dependency] = {
|
|
666
|
+
url: options.dependencies[dependency].url,
|
|
667
|
+
apiKey: options.dependencies[dependency].apiKey,
|
|
668
|
+
};
|
|
669
|
+
}
|
|
652
670
|
});
|
|
653
671
|
}
|
|
654
672
|
if (options.custom) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/configuration",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.5",
|
|
4
4
|
"description": "Common configuration for mimik services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@mimik/eslint-plugin-dependencies": "^2.4.1",
|
|
40
|
-
"@mimik/eslint-plugin-document-env": "^1.0.
|
|
41
|
-
"eslint": "8.
|
|
40
|
+
"@mimik/eslint-plugin-document-env": "^1.0.1",
|
|
41
|
+
"eslint": "8.7.0",
|
|
42
42
|
"eslint-config-airbnb": "18.2.1",
|
|
43
|
-
"eslint-plugin-import": "2.25.
|
|
43
|
+
"eslint-plugin-import": "2.25.4",
|
|
44
44
|
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
45
|
-
"eslint-plugin-react": "7.
|
|
45
|
+
"eslint-plugin-react": "7.28.0",
|
|
46
46
|
"eslint-plugin-react-hooks": "4.3.0",
|
|
47
|
-
"fancy-log": "
|
|
47
|
+
"fancy-log": "2.0.0",
|
|
48
48
|
"gulp": "4.0.2",
|
|
49
49
|
"gulp-eslint": "6.0.0",
|
|
50
50
|
"gulp-git": "2.10.1",
|