@mimik/configuration 4.4.0 → 4.4.4

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 -9
  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
+ | 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
 
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 isMSTSet = process.env.MST_SET !== 'off';
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
+ isMSTSet,
136
138
  };
137
139
  };
138
140
 
@@ -212,9 +214,6 @@ const setupMongo = (dbOpts) => {
212
214
  table: dbOpts.table,
213
215
  url,
214
216
  options: {
215
- useNewUrlParser: true,
216
- useUnifiedTopology: true,
217
- useCreateIndex: true,
218
217
  family: parseInt(process.env.MONGO_FAMILY, 10) || DEFAULT_MONGO_FAMILY,
219
218
  keepAlive: process.env.MONGO_KEEP_ALIVE || DEFAULT_MONGO_KEEP_ALIVE,
220
219
  keepAliveInitialDelay: parseInt(process.env.MONGO_KEEP_ALIVE_INITIAL_DELAY, 10) || DEFAULT_MONGO_KEEP_ALIVE_INITIAL_DELAY,
@@ -371,7 +370,7 @@ const configuration = {
371
370
  admin: {
372
371
  externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
373
372
  },
374
- server: {
373
+ server: !isMSTSet ? {} : {
375
374
  id: process.env.OAUTH_CLIENT_ID,
376
375
  secret: process.env.OAUTH_CLIENT_SECRET,
377
376
  accessKey: process.env.OAUTH_CLIENT_ACCESS_KEY,
@@ -397,7 +396,7 @@ const configuration = {
397
396
  topic: {
398
397
  set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
399
398
  },
400
- dependencies: { // everyserver will resport to mIT
399
+ dependencies: !isMSTSet ? {} : { // every server will report to mIT unless mST setup is disabled
401
400
  mIT: {
402
401
  url: process.env.MIT_URL,
403
402
  audience: process.env.MIT_AUDIENCE,
@@ -439,7 +438,8 @@ configuration.locationProvider = setupLocationProvider();
439
438
  * | SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
440
439
  * | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
441
440
  * | LOG_LEVEL | log level for console output | debug | logInfo.logLevel
442
- * | 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
+ * | MST_SET | to setup configuration without mST and oauth token setup | on | on/off
443
443
  *
444
444
  * The following environement variables are being used for the configuration:
445
445
  *
@@ -601,6 +601,7 @@ const setConfig = (pack, options) => {
601
601
  process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
602
602
  }
603
603
 
604
+ // eslint-disable-next-line max-len
604
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}`;
605
606
 
606
607
  configuration.serverSettings.name = process.env.SERVER_NAME;
@@ -612,9 +613,10 @@ const setConfig = (pack, options) => {
612
613
  // default for every server for cluster management
613
614
  configuration.dependencies[configuration.serverSettings.type] = {
614
615
  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
616
  };
617
617
 
618
+ if (isMSTSet) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
619
+
618
620
  if (options.database) {
619
621
  if (options.database.type === 'mongodb') {
620
622
  configuration.mongoSettings = setupMongo(options.database);
@@ -648,7 +650,15 @@ const setConfig = (pack, options) => {
648
650
  }
649
651
  if (options.dependencies) {
650
652
  Object.keys(options.dependencies).forEach((dependency) => {
651
- configuration.dependencies[dependency] = options.dependencies[dependency];
653
+ if (isMSTSet) {
654
+ configuration.dependencies[dependency] = options.dependencies[dependency];
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
+ }
652
662
  });
653
663
  }
654
664
  if (options.custom) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/configuration",
3
- "version": "4.4.0",
3
+ "version": "4.4.4",
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",