@mimik/configuration 6.0.7 → 6.0.9
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/.claude/settings.local.json +2 -1
- package/README.md +7 -7
- package/index.js +45 -47
- package/lib/common.js +7 -0
- package/package.json +1 -1
- package/.husky/pre-commit +0 -2
- package/.husky/pre-push +0 -2
- package/eslint.config.js +0 -83
- package/manual-test/test-config.js +0 -48
- package/manual-test/testEnv.js +0 -21
- package/test/configuration.spec.js +0 -1038
- package/test/testEnv.js +0 -46
package/README.md
CHANGED
|
@@ -83,8 +83,8 @@ The following environment variables are being used for the configuration:
|
|
|
83
83
|
| OAUTH_GENERIC_KEY | key for token signature provided when a generic for this service type is defined | noGeneric | security.generic.key | [2]
|
|
84
84
|
| OAUTH_GENERIC_PREVIOUS_KEY | key for the token signature before change the public key | | security.generic.previousKey | [2]
|
|
85
85
|
| OAUTH_GENERIC_AUDIENCE | url representing the generic of the service type to mST | noGeneric | security.generic.audience | [2]
|
|
86
|
-
| API_KEYS | list of API Keys which
|
|
87
|
-
| LOG_MODE | collector to be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`,
|
|
86
|
+
| API_KEYS | list of API Keys which are tested against in case of APIKey security | [] |
|
|
87
|
+
| LOG_MODE | collector to be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`, `awsKinesis`, `none`
|
|
88
88
|
| NO_STACK | disable the inclusion of the stack in all logs | yes | logInfo.noStack
|
|
89
89
|
| FILTER_FILE | path for the filter file definition | null | logInfo.filterFile |
|
|
90
90
|
| USER_DEFINITIONS_FILE | path for the custom user definitions | null | userDefinitions.file |
|
|
@@ -100,11 +100,11 @@ The following environment variables are being used for the configuration:
|
|
|
100
100
|
| MIT_AUDIENCE | audience of mIT | | dependencies.mIT.audience | [2]
|
|
101
101
|
| REGISTRATION_SET | switch to enable use of registration | on | registration.set | can be `on` or `off`
|
|
102
102
|
| REGISTRATION_RETRY | retry time for registering to mIT | 3000 | registration.retry | in milliseconds
|
|
103
|
-
| REGISTRATION_AFTER_POSTOPS_SET | switch to set the registration
|
|
103
|
+
| REGISTRATION_AFTER_POSTOPS_SET | switch to set the registration after the execution of the postOps | off | registration.afterPostOpsSet | can be `on` or `off`
|
|
104
104
|
| `$_URL`.toUpperCase() | cluster information | self | dependencies.`(SERVER_TYPE)`.url | should not be used
|
|
105
105
|
| `${configuration.serverSettings.type}_AUDIENCE`.toUpperCase() | cluster information | | dependencies.`(SERVER_TYPE)`.audience | [2], but should not be used
|
|
106
106
|
|
|
107
|
-
[1]: `/(SWAGGER_FILE_ACCOUNT)_(
|
|
107
|
+
[1]: `/(SWAGGER_FILE_ACCOUNT)_(SWAGGER_FILE_NAME)_(SWAGGER_FILE_VERSION)_swagger.json` is added to the `serverSettings.api` property
|
|
108
108
|
|
|
109
109
|
[2]: defined when registering to mST
|
|
110
110
|
|
|
@@ -154,7 +154,7 @@ When `mongodb` is used the following environment variables are used for the conf
|
|
|
154
154
|
| DATABASE_USER | user to access the database | null | if missing no user/password will be used
|
|
155
155
|
| DATABASE_PASSWORD | password to access the database | null | if missing no user/password will be used
|
|
156
156
|
| MONGO_USE_SRV | to use srv connection url set to `yes` | `no` |
|
|
157
|
-
| MONGO_AUTH_DATABASE | the auth database where users
|
|
157
|
+
| MONGO_AUTH_DATABASE | the auth database where users exist | |
|
|
158
158
|
| MONGO_MIN_POOL_SIZE | the minimum number of connections in the connection pool | 0 |
|
|
159
159
|
| MONGO_MAX_POOL_SIZE | the maximum number of connections in the connection pool | 10 |
|
|
160
160
|
| 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
|
|
@@ -162,7 +162,7 @@ When `mongodb` is used the following environment variables are used for the conf
|
|
|
162
162
|
| MONGO_WRITE_CONCERN | accepts a number or `majority` | |
|
|
163
163
|
| MONGO_SSL | uses ssl connection if `yes` | `no` |
|
|
164
164
|
| MONGO_SSL_VALIDATE | validates mongod server certificate against ca if set to `yes` | `yes` | `yes` if MONGO_SSL is also `yes`
|
|
165
|
-
| MONGO_SSL_ALLOW_INVALID_HOSTNAMES | set to yes to
|
|
165
|
+
| MONGO_SSL_ALLOW_INVALID_HOSTNAMES | set to yes to allow invalid hostnames | |
|
|
166
166
|
| MONGO_REPLICAT_SET | specifies the name of the replica set, if the mongod is a member of a replica set | | not mandatory
|
|
167
167
|
| 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
|
|
168
168
|
| MONGO_WAIT_QUEUE_TIMEOUT | the maximum time in milliseconds that a thread can wait for a connection to become available | | not mandatory
|
|
@@ -220,7 +220,7 @@ When `redis` is used the following environment variables are used for the config
|
|
|
220
220
|
| REDIS_RECONNECT_INTERVAL | time to wait before retry | 500 | in milliseconds
|
|
221
221
|
| REDIS_REQUEST_MAX_MEMORY | maximum memory size of the request cache | 10mb | in megabytes
|
|
222
222
|
| REDIS_REQUEST_MAX_MEMORY_POLICY | eviction policy of the request cache | allkeys-lru |
|
|
223
|
-
| REDIS_SOCKET_KEEPALIVE | keep long
|
|
223
|
+
| REDIS_SOCKET_KEEPALIVE | keep long-running connections alive | 5000 | in milliseconds
|
|
224
224
|
| REDIS_DISABLE_OFFLINE_QUEUE | queuing event when not connected | no |
|
|
225
225
|
|
|
226
226
|
**Requires**: <code>module:@mimik/sumologic-winston-logger</code>
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
SWAGGER_EXT,
|
|
22
22
|
SWAGGER_SEP,
|
|
23
23
|
YES,
|
|
24
|
+
toInt,
|
|
24
25
|
} from './lib/common.js';
|
|
25
26
|
import crypto from 'node:crypto';
|
|
26
27
|
import fs from 'node:fs';
|
|
@@ -30,7 +31,6 @@ import logger from '@mimik/sumologic-winston-logger';
|
|
|
30
31
|
import process from 'node:process';
|
|
31
32
|
import { userDefinitions } from '@mimik/user-filters';
|
|
32
33
|
|
|
33
|
-
const DECIMAL = 10;
|
|
34
34
|
const AT_LEAST_ONE = 0;
|
|
35
35
|
const SOME_KEYS = 0;
|
|
36
36
|
const SOME_ERRORS = 0;
|
|
@@ -53,8 +53,8 @@ const setupRedis = () => {
|
|
|
53
53
|
const domain = process.env.CACHE_IP || 'localhost:6379';
|
|
54
54
|
const username = process.env.CACHE_USER;
|
|
55
55
|
const password = process.env.CACHE_PASSWORD;
|
|
56
|
-
const reconnectTries =
|
|
57
|
-
const reconnectInterval =
|
|
56
|
+
const reconnectTries = toInt(process.env.REDIS_RECONNECT_TRIES, 100);
|
|
57
|
+
const reconnectInterval = toInt(process.env.REDIS_RECONNECT_INTERVAL, 500);
|
|
58
58
|
let url = REDIS_BASE_URL;
|
|
59
59
|
let noAuthUrl = url;
|
|
60
60
|
if (username && password) url += `${username}:${password}@`;
|
|
@@ -69,16 +69,16 @@ const setupRedis = () => {
|
|
|
69
69
|
|
|
70
70
|
return {
|
|
71
71
|
api: {
|
|
72
|
-
idTTL:
|
|
73
|
-
optionTTL:
|
|
72
|
+
idTTL: toInt(process.env.CACHE_API_ID_TTL, 20),
|
|
73
|
+
optionTTL: toInt(process.env.CACHE_API_OPTION_TTL, 5),
|
|
74
74
|
},
|
|
75
75
|
cluster: clusterConfig,
|
|
76
|
-
connectTimeout:
|
|
76
|
+
connectTimeout: toInt(process.env.CACHE_CONNECTION_TIMEOUT, 30),
|
|
77
77
|
domain,
|
|
78
78
|
noAuthUrl,
|
|
79
79
|
options: {
|
|
80
80
|
socket: {
|
|
81
|
-
keepAlive:
|
|
81
|
+
keepAlive: toInt(process.env.REDIS_SOCKET_KEEPALIVE, 5000),
|
|
82
82
|
reconnectStrategy: function reconnectStrategy(opts) {
|
|
83
83
|
if (opts.timesConnected > AT_LEAST_ONE && opts.attempt < reconnectTries) {
|
|
84
84
|
return reconnectInterval;
|
|
@@ -98,9 +98,9 @@ const setupRedis = () => {
|
|
|
98
98
|
maxMemoryPolicy: process.env.REDIS_REQUEST_MAX_MEMORY_POLICY || 'allkeys-lru',
|
|
99
99
|
},
|
|
100
100
|
password,
|
|
101
|
-
reconnectOffset:
|
|
101
|
+
reconnectOffset: toInt(process.env.CACHE_RECONNECTION_OFFSET, 5),
|
|
102
102
|
request: {
|
|
103
|
-
TTL:
|
|
103
|
+
TTL: toInt(process.env.CACHE_REQUEST_TTL, 10),
|
|
104
104
|
},
|
|
105
105
|
retryStrategyOptions: {
|
|
106
106
|
reconnectTries,
|
|
@@ -108,24 +108,24 @@ const setupRedis = () => {
|
|
|
108
108
|
},
|
|
109
109
|
url,
|
|
110
110
|
username,
|
|
111
|
-
validationCheck:
|
|
111
|
+
validationCheck: toInt(process.env.CACHE_VALIDATION_CHECK, 1000),
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
const setupDynamo = (dbOpts) => {
|
|
116
116
|
const dbConfig = {
|
|
117
|
-
connectTimeout:
|
|
118
|
-
validationCheck:
|
|
119
|
-
reconnectOffset:
|
|
117
|
+
connectTimeout: toInt(process.env.DATABASE_CONNECTION_TIMEOUT, 30),
|
|
118
|
+
validationCheck: toInt(process.env.DATABASE_VALIDATION_CHECK, 1000),
|
|
119
|
+
reconnectOffset: toInt(process.env.DATABASE_RECONNECTION_OFFSET, 5),
|
|
120
120
|
region: process.env.DYNAMODB_AWS_REGION || '----noRegion----',
|
|
121
121
|
url: process.env.DYNAMODB_LOCAL_URL || 'http://localhost:8000',
|
|
122
122
|
throughput: {
|
|
123
|
-
read:
|
|
124
|
-
write:
|
|
123
|
+
read: toInt(process.env.DYNAMO_THROUGHPUT_READ, 1),
|
|
124
|
+
write: toInt(process.env.DYNAMO_THROUGHPUT_WRITE, 1),
|
|
125
125
|
},
|
|
126
126
|
schemaThroughput: {
|
|
127
|
-
read:
|
|
128
|
-
write:
|
|
127
|
+
read: toInt(process.env.DYNAMO_SCHEMA_THROUGHPUT_READ, 1),
|
|
128
|
+
write: toInt(process.env.DYNAMO_SCHEMA_THROUGHPUT_WRITE, 1),
|
|
129
129
|
},
|
|
130
130
|
tableName: dbOpts.table,
|
|
131
131
|
};
|
|
@@ -137,10 +137,7 @@ const setupDynamo = (dbOpts) => {
|
|
|
137
137
|
delete dbConfig.throughput;
|
|
138
138
|
}
|
|
139
139
|
else if (process.env.DYNAMO_SCHEMA_THROUGHPUT !== undefined) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (Number.isNaN(throughput)) dbConfig.schemaThroughput = 1;
|
|
143
|
-
else dbConfig.schemaThroughput = throughput;
|
|
140
|
+
dbConfig.schemaThroughput = toInt(process.env.DYNAMO_SCHEMA_THROUGHPUT, 1);
|
|
144
141
|
}
|
|
145
142
|
return dbConfig;
|
|
146
143
|
};
|
|
@@ -149,9 +146,9 @@ const setupMongo = (dbOpts) => {
|
|
|
149
146
|
const processStringOptions = () => {
|
|
150
147
|
// default string variables
|
|
151
148
|
const stringOptions = {
|
|
152
|
-
maxPoolSize:
|
|
153
|
-
minPoolSize:
|
|
154
|
-
maxIdleTimeMS:
|
|
149
|
+
maxPoolSize: toInt(process.env.MONGO_MAX_POOL_SIZE, 10),
|
|
150
|
+
minPoolSize: toInt(process.env.MONGO_MIN_POOL_SIZE, 0),
|
|
151
|
+
maxIdleTimeMS: toInt(process.env.MONGO_MAX_IDLE_TIME, 30000),
|
|
155
152
|
};
|
|
156
153
|
// string variables without default
|
|
157
154
|
if (process.env.MONGO_SSL === YES) stringOptions.ssl = true; // default value of mongo driver is false
|
|
@@ -163,8 +160,8 @@ const setupMongo = (dbOpts) => {
|
|
|
163
160
|
// eslint-disable-next-line id-length
|
|
164
161
|
if (process.env.MONGO_WRITE_CONCERN) stringOptions.w = process.env.MONGO_WRITE_CONCERN;
|
|
165
162
|
if (process.env.MONGO_RETRY_WRITES) stringOptions.retryWrites = process.env.MONGO_RETRY_WRITES;
|
|
166
|
-
if (process.env.MONGO_WAIT_QUEUE_MULTIPLE) stringOptions.waitQueueMultiple =
|
|
167
|
-
if (process.env.MONGO_WAIT_QUEUE_TIMEOUT) stringOptions.waitQueueTimeoutMS =
|
|
163
|
+
if (process.env.MONGO_WAIT_QUEUE_MULTIPLE) stringOptions.waitQueueMultiple = toInt(process.env.MONGO_WAIT_QUEUE_MULTIPLE, 0);
|
|
164
|
+
if (process.env.MONGO_WAIT_QUEUE_TIMEOUT) stringOptions.waitQueueTimeoutMS = toInt(process.env.MONGO_WAIT_QUEUE_TIMEOUT, 0); // in ms
|
|
168
165
|
return new URLSearchParams(stringOptions).toString();
|
|
169
166
|
};
|
|
170
167
|
const database = process.env.DATABASE_NAME;
|
|
@@ -186,24 +183,24 @@ const setupMongo = (dbOpts) => {
|
|
|
186
183
|
noAuthUrl = `${noAuthUrl}?${qs}`;
|
|
187
184
|
}
|
|
188
185
|
return {
|
|
189
|
-
connectTimeout:
|
|
186
|
+
connectTimeout: toInt(process.env.DATABASE_CONNECTION_TIMEOUT, 30),
|
|
190
187
|
database,
|
|
191
188
|
domain,
|
|
192
189
|
noAuthUrl,
|
|
193
190
|
options: {
|
|
194
|
-
family:
|
|
195
|
-
socketTimeoutMS:
|
|
196
|
-
serverSelectionTimeoutMS:
|
|
197
|
-
heartbeatFrequencyMS:
|
|
191
|
+
family: toInt(process.env.MONGO_FAMILY, 4),
|
|
192
|
+
socketTimeoutMS: toInt(process.env.MONGO_SOCKET_TIMEOUT, 20000),
|
|
193
|
+
serverSelectionTimeoutMS: toInt(process.env.MONGO_SERVER_SELECTION_TIMEOUT, 30000),
|
|
194
|
+
heartbeatFrequencyMS: toInt(process.env.MONGO_HEARTBEAT_FREQUENCY, 10000),
|
|
198
195
|
},
|
|
199
196
|
password,
|
|
200
|
-
reconnectOffset:
|
|
197
|
+
reconnectOffset: toInt(process.env.DATABASE_RECONNECTION_OFFSET, 5),
|
|
201
198
|
replicat: Boolean(process.env.MONGO_REPLICAT_SET),
|
|
202
199
|
stringOptions: qs,
|
|
203
200
|
table: dbOpts.table,
|
|
204
201
|
url,
|
|
205
202
|
user,
|
|
206
|
-
validationCheck:
|
|
203
|
+
validationCheck: toInt(process.env.DATABASE_VALIDATION_CHECK, 1000),
|
|
207
204
|
};
|
|
208
205
|
};
|
|
209
206
|
|
|
@@ -226,7 +223,7 @@ const setupLog = () => {
|
|
|
226
223
|
log: process.env.LOG_LEVEL || DEBUG,
|
|
227
224
|
},
|
|
228
225
|
filterFile: process.env.FILTER_FILE || NOT_SET,
|
|
229
|
-
exitDelay:
|
|
226
|
+
exitDelay: toInt(process.env.EXIT_DELAY, 2000),
|
|
230
227
|
noStack: process.env.NO_STACK || YES,
|
|
231
228
|
};
|
|
232
229
|
|
|
@@ -240,9 +237,9 @@ const setupLog = () => {
|
|
|
240
237
|
logInfo[AWS_S3] = {
|
|
241
238
|
region: process.env.S3_AWS_REGION,
|
|
242
239
|
bucketName: process.env.S3_AWS_BUCKET_NAME,
|
|
243
|
-
timeout:
|
|
244
|
-
maxSize:
|
|
245
|
-
maxEvents:
|
|
240
|
+
timeout: toInt(process.env.S3_AWS_TIMEOUT, 5),
|
|
241
|
+
maxSize: toInt(process.env.S3_AWS_MAX_SIZE, 5),
|
|
242
|
+
maxEvents: toInt(process.env.S3_AWS_MAX_EVENTS, 1000),
|
|
246
243
|
};
|
|
247
244
|
if (process.env.S3_AWS_ACCESS_KEY_ID !== undefined) logInfo[AWS_S3].accessKeyId = process.env.S3_AWS_ACCESS_KEY_ID;
|
|
248
245
|
if (process.env.S3_AWS_SECRET_ACCESS_KEY !== undefined) logInfo[AWS_S3].secretAccessKey = process.env.S3_AWS_SECRET_ACCESS_KEY;
|
|
@@ -310,6 +307,7 @@ const checkConfig = (config) => {
|
|
|
310
307
|
const errors = [];
|
|
311
308
|
|
|
312
309
|
const traverseNodeSync = (node, path) => {
|
|
310
|
+
if (Array.isArray(node)) return;
|
|
313
311
|
Object.keys(node).forEach((prop) => {
|
|
314
312
|
if (typeof node[prop] === 'object' && node[prop]) {
|
|
315
313
|
traverseNodeSync(node[prop], `${path}.${prop}`);
|
|
@@ -361,7 +359,7 @@ const configuration = {
|
|
|
361
359
|
cloudProvider: process.env.CLOUD_PROVIDER || 'noCloud',
|
|
362
360
|
cluster: {
|
|
363
361
|
management: process.env.CLUSTER_MANAGEMENT || SET_OFF,
|
|
364
|
-
timeout:
|
|
362
|
+
timeout: toInt(process.env.REQUEST_TIMEOUT, 10000),
|
|
365
363
|
},
|
|
366
364
|
dependencies: {
|
|
367
365
|
mIT: {
|
|
@@ -376,7 +374,7 @@ const configuration = {
|
|
|
376
374
|
nodeEnvironment: process.env.NODE_ENV || LOCAL,
|
|
377
375
|
registration: {
|
|
378
376
|
set: process.env.REGISTRATION_SET || SET_ON,
|
|
379
|
-
retry:
|
|
377
|
+
retry: toInt(process.env.REGISTRATION_RETRY, 3000),
|
|
380
378
|
afterPostOpsSet: process.env.REGISTRATION_AFTER_POSTOPS_SET || SET_OFF,
|
|
381
379
|
},
|
|
382
380
|
security: {
|
|
@@ -402,7 +400,7 @@ const configuration = {
|
|
|
402
400
|
customerCodeSep: process.env.CUSTOMER_CODE ? CUSTOMER_CODE_SEP : '',
|
|
403
401
|
securitySet: process.env.SERVER_SECURITY_SET || SET_ON,
|
|
404
402
|
isMSTSet,
|
|
405
|
-
port:
|
|
403
|
+
port: toInt(process.env.SERVER_PORT, undefined),
|
|
406
404
|
interceptError: process.env.INTERCEPT_ERROR || SET_ON,
|
|
407
405
|
ip: {
|
|
408
406
|
local: process.env.SERVER_LOCAL_IPV4,
|
|
@@ -497,8 +495,8 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
497
495
|
* | OAUTH_GENERIC_KEY | key for token signature provided when a generic for this service type is defined | noGeneric | security.generic.key | [2]
|
|
498
496
|
* | OAUTH_GENERIC_PREVIOUS_KEY | key for the token signature before change the public key | | security.generic.previousKey | [2]
|
|
499
497
|
* | OAUTH_GENERIC_AUDIENCE | url representing the generic of the service type to mST | noGeneric | security.generic.audience | [2]
|
|
500
|
-
* | API_KEYS | list of API Keys which
|
|
501
|
-
* | LOG_MODE | collector to be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`,
|
|
498
|
+
* | API_KEYS | list of API Keys which are tested against in case of APIKey security | [] |
|
|
499
|
+
* | LOG_MODE | collector to be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`, `awsKinesis`, `none`
|
|
502
500
|
* | NO_STACK | disable the inclusion of the stack in all logs | yes | logInfo.noStack
|
|
503
501
|
* | FILTER_FILE | path for the filter file definition | null | logInfo.filterFile |
|
|
504
502
|
* | USER_DEFINITIONS_FILE | path for the custom user definitions | null | userDefinitions.file |
|
|
@@ -514,11 +512,11 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
514
512
|
* | MIT_AUDIENCE | audience of mIT | | dependencies.mIT.audience | [2]
|
|
515
513
|
* | REGISTRATION_SET | switch to enable use of registration | on | registration.set | can be `on` or `off`
|
|
516
514
|
* | REGISTRATION_RETRY | retry time for registering to mIT | 3000 | registration.retry | in milliseconds
|
|
517
|
-
* | REGISTRATION_AFTER_POSTOPS_SET | switch to set the registration
|
|
515
|
+
* | REGISTRATION_AFTER_POSTOPS_SET | switch to set the registration after the execution of the postOps | off | registration.afterPostOpsSet | can be `on` or `off`
|
|
518
516
|
* | `${configuration.serverSettings.type}_URL`.toUpperCase() | cluster information | self | dependencies.`(SERVER_TYPE)`.url | should not be used
|
|
519
517
|
* | `${configuration.serverSettings.type}_AUDIENCE`.toUpperCase() | cluster information | | dependencies.`(SERVER_TYPE)`.audience | [2], but should not be used
|
|
520
518
|
*
|
|
521
|
-
* [1]: `/(SWAGGER_FILE_ACCOUNT)_(
|
|
519
|
+
* [1]: `/(SWAGGER_FILE_ACCOUNT)_(SWAGGER_FILE_NAME)_(SWAGGER_FILE_VERSION)_swagger.json` is added to the `serverSettings.api` property
|
|
522
520
|
*
|
|
523
521
|
* [2]: defined when registering to mST
|
|
524
522
|
*
|
|
@@ -568,7 +566,7 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
568
566
|
* | DATABASE_USER | user to access the database | null | if missing no user/password will be used
|
|
569
567
|
* | DATABASE_PASSWORD | password to access the database | null | if missing no user/password will be used
|
|
570
568
|
* | MONGO_USE_SRV | to use srv connection url set to `yes` | `no` |
|
|
571
|
-
* | MONGO_AUTH_DATABASE | the auth database where users
|
|
569
|
+
* | MONGO_AUTH_DATABASE | the auth database where users exist | |
|
|
572
570
|
* | MONGO_MIN_POOL_SIZE | the minimum number of connections in the connection pool | 0 |
|
|
573
571
|
* | MONGO_MAX_POOL_SIZE | the maximum number of connections in the connection pool | 10 |
|
|
574
572
|
* | 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
|
|
@@ -576,7 +574,7 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
576
574
|
* | MONGO_WRITE_CONCERN | accepts a number or `majority` | |
|
|
577
575
|
* | MONGO_SSL | uses ssl connection if `yes` | `no` |
|
|
578
576
|
* | MONGO_SSL_VALIDATE | validates mongod server certificate against ca if set to `yes` | `yes` | `yes` if MONGO_SSL is also `yes`
|
|
579
|
-
* | MONGO_SSL_ALLOW_INVALID_HOSTNAMES | set to yes to
|
|
577
|
+
* | MONGO_SSL_ALLOW_INVALID_HOSTNAMES | set to yes to allow invalid hostnames | |
|
|
580
578
|
* | MONGO_REPLICAT_SET | specifies the name of the replica set, if the mongod is a member of a replica set | | not mandatory
|
|
581
579
|
* | 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
|
|
582
580
|
* | MONGO_WAIT_QUEUE_TIMEOUT | the maximum time in milliseconds that a thread can wait for a connection to become available | | not mandatory
|
|
@@ -634,7 +632,7 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
634
632
|
* | REDIS_RECONNECT_INTERVAL | time to wait before retry | 500 | in milliseconds
|
|
635
633
|
* | REDIS_REQUEST_MAX_MEMORY | maximum memory size of the request cache | 10mb | in megabytes
|
|
636
634
|
* | REDIS_REQUEST_MAX_MEMORY_POLICY | eviction policy of the request cache | allkeys-lru |
|
|
637
|
-
* | REDIS_SOCKET_KEEPALIVE | keep long
|
|
635
|
+
* | REDIS_SOCKET_KEEPALIVE | keep long-running connections alive | 5000 | in milliseconds
|
|
638
636
|
* | REDIS_DISABLE_OFFLINE_QUEUE | queuing event when not connected | no |
|
|
639
637
|
*/
|
|
640
638
|
export const setConfig = (pack, options) => {
|
package/lib/common.js
CHANGED
|
@@ -23,6 +23,12 @@ const PRODUCTIONS = ['prod', 'production'];
|
|
|
23
23
|
|
|
24
24
|
const SUPPORTED_SWAGGER_FILE_PROVIDERS = ['bitbucket', 'swaggerhub'];
|
|
25
25
|
|
|
26
|
+
const DECIMAL = 10;
|
|
27
|
+
const toInt = (value, fallback) => {
|
|
28
|
+
const parsed = parseInt(value, DECIMAL);
|
|
29
|
+
return Number.isNaN(parsed) ? fallback : parsed;
|
|
30
|
+
};
|
|
31
|
+
|
|
26
32
|
export {
|
|
27
33
|
ALL,
|
|
28
34
|
AWS_S3,
|
|
@@ -45,4 +51,5 @@ export {
|
|
|
45
51
|
SWAGGER_EXT,
|
|
46
52
|
SWAGGER_SEP,
|
|
47
53
|
YES,
|
|
54
|
+
toInt,
|
|
48
55
|
};
|
package/package.json
CHANGED
package/.husky/pre-commit
DELETED
package/.husky/pre-push
DELETED
package/eslint.config.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import globals from 'globals';
|
|
2
|
-
import importPlugin from 'eslint-plugin-import';
|
|
3
|
-
import js from '@eslint/js';
|
|
4
|
-
import processDoc from '@mimik/eslint-plugin-document-env';
|
|
5
|
-
import stylistic from '@stylistic/eslint-plugin';
|
|
6
|
-
|
|
7
|
-
const MAX_LENGTH_LINE = 180;
|
|
8
|
-
const MAX_FUNCTION_PARAMETERS = 6;
|
|
9
|
-
const MAX_LINES_IN_FILES = 600;
|
|
10
|
-
const MAX_LINES_IN_FUNCTION = 150;
|
|
11
|
-
const MAX_STATEMENTS_IN_FUNCTION = 45;
|
|
12
|
-
const MIN_KEYS_IN_OBJECT = 10;
|
|
13
|
-
const MAX_COMPLEXITY = 30;
|
|
14
|
-
const ECMA_VERSION = 'latest';
|
|
15
|
-
const MAX_DEPTH = 6;
|
|
16
|
-
const ALLOWED_CONSTANTS = [0, 1, -1];
|
|
17
|
-
|
|
18
|
-
export default [
|
|
19
|
-
{
|
|
20
|
-
ignores: ['mochawesome-report/**', 'node_modules/**', 'dist/**'],
|
|
21
|
-
},
|
|
22
|
-
importPlugin.flatConfigs.recommended,
|
|
23
|
-
stylistic.configs.recommended,
|
|
24
|
-
js.configs.all,
|
|
25
|
-
{
|
|
26
|
-
plugins: {
|
|
27
|
-
processDoc,
|
|
28
|
-
},
|
|
29
|
-
languageOptions: {
|
|
30
|
-
ecmaVersion: ECMA_VERSION,
|
|
31
|
-
globals: {
|
|
32
|
-
...globals.mocha,
|
|
33
|
-
...globals.nodeBuiltin,
|
|
34
|
-
},
|
|
35
|
-
sourceType: 'module',
|
|
36
|
-
},
|
|
37
|
-
rules: {
|
|
38
|
-
'@stylistic/brace-style': ['warn', 'stroustrup', { allowSingleLine: true }],
|
|
39
|
-
'@stylistic/line-comment-position': ['off'],
|
|
40
|
-
'@stylistic/max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true, ignoreStrings: true, ignoreRegExpLiterals: true }],
|
|
41
|
-
'@stylistic/quotes': ['warn', 'single'],
|
|
42
|
-
'@stylistic/semi': ['error', 'always'],
|
|
43
|
-
'capitalized-comments': ['off'],
|
|
44
|
-
'complexity': ['error', MAX_COMPLEXITY],
|
|
45
|
-
'curly': ['off'],
|
|
46
|
-
'id-length': ['error', { exceptions: ['x', 'y', 'z', 'i', 'j', 'k'] }],
|
|
47
|
-
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
|
48
|
-
'import/no-unresolved': ['error', { amd: true, caseSensitiveStrict: true, commonjs: true }],
|
|
49
|
-
'init-declarations': ['off'],
|
|
50
|
-
'linebreak-style': ['off'],
|
|
51
|
-
'max-depth': ['error', MAX_DEPTH],
|
|
52
|
-
'max-len': ['off'],
|
|
53
|
-
'max-lines': ['warn', { max: MAX_LINES_IN_FILES, skipComments: true, skipBlankLines: true }],
|
|
54
|
-
'max-lines-per-function': ['warn', { max: MAX_LINES_IN_FUNCTION, skipComments: true, skipBlankLines: true }],
|
|
55
|
-
'max-params': ['error', MAX_FUNCTION_PARAMETERS],
|
|
56
|
-
'max-statements': ['warn', MAX_STATEMENTS_IN_FUNCTION],
|
|
57
|
-
'no-confusing-arrow': ['off'],
|
|
58
|
-
'no-inline-comments': ['off'],
|
|
59
|
-
'no-magic-numbers': ['error', { ignore: ALLOWED_CONSTANTS, enforceConst: true, detectObjects: true }],
|
|
60
|
-
'no-process-env': ['error'],
|
|
61
|
-
'no-ternary': ['off'],
|
|
62
|
-
'no-undefined': ['off'],
|
|
63
|
-
'one-var': ['error', 'never'],
|
|
64
|
-
'processDoc/validate-document-env': ['error'],
|
|
65
|
-
'quotes': ['off'],
|
|
66
|
-
'sort-imports': ['error', { allowSeparatedGroups: true }],
|
|
67
|
-
'sort-keys': ['error', 'asc', { caseSensitive: true, minKeys: MIN_KEYS_IN_OBJECT, natural: false, allowLineSeparatedGroups: true }],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
files: ['test/**/*.js'],
|
|
72
|
-
rules: {
|
|
73
|
-
'class-methods-use-this': ['off'],
|
|
74
|
-
'max-classes-per-file': ['off'],
|
|
75
|
-
'max-lines': ['off'],
|
|
76
|
-
'max-lines-per-function': ['off'],
|
|
77
|
-
'max-statements': ['off'],
|
|
78
|
-
'no-empty-function': ['off'],
|
|
79
|
-
'no-magic-numbers': ['off'],
|
|
80
|
-
'processDoc/validate-document-env': ['off'],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
];
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import './testEnv.js';
|
|
3
|
-
import { setConfig } from '../index.js';
|
|
4
|
-
// import Config from '../index.js';
|
|
5
|
-
|
|
6
|
-
const pack = {
|
|
7
|
-
swaggerFile: {
|
|
8
|
-
version: '2.0.6',
|
|
9
|
-
account: 'mimiktech',
|
|
10
|
-
name: 'swagger-mds',
|
|
11
|
-
},
|
|
12
|
-
mimik: {
|
|
13
|
-
type: 'test-pack-type',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const config = {
|
|
17
|
-
database: {
|
|
18
|
-
type: 'mongodb',
|
|
19
|
-
table: {
|
|
20
|
-
itResource: 'itResource',
|
|
21
|
-
lease: 'lease',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
dependencies: {
|
|
25
|
-
'mIT': {
|
|
26
|
-
audience: 'test-audience',
|
|
27
|
-
url: 'test-url',
|
|
28
|
-
},
|
|
29
|
-
'test-pack-type': {
|
|
30
|
-
audience: 'test-pack-type-audience',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
security: {
|
|
34
|
-
server: {
|
|
35
|
-
id: 'test-security-id',
|
|
36
|
-
secret: 'test-security-secret',
|
|
37
|
-
accessKey: 'test-security-access-key',
|
|
38
|
-
audience: 'test-security-audience',
|
|
39
|
-
issuer: 'test-security-issuer',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
serverSettings: {
|
|
43
|
-
type: 'test-type',
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const configuration = setConfig(pack, config);
|
|
48
|
-
console.log(configuration);
|
package/manual-test/testEnv.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* eslint no-process-env: "off" */
|
|
2
|
-
import process from 'process';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Test configuration Configuration.
|
|
7
|
-
*
|
|
8
|
-
* @description The following environment variables are needed to configure configuration:
|
|
9
|
-
*
|
|
10
|
-
* | Env variable name | Description | Default | Comments |
|
|
11
|
-
* | ----------------- | ----------- | ------- | -------- |
|
|
12
|
-
* | DATABASE_NAME | name of the database to use for mongodb
|
|
13
|
-
* | MONGO_REPLICAT_SET | set to a value for Boolean()
|
|
14
|
-
* | SUMO_LOGIC_ENDPOINT | dummy endpoint for sumologic
|
|
15
|
-
* | SUMO_LOGIC_COLLECTOR_CODE | dummy collector code for sumologic
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
process.env.DATABASE_NAME = 'test-database-name';
|
|
19
|
-
process.env.MONGO_REPLICAT_SET = 'test-mongo-replicat-set';
|
|
20
|
-
process.env.SUMO_LOGIC_ENDPOINT = 'test-logInfo-sumologic-endpoint';
|
|
21
|
-
process.env.SUMO_LOGIC_COLLECTOR_CODE = 'test-logInfo-sumologic-code';
|