@mimik/configuration 4.4.2 → 4.4.3

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.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/index.js +19 -6
  3. 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 insrance properties | 169.254.169.254
52
+ | AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
53
+ | DISABLE_MST | to setup configuration without mST and oauth token setup | no | yes/no
53
54
 
54
55
  The following environement variables are being used for the configuration:
55
56
 
package/index.js CHANGED
@@ -86,9 +86,10 @@ const {
86
86
  DEFAULT_INTERCEPT_ERROR,
87
87
  } = require('./lib/common');
88
88
 
89
- const correlationIdStart = getCorrelationId('config-start');
90
89
  let display = true;
91
90
  const locParams = [NO_PUBLIC_PROVIDER, ENV_VARIABLE];
91
+ const correlationIdStart = getCorrelationId('config-start');
92
+ const isMSTDisabled = process.env.DISABLE_MST === 'yes';
92
93
 
93
94
  const setupRedis = () => {
94
95
  const domain = process.env.CACHE_IP || DEFAULT_CACHE_IP;
@@ -133,6 +134,7 @@ const setupRedis = () => {
133
134
  idTTL: parseInt(process.env.CACHE_API_ID_TTL, 10) || DEFAULT_CACHE_API_ID_TTL,
134
135
  optionTTL: parseInt(process.env.CACHE_API_OPTION_TTL, 10) || DEFAULT_CACHE_API_OPTION_TTL,
135
136
  },
137
+ isMSTDisabled,
136
138
  };
137
139
  };
138
140
 
@@ -368,7 +370,7 @@ const configuration = {
368
370
  admin: {
369
371
  externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
370
372
  },
371
- server: {
373
+ server: isMSTDisabled ? {} : {
372
374
  id: process.env.OAUTH_CLIENT_ID,
373
375
  secret: process.env.OAUTH_CLIENT_SECRET,
374
376
  accessKey: process.env.OAUTH_CLIENT_ACCESS_KEY,
@@ -394,7 +396,7 @@ const configuration = {
394
396
  topic: {
395
397
  set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
396
398
  },
397
- dependencies: { // everyserver will resport to mIT
399
+ dependencies: isMSTDisabled ? {} : { // everyserver will resport to mIT unless mST setup is disabled
398
400
  mIT: {
399
401
  url: process.env.MIT_URL,
400
402
  audience: process.env.MIT_AUDIENCE,
@@ -436,7 +438,8 @@ configuration.locationProvider = setupLocationProvider();
436
438
  * | SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
437
439
  * | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
438
440
  * | 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
441
+ * | AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
442
+ * | DISABLE_MST | to setup configuration without mST and oauth token setup | no | yes/no
440
443
  *
441
444
  * The following environement variables are being used for the configuration:
442
445
  *
@@ -598,6 +601,7 @@ const setConfig = (pack, options) => {
598
601
  process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
599
602
  }
600
603
 
604
+ // eslint-disable-next-line max-len
601
605
  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
606
 
603
607
  configuration.serverSettings.name = process.env.SERVER_NAME;
@@ -609,9 +613,10 @@ const setConfig = (pack, options) => {
609
613
  // default for every server for cluster management
610
614
  configuration.dependencies[configuration.serverSettings.type] = {
611
615
  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
616
  };
614
617
 
618
+ if (!isMSTDisabled) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
619
+
615
620
  if (options.database) {
616
621
  if (options.database.type === 'mongodb') {
617
622
  configuration.mongoSettings = setupMongo(options.database);
@@ -645,7 +650,15 @@ const setConfig = (pack, options) => {
645
650
  }
646
651
  if (options.dependencies) {
647
652
  Object.keys(options.dependencies).forEach((dependency) => {
648
- configuration.dependencies[dependency] = options.dependencies[dependency];
653
+ if (!isMSTDisabled) {
654
+ configuration.dependencies[dependency] = options.dependencies[dependency].apiKey;
655
+ }
656
+ else if (options.dependencies[dependency].apiKey) {
657
+ configuration.dependencies[dependency] = {
658
+ url: options.dependencies[dependency].url,
659
+ apiKey: options.dependencies[dependency].apiKey,
660
+ };
661
+ }
649
662
  });
650
663
  }
651
664
  if (options.custom) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/configuration",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
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.6.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",