@mimik/configuration 4.4.6 → 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.
Files changed (2) hide show
  1. package/index.js +13 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -135,7 +135,6 @@ const setupRedis = () => {
135
135
  idTTL: parseInt(process.env.CACHE_API_ID_TTL, 10) || DEFAULT_CACHE_API_ID_TTL,
136
136
  optionTTL: parseInt(process.env.CACHE_API_OPTION_TTL, 10) || DEFAULT_CACHE_API_OPTION_TTL,
137
137
  },
138
- isMSTSet,
139
138
  };
140
139
  };
141
140
 
@@ -304,22 +303,25 @@ const setupEncryption = (encryptionOpts) => {
304
303
  };
305
304
 
306
305
  const checkConfig = (config) => {
307
- const errs = [];
306
+ const errors = [];
308
307
 
309
308
  function traverseNodeSync(node, path) {
310
309
  Object.keys(node).forEach((prop) => {
311
310
  if (typeof node[prop] === 'object' && node[prop]) {
312
311
  traverseNodeSync(node[prop], `${path}.${prop}`);
313
312
  }
314
- else if (_.isUndefined(node[prop])) errs.push(`${path}.${prop}`);
313
+ else if (_.isUndefined(node[prop])) errors.push({ reason: 'missing', value: `${path}.${prop}` });
315
314
  });
316
315
  }
317
316
 
318
317
  traverseNodeSync(config, 'configuration');
319
- if (errs.length > 0) {
320
- const error = new Error('Missing values');
318
+ // dependency errors
319
+ if (isMSTSet && config.security.apiKeys.length === 0) errors.push({ reason: 'invalid', value: 'config.security.apiKeys', cause: 'isMSTSet' });
320
+
321
+ if (errors.length > 0) {
322
+ const error = new Error('Errors in configuration');
321
323
 
322
- logger.error(error, { values: errs }, correlationIdStart);
324
+ logger.error(error, { errors }, correlationIdStart);
323
325
  throw error;
324
326
  }
325
327
  };
@@ -372,7 +374,7 @@ const configuration = {
372
374
  admin: {
373
375
  externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
374
376
  },
375
- server: !isMSTSet ? {} : {
377
+ server: {
376
378
  id: process.env.OAUTH_CLIENT_ID,
377
379
  secret: process.env.OAUTH_CLIENT_SECRET,
378
380
  accessKey: process.env.OAUTH_CLIENT_ACCESS_KEY,
@@ -398,7 +400,7 @@ const configuration = {
398
400
  topic: {
399
401
  set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
400
402
  },
401
- dependencies: !isMSTSet ? {} : { // every server will report to mIT unless mST setup is disabled
403
+ dependencies: {
402
404
  mIT: {
403
405
  url: process.env.MIT_URL,
404
406
  audience: process.env.MIT_AUDIENCE,
@@ -410,9 +412,12 @@ const configuration = {
410
412
  },
411
413
  };
412
414
 
415
+ // cross dependencies
413
416
  if (!isMSTSet) {
414
417
  configuration.registration.set = SET_OFF;
415
418
  configuration.cluster.management = SET_OFF;
419
+ configuration.security.server = {};
420
+ configuration.dependencies = {};
416
421
  }
417
422
  if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
418
423
  if (process.env.SWAGGER_API_KEY) configuration.serverSettings.apiKey = process.env.SWAGGER_API_KEY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/configuration",
3
- "version": "4.4.6",
3
+ "version": "4.4.7",
4
4
  "description": "Common configuration for mimik services",
5
5
  "main": "index.js",
6
6
  "scripts": {