@mimik/configuration 6.0.6 → 6.0.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.
package/index.js CHANGED
@@ -1,74 +1,15 @@
1
- /* eslint no-process-env: "off" */
1
+ /* eslint no-process-env: "off", no-magic-numbers: "off" */
2
2
  import {
3
3
  ALL,
4
4
  AWS_S3,
5
5
  CUSTOMER_CODE_SEP,
6
- DEFAULT_ADMIN_EXTERNAL_ID,
7
- DEFAULT_AWS_LOCAL_PROPERTIES,
8
- DEFAULT_AWS_REGION,
9
- DEFAULT_BITBUCKET_PASSWORD,
10
- DEFAULT_BITBUCKET_USERNAME,
11
- DEFAULT_CACHE_API_ID_TTL,
12
- DEFAULT_CACHE_API_OPTION_TTL,
13
- DEFAULT_CACHE_CONNECTION_TIMEOUT,
14
- DEFAULT_CACHE_IP,
15
- DEFAULT_CACHE_RECONNECTION_OFFSET,
16
- DEFAULT_CACHE_REQUEST_TTL,
17
- DEFAULT_CACHE_SET,
18
- DEFAULT_CACHE_VALIDATION_CHECK,
19
- DEFAULT_CLOUD_PROVIDER,
20
- DEFAULT_CLUSTER_MANAGEMENT,
21
- DEFAULT_CUSTOMER_CODE,
22
- DEFAULT_DATABASE_CONNECTION_TIMEOUT,
23
- DEFAULT_DATABASE_IP,
24
- DEFAULT_DATABASE_PASSWORD,
25
- DEFAULT_DATABASE_RECONNECTION_OFFSET,
26
- DEFAULT_DATABASE_USER,
27
- DEFAULT_DATABASE_VALIDATION_CHECK,
28
- DEFAULT_DYNAMODB_LOCAL_URL,
29
- DEFAULT_DYNAMO_THROUGHPUT,
30
- DEFAULT_DYNAMO_THROUGHPUT_READ,
31
- DEFAULT_DYNAMO_THROUGHPUT_WRITE,
32
- DEFAULT_ENCRYPTION_SET,
33
- DEFAULT_ENV,
34
- DEFAULT_EXIT_DELAY,
35
- DEFAULT_FILTER_FILE,
36
- DEFAULT_INTERCEPT_ERROR,
37
- DEFAULT_KMS_PROVIDER,
38
- DEFAULT_LOCATION_PROVIDER,
39
- DEFAULT_LOG_LEVEL,
40
- DEFAULT_MONGO_FAMILY,
41
- DEFAULT_MONGO_HEARTBEAT_FREQUENCY,
42
- DEFAULT_MONGO_MAX_IDLE_TIME,
43
- DEFAULT_MONGO_MAX_POOL_SIZE,
44
- DEFAULT_MONGO_MIN_POOL_SIZE,
45
- DEFAULT_MONGO_SERVER_SELECTION_TIMEOUT,
46
- DEFAULT_MONGO_SOCKET_TIMEOUT,
47
- DEFAULT_NO_STACK,
48
- DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE,
49
- DEFAULT_REDIS_RECONNECT_INTERVAL,
50
- DEFAULT_REDIS_RECONNECT_TRIES,
51
- DEFAULT_REDIS_REQUEST_MAX_MEMORY,
52
- DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY,
53
- DEFAULT_REDIS_SOCKET_KEEPALIVE,
54
- DEFAULT_REGISTRATION_AFTER_POSTOPS_SET,
55
- DEFAULT_REGISTRATION_RETRY,
56
- DEFAULT_REGISTRATION_SET,
57
- DEFAULT_REQUEST_TIMEOUT,
58
- DEFAULT_S3_AWS_MAX_EVENTS,
59
- DEFAULT_S3_AWS_MAX_SIZE,
60
- DEFAULT_S3_AWS_TIMEOUT,
61
- DEFAULT_SERVER_PUBLIC_DOMAIN_NAME,
62
- DEFAULT_SERVER_PUBLIC_PROTOCOL,
63
- DEFAULT_SERVER_SECURITY_SET,
64
- DEFAULT_SWAGGER_DIR,
65
- DEFAULT_SWAGGER_FILE_PROVIDER,
66
- DEFAULT_TOPIC_SET,
67
- DEFAULT_USER_DEFINITIONS_FILE,
6
+ DEBUG,
68
7
  ENV_VARIABLE,
8
+ LOCAL,
69
9
  MONGO_BASE_URL,
70
10
  MONGO_BASE_URL_SRV,
71
11
  NO,
12
+ NOT_SET,
72
13
  NO_GENERIC,
73
14
  NO_PUBLIC_PROVIDER,
74
15
  PRODUCTIONS,
@@ -81,20 +22,13 @@ import {
81
22
  SWAGGER_SEP,
82
23
  YES,
83
24
  } from './lib/common.js';
84
- import fs from 'fs';
25
+ import crypto from 'node:crypto';
26
+ import fs from 'node:fs';
85
27
  import { getCorrelationId } from '@mimik/request-helper';
86
- import includes from 'lodash.includes';
87
28
  import ip from 'ip';
88
- import isNaN from 'lodash.isnan';
89
- import isNil from 'lodash.isnil';
90
- import isString from 'lodash.isstring';
91
- import isUndefined from 'lodash.isundefined';
92
29
  import logger from '@mimik/sumologic-winston-logger';
93
- import process from 'process';
94
- import querystring from 'querystring';
95
- import split from 'lodash.split';
30
+ import process from 'node:process';
96
31
  import { userDefinitions } from '@mimik/user-filters';
97
- import { v4 as uuidv4 } from 'uuid';
98
32
 
99
33
  const DECIMAL = 10;
100
34
  const AT_LEAST_ONE = 0;
@@ -116,11 +50,11 @@ const correlationIdStart = getCorrelationId('config-start');
116
50
  const isMSTSet = process.env.MST_SET !== SET_OFF;
117
51
 
118
52
  const setupRedis = () => {
119
- const domain = process.env.CACHE_IP || DEFAULT_CACHE_IP;
53
+ const domain = process.env.CACHE_IP || 'localhost:6379';
120
54
  const username = process.env.CACHE_USER;
121
55
  const password = process.env.CACHE_PASSWORD;
122
- const reconnectTries = parseInt(process.env.REDIS_RECONNECT_TRIES, DECIMAL) || DEFAULT_REDIS_RECONNECT_TRIES;
123
- const reconnectInterval = parseInt(process.env.REDIS_RECONNECT_INTERVAL, DECIMAL) || DEFAULT_REDIS_RECONNECT_INTERVAL;
56
+ const reconnectTries = parseInt(process.env.REDIS_RECONNECT_TRIES, DECIMAL) || 100;
57
+ const reconnectInterval = parseInt(process.env.REDIS_RECONNECT_INTERVAL, DECIMAL) || 500;
124
58
  let url = REDIS_BASE_URL;
125
59
  let noAuthUrl = url;
126
60
  if (username && password) url += `${username}:${password}@`;
@@ -135,16 +69,16 @@ const setupRedis = () => {
135
69
 
136
70
  return {
137
71
  api: {
138
- idTTL: parseInt(process.env.CACHE_API_ID_TTL, DECIMAL) || DEFAULT_CACHE_API_ID_TTL,
139
- optionTTL: parseInt(process.env.CACHE_API_OPTION_TTL, DECIMAL) || DEFAULT_CACHE_API_OPTION_TTL,
72
+ idTTL: parseInt(process.env.CACHE_API_ID_TTL, DECIMAL) || 20,
73
+ optionTTL: parseInt(process.env.CACHE_API_OPTION_TTL, DECIMAL) || 5,
140
74
  },
141
75
  cluster: clusterConfig,
142
- connectTimeout: parseInt(process.env.CACHE_CONNECTION_TIMEOUT, DECIMAL) || DEFAULT_CACHE_CONNECTION_TIMEOUT,
76
+ connectTimeout: parseInt(process.env.CACHE_CONNECTION_TIMEOUT, DECIMAL) || 30,
143
77
  domain,
144
78
  noAuthUrl,
145
79
  options: {
146
80
  socket: {
147
- keepAlive: process.env.REDIS_SOCKET_KEEPALIVE || DEFAULT_REDIS_SOCKET_KEEPALIVE,
81
+ keepAlive: parseInt(process.env.REDIS_SOCKET_KEEPALIVE, DECIMAL) || 5000,
148
82
  reconnectStrategy: function reconnectStrategy(opts) {
149
83
  if (opts.timesConnected > AT_LEAST_ONE && opts.attempt < reconnectTries) {
150
84
  return reconnectInterval;
@@ -158,15 +92,15 @@ const setupRedis = () => {
158
92
  }
159
93
  return undefined;
160
94
  },
161
- disableOfflineQueue: (process.env.REDIS_DISABLE_OFFLINE_QUEUE === YES) || DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE,
95
+ disableOfflineQueue: (process.env.REDIS_DISABLE_OFFLINE_QUEUE === YES),
162
96
  },
163
- maxMemory: process.env.REDIS_REQUEST_MAX_MEMORY || DEFAULT_REDIS_REQUEST_MAX_MEMORY,
164
- maxMemoryPolicy: process.env.REDIS_REQUEST_MAX_MEMORY_POLICY || DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY,
97
+ maxMemory: process.env.REDIS_REQUEST_MAX_MEMORY || '10mb',
98
+ maxMemoryPolicy: process.env.REDIS_REQUEST_MAX_MEMORY_POLICY || 'allkeys-lru',
165
99
  },
166
100
  password,
167
- reconnectOffset: parseInt(process.env.CACHE_RECONNECTION_OFFSET, DECIMAL) || DEFAULT_CACHE_RECONNECTION_OFFSET,
101
+ reconnectOffset: parseInt(process.env.CACHE_RECONNECTION_OFFSET, DECIMAL) || 5,
168
102
  request: {
169
- TTL: parseInt(process.env.CACHE_REQUEST_TTL, DECIMAL) || DEFAULT_CACHE_REQUEST_TTL,
103
+ TTL: parseInt(process.env.CACHE_REQUEST_TTL, DECIMAL) || 10,
170
104
  },
171
105
  retryStrategyOptions: {
172
106
  reconnectTries,
@@ -174,38 +108,38 @@ const setupRedis = () => {
174
108
  },
175
109
  url,
176
110
  username,
177
- validationCheck: parseInt(process.env.CACHE_VALIDATION_CHECK, DECIMAL) || DEFAULT_CACHE_VALIDATION_CHECK,
111
+ validationCheck: parseInt(process.env.CACHE_VALIDATION_CHECK, DECIMAL) || 1000,
178
112
  };
179
113
  };
180
114
 
181
115
  const setupDynamo = (dbOpts) => {
182
116
  const dbConfig = {
183
- connectTimeout: parseInt(process.env.DATABASE_CONNECTION_TIMEOUT, DECIMAL) || DEFAULT_DATABASE_CONNECTION_TIMEOUT,
184
- validationCheck: parseInt(process.env.DATABASE_VALIDATION_CHECK, DECIMAL) || DEFAULT_DATABASE_VALIDATION_CHECK,
185
- reconnectOffset: parseInt(process.env.DATABASE_RECONNECTION_OFFSET, DECIMAL) || DEFAULT_DATABASE_RECONNECTION_OFFSET,
186
- region: process.env.DYNAMODB_AWS_REGION || DEFAULT_AWS_REGION,
187
- url: process.env.DYNAMODB_LOCAL_URL || DEFAULT_DYNAMODB_LOCAL_URL,
117
+ connectTimeout: parseInt(process.env.DATABASE_CONNECTION_TIMEOUT, DECIMAL) || 30,
118
+ validationCheck: parseInt(process.env.DATABASE_VALIDATION_CHECK, DECIMAL) || 1000,
119
+ reconnectOffset: parseInt(process.env.DATABASE_RECONNECTION_OFFSET, DECIMAL) || 5,
120
+ region: process.env.DYNAMODB_AWS_REGION || '----noRegion----',
121
+ url: process.env.DYNAMODB_LOCAL_URL || 'http://localhost:8000',
188
122
  throughput: {
189
- read: parseInt(process.env.DYNAMO_THROUGHPUT_READ, DECIMAL) || DEFAULT_DYNAMO_THROUGHPUT_READ,
190
- write: parseInt(process.env.DYNAMO_THROUGHPUT_WRITE, DECIMAL) || DEFAULT_DYNAMO_THROUGHPUT_WRITE,
123
+ read: parseInt(process.env.DYNAMO_THROUGHPUT_READ, DECIMAL) || 1,
124
+ write: parseInt(process.env.DYNAMO_THROUGHPUT_WRITE, DECIMAL) || 1,
191
125
  },
192
126
  schemaThroughput: {
193
- read: parseInt(process.env.DYNAMO_SCHEMA_THROUGHPUT_READ, DECIMAL) || DEFAULT_DYNAMO_THROUGHPUT_READ,
194
- write: parseInt(process.env.DYNAMO_SCHEMA_THROUGHPUT_WRITE, DECIMAL) || DEFAULT_DYNAMO_THROUGHPUT_WRITE,
127
+ read: parseInt(process.env.DYNAMO_SCHEMA_THROUGHPUT_READ, DECIMAL) || 1,
128
+ write: parseInt(process.env.DYNAMO_SCHEMA_THROUGHPUT_WRITE, DECIMAL) || 1,
195
129
  },
196
130
  tableName: dbOpts.table,
197
131
  };
198
- if (!isNil(process.env.DYNAMODB_AWS_ACCESS_KEY_ID)) dbConfig.accessKeyId = process.env.DYNAMODB_AWS_ACCESS_KEY_ID;
199
- if (!isNil(process.env.DYNAMODB_AWS_SECRET_ACCESS_KEY)) dbConfig.secretAccessKey = process.env.DYNAMODB_AWS_SECRET_ACCESS_KEY;
132
+ if (process.env.DYNAMODB_AWS_ACCESS_KEY_ID !== undefined) dbConfig.accessKeyId = process.env.DYNAMODB_AWS_ACCESS_KEY_ID;
133
+ if (process.env.DYNAMODB_AWS_SECRET_ACCESS_KEY !== undefined) dbConfig.secretAccessKey = process.env.DYNAMODB_AWS_SECRET_ACCESS_KEY;
200
134
 
201
135
  if (process.env.DYNAMO_SCHEMA_THROUGHPUT === 'ON_DEMAND') {
202
136
  dbConfig.schemaThroughput = process.env.DYNAMO_SCHEMA_THROUGHPUT;
203
137
  delete dbConfig.throughput;
204
138
  }
205
- else if (!isNil(process.env.DYNAMO_SCHEMA_THROUGHPUT)) {
139
+ else if (process.env.DYNAMO_SCHEMA_THROUGHPUT !== undefined) {
206
140
  const throughput = parseInt(process.env.DYNAMO_SCHEMA_THROUGHPUT, DECIMAL);
207
141
 
208
- if (isNil(throughput) || isNaN(throughput)) dbConfig.schemaThroughput = DEFAULT_DYNAMO_THROUGHPUT;
142
+ if (Number.isNaN(throughput)) dbConfig.schemaThroughput = 1;
209
143
  else dbConfig.schemaThroughput = throughput;
210
144
  }
211
145
  return dbConfig;
@@ -215,9 +149,9 @@ const setupMongo = (dbOpts) => {
215
149
  const processStringOptions = () => {
216
150
  // default string variables
217
151
  const stringOptions = {
218
- maxPoolSize: parseInt(process.env.MONGO_MAX_POOL_SIZE, DECIMAL) || DEFAULT_MONGO_MAX_POOL_SIZE,
219
- minPoolSize: parseInt(process.env.MONGO_MIN_POOL_SIZE, DECIMAL) || DEFAULT_MONGO_MIN_POOL_SIZE,
220
- maxIdleTimeMS: parseInt(process.env.MONGO_MAX_IDLE_TIME, DECIMAL) || DEFAULT_MONGO_MAX_IDLE_TIME,
152
+ maxPoolSize: parseInt(process.env.MONGO_MAX_POOL_SIZE, DECIMAL) || 10,
153
+ minPoolSize: parseInt(process.env.MONGO_MIN_POOL_SIZE, DECIMAL) || 0,
154
+ maxIdleTimeMS: parseInt(process.env.MONGO_MAX_IDLE_TIME, DECIMAL) || 30000,
221
155
  };
222
156
  // string variables without default
223
157
  if (process.env.MONGO_SSL === YES) stringOptions.ssl = true; // default value of mongo driver is false
@@ -231,15 +165,15 @@ const setupMongo = (dbOpts) => {
231
165
  if (process.env.MONGO_RETRY_WRITES) stringOptions.retryWrites = process.env.MONGO_RETRY_WRITES;
232
166
  if (process.env.MONGO_WAIT_QUEUE_MULTIPLE) stringOptions.waitQueueMultiple = parseInt(process.env.MONGO_WAIT_QUEUE_MULTIPLE, DECIMAL);
233
167
  if (process.env.MONGO_WAIT_QUEUE_TIMEOUT) stringOptions.waitQueueTimeoutMS = parseInt(process.env.MONGO_WAIT_QUEUE_TIMEOUT, DECIMAL); // in ms
234
- return stringOptions ? querystring.stringify(stringOptions) : null;
168
+ return new URLSearchParams(stringOptions).toString();
235
169
  };
236
170
  const database = process.env.DATABASE_NAME;
237
171
  if (!database) {
238
172
  return undefined;
239
173
  }
240
- const domain = process.env.DATABASE_IP || DEFAULT_DATABASE_IP;
241
- const user = process.env.DATABASE_USER || DEFAULT_DATABASE_USER;
242
- const password = process.env.DATABASE_PASSWORD || DEFAULT_DATABASE_PASSWORD;
174
+ const domain = process.env.DATABASE_IP || 'localhost';
175
+ const user = process.env.DATABASE_USER || null;
176
+ const password = process.env.DATABASE_PASSWORD || null;
243
177
  const qs = processStringOptions();
244
178
  let url = (process.env.MONGO_USE_SRV === YES) ? MONGO_BASE_URL_SRV : MONGO_BASE_URL;
245
179
  let noAuthUrl = url;
@@ -252,24 +186,24 @@ const setupMongo = (dbOpts) => {
252
186
  noAuthUrl = `${noAuthUrl}?${qs}`;
253
187
  }
254
188
  return {
255
- connectTimeout: parseInt(process.env.DATABASE_CONNECTION_TIMEOUT, DECIMAL) || DEFAULT_DATABASE_CONNECTION_TIMEOUT,
189
+ connectTimeout: parseInt(process.env.DATABASE_CONNECTION_TIMEOUT, DECIMAL) || 30,
256
190
  database,
257
191
  domain,
258
192
  noAuthUrl,
259
193
  options: {
260
- family: parseInt(process.env.MONGO_FAMILY, DECIMAL) || DEFAULT_MONGO_FAMILY,
261
- socketTimeoutMS: parseInt(process.env.MONGO_SOCKET_TIMEOUT, DECIMAL) || DEFAULT_MONGO_SOCKET_TIMEOUT,
262
- serverSelectionTimeoutMS: parseInt(process.env.MONGO_SERVER_SELECTION_TIMEOUT, DECIMAL) || DEFAULT_MONGO_SERVER_SELECTION_TIMEOUT,
263
- heartbeatFrequencyMS: parseInt(process.env.MONGO_HEARTBEAT_FREQUENCY, DECIMAL) || DEFAULT_MONGO_HEARTBEAT_FREQUENCY,
194
+ family: parseInt(process.env.MONGO_FAMILY, DECIMAL) || 4,
195
+ socketTimeoutMS: parseInt(process.env.MONGO_SOCKET_TIMEOUT, DECIMAL) || 20000,
196
+ serverSelectionTimeoutMS: parseInt(process.env.MONGO_SERVER_SELECTION_TIMEOUT, DECIMAL) || 30000,
197
+ heartbeatFrequencyMS: parseInt(process.env.MONGO_HEARTBEAT_FREQUENCY, DECIMAL) || 10000,
264
198
  },
265
199
  password,
266
- reconnectOffset: parseInt(process.env.DATABASE_RECONNECTION_OFFSET, DECIMAL) || DEFAULT_DATABASE_RECONNECTION_OFFSET,
200
+ reconnectOffset: parseInt(process.env.DATABASE_RECONNECTION_OFFSET, DECIMAL) || 5,
267
201
  replicat: Boolean(process.env.MONGO_REPLICAT_SET),
268
202
  stringOptions: qs,
269
203
  table: dbOpts.table,
270
204
  url,
271
205
  user,
272
- validationCheck: parseInt(process.env.DATABASE_VALIDATION_CHECK, DECIMAL) || DEFAULT_DATABASE_VALIDATION_CHECK,
206
+ validationCheck: parseInt(process.env.DATABASE_VALIDATION_CHECK, DECIMAL) || 1000,
273
207
  };
274
208
  };
275
209
 
@@ -277,7 +211,7 @@ const setupLocationProvider = () => {
277
211
  const url = process.env.LOCATION_PROVIDER;
278
212
 
279
213
  if (!url) return NO_PUBLIC_PROVIDER;
280
- if (includes(locParams, url)) return url;
214
+ if (locParams.includes(url)) return url;
281
215
  const locationProvider = { url };
282
216
 
283
217
  if (process.env.LOCATION_PROVIDER_KEY) locationProvider.key = process.env.LOCATION_PROVIDER_KEY;
@@ -288,12 +222,12 @@ const setupLog = () => {
288
222
  const logInfo = {
289
223
  mode: process.env.LOG_MODE || SUMOLOGIC,
290
224
  level: {
291
- console: process.env.CONSOLE_LEVEL || DEFAULT_LOG_LEVEL,
292
- log: process.env.LOG_LEVEL || DEFAULT_LOG_LEVEL,
225
+ console: process.env.CONSOLE_LEVEL || DEBUG,
226
+ log: process.env.LOG_LEVEL || DEBUG,
293
227
  },
294
- filterFile: process.env.FILTER_FILE || DEFAULT_FILTER_FILE,
295
- exitDelay: parseInt(process.env.EXIT_DELAY, DECIMAL) || DEFAULT_EXIT_DELAY,
296
- noStack: process.env.NO_STACK || DEFAULT_NO_STACK,
228
+ filterFile: process.env.FILTER_FILE || NOT_SET,
229
+ exitDelay: parseInt(process.env.EXIT_DELAY, DECIMAL) || 2000,
230
+ noStack: process.env.NO_STACK || YES,
297
231
  };
298
232
 
299
233
  if (logInfo.mode === SUMOLOGIC || logInfo.mode === ALL) {
@@ -305,28 +239,28 @@ const setupLog = () => {
305
239
  if (logInfo.mode === AWS_S3 || logInfo.mode === ALL) {
306
240
  logInfo[AWS_S3] = {
307
241
  region: process.env.S3_AWS_REGION,
308
- bucketname: process.env.S3_AWS_BUCKET_NAME,
309
- timeout: parseInt(process.env.S3_AWS_TIMEOUT, DECIMAL) || DEFAULT_S3_AWS_TIMEOUT,
310
- maxSize: parseInt(process.env.S3_AWS_MAX_SIZE, DECIMAL) || DEFAULT_S3_AWS_MAX_SIZE,
311
- maxEvents: parseInt(process.env.S3_AWS_MAX_EVENTS, DECIMAL) || DEFAULT_S3_AWS_MAX_EVENTS,
242
+ bucketName: process.env.S3_AWS_BUCKET_NAME,
243
+ timeout: parseInt(process.env.S3_AWS_TIMEOUT, DECIMAL) || 5,
244
+ maxSize: parseInt(process.env.S3_AWS_MAX_SIZE, DECIMAL) || 5,
245
+ maxEvents: parseInt(process.env.S3_AWS_MAX_EVENTS, DECIMAL) || 1000,
312
246
  };
313
- if (!isNil(process.env.S3_AWS_ACCESS_KEY_ID)) logInfo[AWS_S3].accessKeyId = process.env.S3_AWS_ACCESS_KEY_ID;
314
- if (!isNil(process.env.S3_AWS_SECRET_ACCESS_KEY)) logInfo[AWS_S3].secretAccessKey = process.env.S3_AWS_SECRET_ACCESS_KEY;
247
+ if (process.env.S3_AWS_ACCESS_KEY_ID !== undefined) logInfo[AWS_S3].accessKeyId = process.env.S3_AWS_ACCESS_KEY_ID;
248
+ if (process.env.S3_AWS_SECRET_ACCESS_KEY !== undefined) logInfo[AWS_S3].secretAccessKey = process.env.S3_AWS_SECRET_ACCESS_KEY;
315
249
  }
316
250
  return logInfo;
317
251
  };
318
252
 
319
253
  const setupTopic = (topicOpts) => {
320
254
  const topicConfig = {
321
- region: process.env.SNS_AWS_REGION || DEFAULT_AWS_REGION,
255
+ region: process.env.SNS_AWS_REGION || '----noRegion----',
322
256
  name: topicOpts.name,
323
257
  isFifoTopic: process.env.SET_SNS_TOPIC_FIFO === YES,
324
258
  contentBasedDeduplication: false,
325
259
  };
326
260
 
327
261
  if (topicConfig.isFifoTopic) topicConfig.contentBasedDeduplication = process.env.SET_SNS_CONTENT_DEDUPLICATION === YES;
328
- if (!isNil(process.env.SNS_AWS_ACCESS_KEY_ID)) topicConfig.accessKeyId = process.env.SNS_AWS_ACCESS_KEY_ID;
329
- if (!isNil(process.env.SNS_AWS_SECRET_ACCESS_KEY)) topicConfig.secretAccessKey = process.env.SNS_AWS_SECRET_ACCESS_KEY;
262
+ if (process.env.SNS_AWS_ACCESS_KEY_ID !== undefined) topicConfig.accessKeyId = process.env.SNS_AWS_ACCESS_KEY_ID;
263
+ if (process.env.SNS_AWS_SECRET_ACCESS_KEY !== undefined) topicConfig.secretAccessKey = process.env.SNS_AWS_SECRET_ACCESS_KEY;
330
264
 
331
265
  return topicConfig;
332
266
  };
@@ -336,16 +270,16 @@ const setupEncryption = (encryptionOpts) => {
336
270
  set: encryptionOpts.set,
337
271
  database: process.env.ENCRYPTION_DATABASE,
338
272
  keyVaultTable: process.env.KEY_VAULT_TABLE,
339
- kmsProvider: process.env.KMS_PROVIDER || DEFAULT_KMS_PROVIDER,
273
+ kmsProvider: process.env.KMS_PROVIDER || LOCAL,
340
274
  };
341
275
 
342
276
  if (encryptionConfig.kmsProvider.toLowerCase() === 'aws') {
343
277
  encryptionConfig.aws = {};
344
- encryptionConfig.region = process.env.MASTER_KEY_AWS_REGION || DEFAULT_AWS_REGION;
278
+ encryptionConfig.region = process.env.MASTER_KEY_AWS_REGION || '----noRegion----';
345
279
  encryptionConfig.masterKeyARN = process.env.MASTER_KEY_ARN;
346
280
 
347
- if (!isNil(process.env.ENCRYPTION_ACCESS_KEY_ID)) encryptionConfig.aws.accessKeyId = process.env.ENCRYPTION_ACCESS_KEY_ID;
348
- if (!isNil(process.env.ENCRYPTION_SECRET_ACCESS_KEY)) encryptionConfig.aws.secretAccessKey = process.env.ENCRYPTION_SECRET_ACCESS_KEY;
281
+ if (process.env.ENCRYPTION_ACCESS_KEY_ID !== undefined) encryptionConfig.aws.accessKeyId = process.env.ENCRYPTION_ACCESS_KEY_ID;
282
+ if (process.env.ENCRYPTION_SECRET_ACCESS_KEY !== undefined) encryptionConfig.aws.secretAccessKey = process.env.ENCRYPTION_SECRET_ACCESS_KEY;
349
283
  }
350
284
  else encryptionConfig.localMasterKey = process.env.LOCAL_MASTER_KEY;
351
285
 
@@ -357,12 +291,12 @@ const setupEncryption = (encryptionOpts) => {
357
291
  const setupUserDefinitions = (definitions) => {
358
292
  const userDefinitionsFile = definitions.file;
359
293
  let customDefinitions = {};
360
- if (userDefinitionsFile && userDefinitionsFile !== DEFAULT_USER_DEFINITIONS_FILE) {
294
+ if (userDefinitionsFile && userDefinitionsFile !== NOT_SET) {
361
295
  try {
362
296
  customDefinitions = JSON.parse(fs.readFileSync(userDefinitionsFile).toString());
363
297
  }
364
298
  catch (err) {
365
- throw new Error(`Invalid file for user definitions: ${userDefinitionsFile}, error: ${err.message}`);
299
+ throw new Error(`Invalid file for user definitions: ${userDefinitionsFile}, error: ${err.message}`, { cause: err });
366
300
  }
367
301
  }
368
302
  return {
@@ -380,7 +314,7 @@ const checkConfig = (config) => {
380
314
  if (typeof node[prop] === 'object' && node[prop]) {
381
315
  traverseNodeSync(node[prop], `${path}.${prop}`);
382
316
  }
383
- else if (isUndefined(node[prop])) errors.push({ reason: 'missing', value: `${path}.${prop}` });
317
+ else if (node[prop] === undefined) errors.push({ reason: 'missing', value: `${path}.${prop}` });
384
318
  });
385
319
  };
386
320
 
@@ -407,27 +341,27 @@ const checkConfig = (config) => {
407
341
  *
408
342
  * | Env variable name | Description | Value | Comments |
409
343
  * | ----------------- | ----------- | ----- | -------- |
410
- * | NODE_ENV | environnment of the microservice |
344
+ * | NODE_ENV | environment of the microservice |
411
345
  */
412
346
  export const isProd = () => {
413
- if (isString(process.env.NODE_ENV)) return includes(PRODUCTIONS, process.env.NODE_ENV.toLowerCase());
347
+ if (typeof process.env.NODE_ENV === 'string') return PRODUCTIONS.includes(process.env.NODE_ENV.toLowerCase());
414
348
  return false;
415
349
  };
416
350
 
417
351
  process.env.SERVER_LOCAL_IPV4 = ip.address();
418
- process.env.AWS_LOCAL_PROPERTIES = DEFAULT_AWS_LOCAL_PROPERTIES;
419
- process.env.CONSOLE_LEVEL ||= DEFAULT_LOG_LEVEL;
420
- process.env.LOG_LEVEL ||= DEFAULT_LOG_LEVEL;
421
- process.env.SERVER_ID ||= uuidv4();
352
+ process.env.AWS_LOCAL_PROPERTIES = '169.254.169.254';
353
+ process.env.CONSOLE_LEVEL ||= DEBUG;
354
+ process.env.LOG_LEVEL ||= DEBUG;
355
+ process.env.SERVER_ID ||= crypto.randomUUID();
422
356
 
423
357
  const configuration = {
424
358
  cache: {
425
- set: process.env.CACHE_SET || DEFAULT_CACHE_SET,
359
+ set: process.env.CACHE_SET || SET_OFF,
426
360
  },
427
- cloudProvider: process.env.CLOUD_PROVIDER || DEFAULT_CLOUD_PROVIDER,
361
+ cloudProvider: process.env.CLOUD_PROVIDER || 'noCloud',
428
362
  cluster: {
429
- management: process.env.CLUSTER_MANAGEMENT || DEFAULT_CLUSTER_MANAGEMENT,
430
- timeout: parseInt(process.env.REQUEST_TIMEOUT, DECIMAL) || DEFAULT_REQUEST_TIMEOUT,
363
+ management: process.env.CLUSTER_MANAGEMENT || SET_OFF,
364
+ timeout: parseInt(process.env.REQUEST_TIMEOUT, DECIMAL) || 10000,
431
365
  },
432
366
  dependencies: {
433
367
  mIT: {
@@ -436,18 +370,18 @@ const configuration = {
436
370
  },
437
371
  },
438
372
  encryption: {
439
- set: process.env.ENCRYPTION_SET || DEFAULT_ENCRYPTION_SET,
373
+ set: process.env.ENCRYPTION_SET || SET_OFF,
440
374
  },
441
- locationProvider: process.env.LOCATION_PROVIDER || DEFAULT_LOCATION_PROVIDER,
442
- nodeEnvironment: process.env.NODE_ENV || DEFAULT_ENV,
375
+ locationProvider: process.env.LOCATION_PROVIDER || NO_PUBLIC_PROVIDER,
376
+ nodeEnvironment: process.env.NODE_ENV || LOCAL,
443
377
  registration: {
444
- set: process.env.REGISTRATION_SET || DEFAULT_REGISTRATION_SET,
445
- retry: parseInt(process.env.REGISTRATION_RETRY, DECIMAL) || DEFAULT_REGISTRATION_RETRY,
446
- afterPostOpsSet: process.env.REGISTRATION_AFTER_POSTOPS_SET || DEFAULT_REGISTRATION_AFTER_POSTOPS_SET,
378
+ set: process.env.REGISTRATION_SET || SET_ON,
379
+ retry: parseInt(process.env.REGISTRATION_RETRY, DECIMAL) || 3000,
380
+ afterPostOpsSet: process.env.REGISTRATION_AFTER_POSTOPS_SET || SET_OFF,
447
381
  },
448
382
  security: {
449
383
  admin: {
450
- externalId: process.env.ADMIN_EXTERNAL_ID || DEFAULT_ADMIN_EXTERNAL_ID,
384
+ externalId: process.env.ADMIN_EXTERNAL_ID || 'admin',
451
385
  },
452
386
  server: {
453
387
  id: process.env.OAUTH_CLIENT_ID,
@@ -460,29 +394,29 @@ const configuration = {
460
394
  key: process.env.OAUTH_GENERIC_KEY || NO_GENERIC,
461
395
  audience: process.env.OAUTH_GENERIC_AUDIENCE || NO_GENERIC,
462
396
  },
463
- apiKeys: process.env.API_KEYS ? split(process.env.API_KEYS.trim(), /\s*,\s*/u) : [],
397
+ apiKeys: process.env.API_KEYS ? process.env.API_KEYS.trim().split(/\s*,\s*/u) : [],
464
398
  },
465
399
  serverSettings: {
466
400
  id: process.env.SERVER_ID,
467
- customerCode: process.env.CUSTOMER_CODE || DEFAULT_CUSTOMER_CODE,
401
+ customerCode: process.env.CUSTOMER_CODE || '',
468
402
  customerCodeSep: process.env.CUSTOMER_CODE ? CUSTOMER_CODE_SEP : '',
469
- securitySet: process.env.SERVER_SECURITY_SET || DEFAULT_SERVER_SECURITY_SET,
403
+ securitySet: process.env.SERVER_SECURITY_SET || SET_ON,
470
404
  isMSTSet,
471
405
  port: parseInt(process.env.SERVER_PORT, DECIMAL),
472
- interceptError: process.env.INTERCEPT_ERROR || DEFAULT_INTERCEPT_ERROR,
406
+ interceptError: process.env.INTERCEPT_ERROR || SET_ON,
473
407
  ip: {
474
408
  local: process.env.SERVER_LOCAL_IPV4,
475
409
  },
476
410
  public: {
477
- protocol: process.env.SERVER_PUBLIC_PROTOCOL || DEFAULT_SERVER_PUBLIC_PROTOCOL,
478
- domainName: process.env.SERVER_PUBLIC_DOMAIN_NAME || DEFAULT_SERVER_PUBLIC_DOMAIN_NAME,
411
+ protocol: process.env.SERVER_PUBLIC_PROTOCOL || 'http:',
412
+ domainName: process.env.SERVER_PUBLIC_DOMAIN_NAME || null,
479
413
  },
480
414
  },
481
415
  topic: {
482
- set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
416
+ set: process.env.TOPIC_SET || SET_OFF,
483
417
  },
484
418
  userDefinitions: {
485
- file: process.env.USER_DEFINITIONS_FILE || DEFAULT_USER_DEFINITIONS_FILE,
419
+ file: process.env.USER_DEFINITIONS_FILE || NOT_SET,
486
420
  },
487
421
  };
488
422
 
@@ -496,8 +430,8 @@ if (!isMSTSet) {
496
430
  if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
497
431
  if (process.env.BITBUCKET_USERNAME || process.env.BITBUCKET_PASSWORD) {
498
432
  configuration.serverSettings.apiBasicAuth = {
499
- username: process.env.BITBUCKET_USERNAME || DEFAULT_BITBUCKET_USERNAME,
500
- password: process.env.BITBUCKET_PASSWORD || DEFAULT_BITBUCKET_PASSWORD,
433
+ username: process.env.BITBUCKET_USERNAME || ' ',
434
+ password: process.env.BITBUCKET_PASSWORD || ' ',
501
435
  };
502
436
  }
503
437
  if (process.env.SWAGGERHUB_API_KEY) {
@@ -513,10 +447,10 @@ configuration.locationProvider = setupLocationProvider();
513
447
  *
514
448
  * @function setConfig
515
449
  * @category sync
516
- * @param {string} pack - `Package.json` object to use for the configuration.
450
+ * @param {object} pack - `Package.json` object to use for the configuration.
517
451
  * @param {object} options - Options to add to the config.
518
452
  * @return {object} The configuration.
519
- * @exception Will trow an error if a mandatory value is missing.
453
+ * @exception Will throw an error if a mandatory value is missing.
520
454
  *
521
455
  * The following environment variables are being setup:
522
456
  *
@@ -535,7 +469,7 @@ configuration.locationProvider = setupLocationProvider();
535
469
  * | AWS_LOCAL_PROPERTIES | internal ip address to access aws instance properties | 169.254.169.254
536
470
  * | MST_SET | to setup configuration without mST and oauth token setup | on | on/off
537
471
  *
538
- * The following environement variables are being used for the configuration:
472
+ * The following environment variables are being used for the configuration:
539
473
  *
540
474
  * | Env variable name | Description | Default | Config property | Comments |
541
475
  * | ----------------- | ----------- | ------- | ----------------| -------- |
@@ -543,18 +477,18 @@ configuration.locationProvider = setupLocationProvider();
543
477
  * | LOCATION_PROVIDER | location provider URL to use for ip location or `noPublic` or `environment` | noPublic | locationProvider.url or locationProvider | `see public-helper`
544
478
  * | LOCATION_PROVIDER_KEY | location provider key to use to access the location provider | null | locationProvider.key | see `public-helper`
545
479
  * | CLOUD_PROVIDER | cloud provider running the service | noCloud | cloudProvider | see `public-helper`
546
- * | SERVER_ID | service id | uuid.v4() | serverSettings.id |
480
+ * | SERVER_ID | service id | crypto.randomUUID() | serverSettings.id |
547
481
  * | CUSTOMER_CODE | customer code associated with the service instance | '' | serverSettings.customerCode | empty string
548
- * | SWAGGER_FILE_DIRECTORY | directory where the api definition is located | ./api | serverSettings.api | [1]
482
+ * | SWAGGER_FILE_DIRECTORY | directory where the api definition is located | ../api | serverSettings.api | [1]
549
483
  * | BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.username
550
484
  * | BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.password
551
485
  * | SWAGGERHUB_API_KEY | apiKey to access swaggerhub | | serverSettings.apiApiKey
552
486
  * | SERVER_SECURITY_SET | switch to enable or disable the token interpretation | on | serverSettings.securitySet | only active if environment is `local`
553
487
  * | INTERCEPT_ERROR | switch to use or not the errorIntercept option | on | serverSettings.interceptError | must be set to off for mID
554
488
  * | SERVER_PORT | port of the server | | serverSettings.port |
555
- * | SERVER_PUBLIC_PROTOCOL | protocol used to defined the domain address of the sevice | http: | serverSettings.public.protocol |
489
+ * | SERVER_PUBLIC_PROTOCOL | protocol used to define the domain address of the service | http: | serverSettings.public.protocol |
556
490
  * | SERVER_PUBLIC_DOMAIN_NAME | domain name used to define the domain address of the service | null | serverSettings.public.domainName |
557
- * | ADMIN_EXTERNAL_ID | external id of the admin role to be chacked in the token | admin | security.admin.externalId |
491
+ * | ADMIN_EXTERNAL_ID | external id of the admin role to be checked in the token | admin | security.admin.externalId |
558
492
  * | OAUTH_CLIENT_ID | security id of the service | | security.server.id | [2]
559
493
  * | OAUTH_CLIENT_SECRET | secret of the service | | security.server.secret | [2]
560
494
  * | OAUTH_CLIENT_ACCESS_KEY | key for token signature | | security.server.accessKey | [2]
@@ -564,8 +498,8 @@ configuration.locationProvider = setupLocationProvider();
564
498
  * | OAUTH_GENERIC_PREVIOUS_KEY | key for the token signature before change the public key | | security.generic.previousKey | [2]
565
499
  * | OAUTH_GENERIC_AUDIENCE | url representing the generic of the service type to mST | noGeneric | security.generic.audience | [2]
566
500
  * | API_KEYS | list of API Keys which a test against in case of APIKey security | [] |
567
- * | LOG_MODE | collector the be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`, 'awsKinesis'
568
- * | NO_STACK | disable the inclusion of a the stack in all logs | yes | logInfo.noStack
501
+ * | LOG_MODE | collector to be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`, 'awsKinesis'
502
+ * | NO_STACK | disable the inclusion of the stack in all logs | yes | logInfo.noStack
569
503
  * | FILTER_FILE | path for the filter file definition | null | logInfo.filterFile |
570
504
  * | USER_DEFINITIONS_FILE | path for the custom user definitions | null | userDefinitions.file |
571
505
  * | EXIT_DELAY | delay to allow the log transports to flush | 2000 | logInfo.exitDelay | in milliseconds
@@ -578,9 +512,9 @@ configuration.locationProvider = setupLocationProvider();
578
512
  * | ENCRYPTION_SET | switch to enable use of mongodb encryption | off | encryption.set | can be `on`, or `off`
579
513
  * | MIT_URL | url for reaching mIT | | dependencies.mIT.url |
580
514
  * | MIT_AUDIENCE | audience of mIT | | dependencies.mIT.audience | [2]
581
- * | REGISTRATION_SET | swicht to enable user of registration | on | registration.set | can be `on` or `off`
515
+ * | REGISTRATION_SET | switch to enable use of registration | on | registration.set | can be `on` or `off`
582
516
  * | REGISTRATION_RETRY | retry time for registering to mIT | 3000 | registration.retry | in milliseconds
583
- * | REGISTRATION_AFTER_POSTOPS_SET | switch to set the registration of execution the postOps | off | registratiom.afterPostOpsSet | can be `on` or `off`
517
+ * | REGISTRATION_AFTER_POSTOPS_SET | switch to set the registration of execution the postOps | off | registration.afterPostOpsSet | can be `on` or `off`
584
518
  * | `${configuration.serverSettings.type}_URL`.toUpperCase() | cluster information | self | dependencies.`(SERVER_TYPE)`.url | should not be used
585
519
  * | `${configuration.serverSettings.type}_AUDIENCE`.toUpperCase() | cluster information | | dependencies.`(SERVER_TYPE)`.audience | [2], but should not be used
586
520
  *
@@ -588,13 +522,13 @@ configuration.locationProvider = setupLocationProvider();
588
522
  *
589
523
  * [2]: defined when registering to mST
590
524
  *
591
- * 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``
525
+ * 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`
592
526
  *
593
527
  * When `sumologic` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
594
528
  *
595
529
  * | Env variable name | Description | Default | Comments |
596
530
  * | ----------------- | ----------- | ------- | -------- |
597
- * | SUMO_LOGIC_ENDPOINT | endpoint of the sumologic collector to used for logs |
531
+ * | SUMO_LOGIC_ENDPOINT | endpoint of the sumologic collector used for logs |
598
532
  * | SUMO_LOGIC_COLLECTOR_CODE | id of the collector in sumologic |
599
533
  *
600
534
  * When `awsS3` or `all` is used for `LOG_MODE` the following environment variables are used for the configuration:
@@ -618,7 +552,9 @@ configuration.locationProvider = setupLocationProvider();
618
552
  * | SNS_AWS_REGION | region where the topic is | ----noRegion---- |
619
553
  *
620
554
  * When a database is involved
555
+ *
621
556
  * | Env variable name | Description | Default | Comments |
557
+ * | ----------------- | ----------- | ------- | -------- |
622
558
  * | DATABASE_CONNECTION_TIMEOUT | the time to connect to the database before error is generated | 30 | in seconds
623
559
  * | DATABASE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
624
560
  * | DATABASE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
@@ -633,16 +569,16 @@ configuration.locationProvider = setupLocationProvider();
633
569
  * | DATABASE_PASSWORD | password to access the database | null | if missing no user/password will be used
634
570
  * | MONGO_USE_SRV | to use srv connection url set to `yes` | `no` |
635
571
  * | MONGO_AUTH_DATABASE | the auth database where users exists | |
636
- * | MONGO_MAX_POOL_SIZE | the minimum number of connections in the connection pool | 5 |
637
- * | MONGO_MIN_POOL_SIZE | the maximum number of connections in the connection pool | 10 |
638
- * | MONGO_MAX_IDLE_TIME | the maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed | 3000 | in milliseconds
572
+ * | MONGO_MIN_POOL_SIZE | the minimum number of connections in the connection pool | 0 |
573
+ * | MONGO_MAX_POOL_SIZE | the maximum number of connections in the connection pool | 10 |
574
+ * | MONGO_MAX_IDLE_TIME | the maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed | 30000 | in milliseconds
639
575
  * | MONGO_RETRY_WRITES | defines if the transaction should be tried again to write set to true or false | |
640
576
  * | MONGO_WRITE_CONCERN | accepts a number or `majority` | |
641
577
  * | MONGO_SSL | uses ssl connection if `yes` | `no` |
642
578
  * | MONGO_SSL_VALIDATE | validates mongod server certificate against ca if set to `yes` | `yes` | `yes` if MONGO_SSL is also `yes`
643
579
  * | MONGO_SSL_ALLOW_INVALID_HOSTNAMES | set to yes to allows invalid hostnames | |
644
580
  * | MONGO_REPLICAT_SET | specifies the name of the replica set, if the mongod is a member of a replica set | | not mandatory
645
- * | MONGO_WAIT_QUEUE_MULTIPLE | a number that the driver multiples the maxPoolSize value to, to provide the maximum number of threads allowed to wait for a connection to become available from the pool | | no mandatory
581
+ * | MONGO_WAIT_QUEUE_MULTIPLE | a number that the driver multiplies the maxPoolSize value to, to provide the maximum number of threads allowed to wait for a connection to become available from the pool | | not mandatory
646
582
  * | MONGO_WAIT_QUEUE_TIMEOUT | the maximum time in milliseconds that a thread can wait for a connection to become available | | not mandatory
647
583
  * | MONGO_SOCKET_TIMEOUT | The time in milliseconds to attempt a send or receive on a socket before the attempt times out | 20000 | in milliseconds
648
584
  * | MONGO_FAMILY | IP address family | 4 | 4 -> IPV4, 6 -> IPV6
@@ -662,7 +598,7 @@ configuration.locationProvider = setupLocationProvider();
662
598
  * | ENCRYPTION_SECRET_ACCESS_KEY | if KMS is aws, secretAccessKey to connect KMS | |
663
599
  * | LOCAL_MASTER_KEY | if KMS is local, masterkey to encrypt data keys | |
664
600
  *
665
- * When `dynamodb` is used the following environement variables are used for the configuration:
601
+ * When `dynamodb` is used the following environment variables are used for the configuration:
666
602
  *
667
603
  * | Env variable name | Description | Default | Comments |
668
604
  * | ----------------- | ----------- | ------- | -------- |
@@ -676,13 +612,13 @@ configuration.locationProvider = setupLocationProvider();
676
612
  * | DYNAMO_SCHEMA_THROUGHPUT_WRITE | throughput write for dynamodb schema | 1 |
677
613
  * | DYNAMO_SCHEMA_THROUGHPUT | throughput for dynamodb schema |
678
614
  *
679
- * `DYNAMO_SCHEMA_THROUGHPUT` takes precedence over `DYNAMO_SCHEMA_THROUGHPUT_READ` and `DYNAMO_SCHEMA_THROUGHPUT_WRITE`. If DYNAMO_SCHEMA_THROUGHPUT is set to `ON_DEMAND` then index throughput wont apply, and if DYNAMO_SCHEMA_THROUGHPUT is not set to a number the value will be 1.
615
+ * `DYNAMO_SCHEMA_THROUGHPUT` takes precedence over `DYNAMO_SCHEMA_THROUGHPUT_READ` and `DYNAMO_SCHEMA_THROUGHPUT_WRITE`. If DYNAMO_SCHEMA_THROUGHPUT is set to `ON_DEMAND` then index throughput won't apply, and if DYNAMO_SCHEMA_THROUGHPUT is not set to a number the value will be 1.
680
616
  *
681
- * When `redis` is used the following environement variables are used for the configuration:
617
+ * When `redis` is used the following environment variables are used for the configuration:
682
618
  *
683
619
  * | Env variable name | Description | Default | Comments |
684
620
  * | ----------------- | ----------- | ------- | -------- |
685
- * | CACHE_IP | domain of the redis server to use with port, a comma seperated list if using cluster | localhost:6379 |
621
+ * | CACHE_IP | domain of the redis server to use with port, a comma separated list if using cluster | localhost:6379 |
686
622
  * | CACHE_USER | redis user if the redis service is auth protected | null |
687
623
  * | CACHE_PASSWORD | redis password for the user if the redis service is auth protected | null |
688
624
  * | CACHE_CLUSTER_SET | set on, when using redis in a cluster. | off |
@@ -694,9 +630,9 @@ configuration.locationProvider = setupLocationProvider();
694
630
  * | CACHE_REQUEST_TTL | request time to live in cache | 10 | in seconds
695
631
  * | CACHE_API_ID_TTL | API request time to live for main resource | 20 | in seconds
696
632
  * | CACHE_API_OPTION_TTL | API request time to live for option | 5 | in seconds
697
- * | REDIS_RECONNECT_TRIES | number of tries to restablish a connection | 100 |
633
+ * | REDIS_RECONNECT_TRIES | number of tries to reestablish a connection | 100 |
698
634
  * | REDIS_RECONNECT_INTERVAL | time to wait before retry | 500 | in milliseconds
699
- * | REDIS_REQUEST_MAX_MEMORY | maximum memory size of the request cache | 10 | in megabytes
635
+ * | REDIS_REQUEST_MAX_MEMORY | maximum memory size of the request cache | 10mb | in megabytes
700
636
  * | REDIS_REQUEST_MAX_MEMORY_POLICY | eviction policy of the request cache | allkeys-lru |
701
637
  * | REDIS_SOCKET_KEEPALIVE | keep long running connections alive for x seconds | 5000 | in seconds
702
638
  * | REDIS_DISABLE_OFFLINE_QUEUE | queuing event when not connected | no |
@@ -710,16 +646,15 @@ export const setConfig = (pack, options) => {
710
646
  process.env.SWAGGER_FILE_ACCOUNT = pack.swaggerFile.account;
711
647
  process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
712
648
  if (pack.swaggerFile.provider) process.env.SWAGGER_FILE_PROVIDER = pack.swaggerFile.provider;
713
- else process.env.SWAGGER_FILE_PROVIDER = DEFAULT_SWAGGER_FILE_PROVIDER;
649
+ else process.env.SWAGGER_FILE_PROVIDER = 'bitbucket';
714
650
  }
715
651
 
716
- // eslint-disable-next-line max-len
717
652
  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}`;
718
653
 
719
654
  configuration.serverSettings.name = process.env.SERVER_NAME;
720
655
  configuration.serverSettings.type = process.env.SERVER_TYPE;
721
656
  configuration.serverSettings.version = process.env.SERVER_VERSION;
722
- configuration.serverSettings.api = `${process.env.SWAGGER_FILE_DIRECTORY || DEFAULT_SWAGGER_DIR}/${apiFilename}`;
657
+ configuration.serverSettings.api = `${process.env.SWAGGER_FILE_DIRECTORY || '../api'}/${apiFilename}`;
723
658
  configuration.serverSettings.swaggerFile = {
724
659
  version: process.env.SWAGGER_FILE_VERSION,
725
660
  name: process.env.SWAGGER_FILE_NAME,
@@ -751,15 +686,15 @@ export const setConfig = (pack, options) => {
751
686
  configuration.dynamoose = setupDynamo(options.database);
752
687
  }
753
688
  else {
754
- throw new Error(`database type no supported: ${options.database.type}`);
689
+ throw new Error(`database type not supported: ${options.database.type}`);
755
690
  }
756
691
  }
757
692
  if (options.cache && configuration.cache.set === SET_ON) {
758
693
  if (options.cache.type === 'redis') {
759
- configuration.redisSettings = setupRedis(options.cache);
694
+ configuration.redisSettings = setupRedis();
760
695
  }
761
696
  else {
762
- throw new Error(`cache type no supported: ${options.cache.type}`);
697
+ throw new Error(`cache type not supported: ${options.cache.type}`);
763
698
  }
764
699
  }
765
700
  if (options.topic && configuration.topic.set === SET_ON) {
@@ -791,7 +726,7 @@ export const setConfig = (pack, options) => {
791
726
  }
792
727
  if (options.security) {
793
728
  Object.keys(options.security).forEach((securityItem) => {
794
- if (configuration.security[securityItem]) {
729
+ if (securityItem in configuration.security) {
795
730
  Object.keys(options.security[securityItem]).forEach((subSecurityItem) => {
796
731
  configuration.security[securityItem][subSecurityItem] = options.security[securityItem][subSecurityItem];
797
732
  });