@mimik/configuration 5.0.4 → 5.0.5
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/README.md +9 -3
- package/index.js +18 -3
- package/lib/common.js +7 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -132,6 +132,12 @@ When `on` is used for `TOPIC_SET` the following environment variables are used f
|
|
|
132
132
|
| SNS_AWS_SECRET_ACCESS_KEY | secret access key for AWS SNS | |
|
|
133
133
|
| SNS_AWS_REGION | region where the topic is | ----noRegion---- |
|
|
134
134
|
|
|
135
|
+
When a database is involved
|
|
136
|
+
| Env variable name | Description | Default | Comments |
|
|
137
|
+
| DATABASE_CONNECTION_TIMEOUT | the time to connect to the database before error is generated | 30 | in seconds
|
|
138
|
+
| DATABASE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
|
|
139
|
+
| DATABASE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
140
|
+
|
|
135
141
|
When `mongodb` is used the following environment variables are used for the configuration:
|
|
136
142
|
|
|
137
143
|
| Env variable name | Description | Default | Comments |
|
|
@@ -140,8 +146,6 @@ When `mongodb` is used the following environment variables are used for the conf
|
|
|
140
146
|
| DATABASE_IP | ip address of the database | localhost |
|
|
141
147
|
| DATABASE_USER | user to access the database | null | if missing no user/password will be used
|
|
142
148
|
| DATABASE_PASSWORD | password to access the database | null | if missing no user/password will be used
|
|
143
|
-
| DATABASE_CONNECTION_TIMEOUT | the time to connect to the database before error is generated | 30 | in seconds
|
|
144
|
-
| DATABASE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
145
149
|
| MONGO_USE_SRV | to use srv connection url set to `yes` | `no` |
|
|
146
150
|
| MONGO_AUTH_DATABASE | the auth database where users exists | |
|
|
147
151
|
| MONGO_MAX_POOL_SIZE | the minimum number of connections in the connection pool | 5 |
|
|
@@ -197,7 +201,9 @@ When `redis` is used the following environement variables are used for the confi
|
|
|
197
201
|
| ----------------- | ----------- | ------- | -------- |
|
|
198
202
|
| CACHE_IP | domain of the redis server to use | localhost:6379 |
|
|
199
203
|
| CACHE_PASSWORD | password if the redis service is protected (requirepass in redis.conf) | null |
|
|
200
|
-
| CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache |
|
|
204
|
+
| CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache | 30 | in seconds
|
|
205
|
+
| CACHE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
|
|
206
|
+
| CACHE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
201
207
|
| CACHE_REQUEST_TTL | request time to live in cache | 10 | in seconds
|
|
202
208
|
| CACHE_API_ID_TTL | API request time to live for main resource | 20 | in seconds
|
|
203
209
|
| CACHE_API_OPTION_TTL | API request time to live for option | 5 | in seconds
|
package/index.js
CHANGED
|
@@ -37,6 +37,8 @@ const {
|
|
|
37
37
|
DEFAULT_CACHE_IP,
|
|
38
38
|
DEFAULT_CACHE_PASSWORD,
|
|
39
39
|
DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
40
|
+
DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
41
|
+
DEFAULT_CACHE_VALIDATION_CHECK,
|
|
40
42
|
DEFAULT_CACHE_REQUEST_TTL,
|
|
41
43
|
DEFAULT_CACHE_API_ID_TTL,
|
|
42
44
|
DEFAULT_CACHE_API_OPTION_TTL,
|
|
@@ -66,6 +68,7 @@ const {
|
|
|
66
68
|
DEFAULT_DATABASE_PASSWORD,
|
|
67
69
|
DEFAULT_DATABASE_CONNECTION_TIMEOUT,
|
|
68
70
|
DEFAULT_DATABASE_RECONNECTION_OFFSET,
|
|
71
|
+
DEFAULT_DATABASE_VALIDATION_CHECK,
|
|
69
72
|
DEFAULT_ENCRYPTION_SET,
|
|
70
73
|
DEFAULT_KMS_PROVIDER,
|
|
71
74
|
DEFAULT_LOG_LEVEL,
|
|
@@ -111,6 +114,8 @@ const setupRedis = () => {
|
|
|
111
114
|
domain,
|
|
112
115
|
password,
|
|
113
116
|
connectTimeout: parseInt(process.env.CACHE_CONNECTION_TIMEOUT, 10) || DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
117
|
+
validationCheck: parseInt(process.env.CACHE_VALIDATION_CHECK, 10) || DEFAULT_CACHE_VALIDATION_CHECK,
|
|
118
|
+
reconnectOffset: parseInt(process.env.CACHE_RECONNECTION_OFFSET, 10) || DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
114
119
|
url,
|
|
115
120
|
options: {
|
|
116
121
|
maxMemory: process.env.REDIS_REQUEST_MAX_MEMORY || DEFAULT_REDIS_REQUEST_MAX_MEMORY,
|
|
@@ -147,6 +152,9 @@ const setupRedis = () => {
|
|
|
147
152
|
|
|
148
153
|
const setupDynamo = (dbOpts) => {
|
|
149
154
|
const dbConfig = {
|
|
155
|
+
connectTimeout: parseInt(process.env.DATABASE_CONNECTION_TIMEOUT, 10) || DEFAULT_DATABASE_CONNECTION_TIMEOUT,
|
|
156
|
+
validationCheck: parseInt(process.env.DATABASE_VALIDATION_CHECK, 10) || DEFAULT_DATABASE_VALIDATION_CHECK,
|
|
157
|
+
reconnectOffset: parseInt(process.env.DATABASE_RECONNECTION_OFFSET, 10) || DEFAULT_DATABASE_RECONNECTION_OFFSET,
|
|
150
158
|
region: process.env.DYNAMODB_AWS_REGION || DEFAULT_AWS_REGION,
|
|
151
159
|
url: process.env.DYNAMODB_LOCAL_URL || DEFAULT_DYNAMODB_LOCAL_URL,
|
|
152
160
|
throughput: {
|
|
@@ -215,6 +223,7 @@ const setupMongo = (dbOpts) => {
|
|
|
215
223
|
user,
|
|
216
224
|
password,
|
|
217
225
|
connectTimeout: parseInt(process.env.DATABASE_CONNECTION_TIMEOUT, 10) || DEFAULT_DATABASE_CONNECTION_TIMEOUT,
|
|
226
|
+
validationCheck: parseInt(process.env.DATABASE_VALIDATION_CHECK, 10) || DEFAULT_DATABASE_VALIDATION_CHECK,
|
|
218
227
|
reconnectOffset: parseInt(process.env.DATABASE_RECONNECTION_OFFSET, 10) || DEFAULT_DATABASE_RECONNECTION_OFFSET,
|
|
219
228
|
replicat: !!process.env.MONGO_REPLICAT_SET,
|
|
220
229
|
stringOptions: qs,
|
|
@@ -566,6 +575,12 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
566
575
|
* | SNS_AWS_SECRET_ACCESS_KEY | secret access key for AWS SNS | |
|
|
567
576
|
* | SNS_AWS_REGION | region where the topic is | ----noRegion---- |
|
|
568
577
|
*
|
|
578
|
+
* When a database is involved
|
|
579
|
+
* | Env variable name | Description | Default | Comments |
|
|
580
|
+
* | DATABASE_CONNECTION_TIMEOUT | the time to connect to the database before error is generated | 30 | in seconds
|
|
581
|
+
* | DATABASE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
|
|
582
|
+
* | DATABASE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
583
|
+
*
|
|
569
584
|
* When `mongodb` is used the following environment variables are used for the configuration:
|
|
570
585
|
*
|
|
571
586
|
* | Env variable name | Description | Default | Comments |
|
|
@@ -574,8 +589,6 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
574
589
|
* | DATABASE_IP | ip address of the database | localhost |
|
|
575
590
|
* | DATABASE_USER | user to access the database | null | if missing no user/password will be used
|
|
576
591
|
* | DATABASE_PASSWORD | password to access the database | null | if missing no user/password will be used
|
|
577
|
-
* | DATABASE_CONNECTION_TIMEOUT | the time to connect to the database before error is generated | 30 | in seconds
|
|
578
|
-
* | DATABASE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
579
592
|
* | MONGO_USE_SRV | to use srv connection url set to `yes` | `no` |
|
|
580
593
|
* | MONGO_AUTH_DATABASE | the auth database where users exists | |
|
|
581
594
|
* | MONGO_MAX_POOL_SIZE | the minimum number of connections in the connection pool | 5 |
|
|
@@ -631,7 +644,9 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
631
644
|
* | ----------------- | ----------- | ------- | -------- |
|
|
632
645
|
* | CACHE_IP | domain of the redis server to use | localhost:6379 |
|
|
633
646
|
* | CACHE_PASSWORD | password if the redis service is protected (requirepass in redis.conf) | null |
|
|
634
|
-
* | CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache |
|
|
647
|
+
* | CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache | 30 | in seconds
|
|
648
|
+
* | CACHE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
|
|
649
|
+
* | CACHE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
635
650
|
* | CACHE_REQUEST_TTL | request time to live in cache | 10 | in seconds
|
|
636
651
|
* | CACHE_API_ID_TTL | API request time to live for main resource | 20 | in seconds
|
|
637
652
|
* | CACHE_API_OPTION_TTL | API request time to live for option | 5 | in seconds
|
package/lib/common.js
CHANGED
|
@@ -22,7 +22,9 @@ const DEFAULT_CUSTOMER_CODE = '';
|
|
|
22
22
|
|
|
23
23
|
const DEFAULT_CACHE_IP = 'localhost:6379';
|
|
24
24
|
const DEFAULT_CACHE_PASSWORD = null;
|
|
25
|
-
const DEFAULT_CACHE_CONNECTION_TIMEOUT =
|
|
25
|
+
const DEFAULT_CACHE_CONNECTION_TIMEOUT = 30; // in seconds
|
|
26
|
+
const DEFAULT_CACHE_RECONNECTION_OFFSET = 5; // in seconds
|
|
27
|
+
const DEFAULT_CACHE_VALIDATION_CHECK = 1000; // in ms
|
|
26
28
|
const DEFAULT_CACHE_REQUEST_TTL = 10; // in seconds
|
|
27
29
|
const DEFAULT_CACHE_API_ID_TTL = 20; // in seconds
|
|
28
30
|
const DEFAULT_CACHE_API_OPTION_TTL = 5; // in seconds
|
|
@@ -57,6 +59,7 @@ const DEFAULT_DATABASE_USER = null;
|
|
|
57
59
|
const DEFAULT_DATABASE_PASSWORD = null;
|
|
58
60
|
const DEFAULT_DATABASE_CONNECTION_TIMEOUT = 30; // in seconds
|
|
59
61
|
const DEFAULT_DATABASE_RECONNECTION_OFFSET = 5; // in seconds
|
|
62
|
+
const DEFAULT_DATABASE_VALIDATION_CHECK = 1000; // in ms
|
|
60
63
|
|
|
61
64
|
const DEFAULT_ENCRYPTION_SET = SET_OFF;
|
|
62
65
|
const DEFAULT_KMS_PROVIDER = 'local';
|
|
@@ -117,6 +120,8 @@ module.exports = {
|
|
|
117
120
|
DEFAULT_CACHE_IP,
|
|
118
121
|
DEFAULT_CACHE_PASSWORD,
|
|
119
122
|
DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
123
|
+
DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
124
|
+
DEFAULT_CACHE_VALIDATION_CHECK,
|
|
120
125
|
DEFAULT_CACHE_REQUEST_TTL,
|
|
121
126
|
DEFAULT_CACHE_API_ID_TTL,
|
|
122
127
|
DEFAULT_CACHE_API_OPTION_TTL,
|
|
@@ -146,6 +151,7 @@ module.exports = {
|
|
|
146
151
|
DEFAULT_DATABASE_PASSWORD,
|
|
147
152
|
DEFAULT_DATABASE_CONNECTION_TIMEOUT,
|
|
148
153
|
DEFAULT_DATABASE_RECONNECTION_OFFSET,
|
|
154
|
+
DEFAULT_DATABASE_VALIDATION_CHECK,
|
|
149
155
|
DEFAULT_ENCRYPTION_SET,
|
|
150
156
|
DEFAULT_KMS_PROVIDER,
|
|
151
157
|
DEFAULT_LOG_LEVEL,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/configuration",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"description": "Common configuration for mimik services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@mimik/eslint-plugin-dependencies": "^2.4.5",
|
|
42
42
|
"@mimik/eslint-plugin-document-env": "^1.0.5",
|
|
43
|
-
"eslint": "8.
|
|
43
|
+
"eslint": "8.40.0",
|
|
44
44
|
"eslint-config-airbnb": "19.0.4",
|
|
45
45
|
"eslint-plugin-import": "2.27.5",
|
|
46
46
|
"eslint-plugin-jsx-a11y": "6.7.1",
|