@mimik/configuration 4.4.2 → 4.4.6

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 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 insrance properties | 169.254.169.254
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
 
@@ -354,6 +357,7 @@ const configuration = {
354
357
  customerCode: process.env.CUSTOMER_CODE || DEFAULT_CUSTOMER_CODE,
355
358
  customerCodeSep: process.env.CUSTOMER_CODE ? CUSTOMER_CODE_SEP : '',
356
359
  securitySet: process.env.SERVER_SECURITY_SET || DEFAULT_SERVER_SECURITY_SET,
360
+ isMSTSet,
357
361
  port: process.env.SERVER_PORT,
358
362
  interceptError: process.env.INTERCEPT_ERROR || DEFAULT_INTERCEPT_ERROR,
359
363
  ip: {
@@ -368,7 +372,7 @@ const configuration = {
368
372
  admin: {
369
373
  externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
370
374
  },
371
- server: {
375
+ server: !isMSTSet ? {} : {
372
376
  id: process.env.OAUTH_CLIENT_ID,
373
377
  secret: process.env.OAUTH_CLIENT_SECRET,
374
378
  accessKey: process.env.OAUTH_CLIENT_ACCESS_KEY,
@@ -394,7 +398,7 @@ const configuration = {
394
398
  topic: {
395
399
  set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
396
400
  },
397
- dependencies: { // everyserver will resport to mIT
401
+ dependencies: !isMSTSet ? {} : { // every server will report to mIT unless mST setup is disabled
398
402
  mIT: {
399
403
  url: process.env.MIT_URL,
400
404
  audience: process.env.MIT_AUDIENCE,
@@ -406,6 +410,10 @@ const configuration = {
406
410
  },
407
411
  };
408
412
 
413
+ if (!isMSTSet) {
414
+ configuration.registration.set = SET_OFF;
415
+ configuration.cluster.management = SET_OFF;
416
+ }
409
417
  if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
410
418
  if (process.env.SWAGGER_API_KEY) configuration.serverSettings.apiKey = process.env.SWAGGER_API_KEY;
411
419
  configuration.logInfo = setupLog();
@@ -436,7 +444,8 @@ configuration.locationProvider = setupLocationProvider();
436
444
  * | SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
437
445
  * | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
438
446
  * | LOG_LEVEL | log level for console output | debug | logInfo.logLevel
439
- * | AWS_LOCAL_PROPERTIES | internal ip address to access aws insrance properties | 169.254.169.254
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
440
449
  *
441
450
  * The following environement variables are being used for the configuration:
442
451
  *
@@ -485,6 +494,8 @@ configuration.locationProvider = setupLocationProvider();
485
494
  *
486
495
  * [2]: defined when registering to mST
487
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
+ *
488
499
  * When `sumologic` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
489
500
  *
490
501
  * | Env variable name | Description | Default | Comments |
@@ -598,6 +609,7 @@ const setConfig = (pack, options) => {
598
609
  process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
599
610
  }
600
611
 
612
+ // eslint-disable-next-line max-len
601
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}`;
602
614
 
603
615
  configuration.serverSettings.name = process.env.SERVER_NAME;
@@ -609,9 +621,10 @@ const setConfig = (pack, options) => {
609
621
  // default for every server for cluster management
610
622
  configuration.dependencies[configuration.serverSettings.type] = {
611
623
  url: process.env[`${configuration.serverSettings.type}_URL`.toUpperCase()] || 'self', // this url should never be needed
612
- audience: process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()],
613
624
  };
614
625
 
626
+ if (isMSTSet) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
627
+
615
628
  if (options.database) {
616
629
  if (options.database.type === 'mongodb') {
617
630
  configuration.mongoSettings = setupMongo(options.database);
@@ -645,7 +658,15 @@ const setConfig = (pack, options) => {
645
658
  }
646
659
  if (options.dependencies) {
647
660
  Object.keys(options.dependencies).forEach((dependency) => {
648
- configuration.dependencies[dependency] = options.dependencies[dependency];
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
+ }
649
670
  });
650
671
  }
651
672
  if (options.custom) {
package/lib/common.js CHANGED
@@ -91,6 +91,7 @@ module.exports = {
91
91
  AWS_S3,
92
92
  ALL,
93
93
  SET_ON,
94
+ SET_OFF,
94
95
  CUSTOMER_CODE_SEP,
95
96
  NO_PUBLIC_PROVIDER,
96
97
  NO_GENERIC,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/configuration",
3
- "version": "4.4.2",
3
+ "version": "4.4.6",
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.0",
41
- "eslint": "8.4.1",
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.3",
43
+ "eslint-plugin-import": "2.25.4",
44
44
  "eslint-plugin-jsx-a11y": "6.5.1",
45
- "eslint-plugin-react": "7.27.1",
45
+ "eslint-plugin-react": "7.28.0",
46
46
  "eslint-plugin-react-hooks": "4.3.0",
47
- "fancy-log": "1.3.3",
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",