@mimik/configuration 6.0.6 → 6.0.8
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 +15 -0
- package/.husky/pre-commit +0 -2
- package/.husky/pre-push +0 -2
- package/README.md +31 -29
- package/eslint.config.js +35 -11
- package/index.js +137 -204
- package/lib/common.js +13 -141
- package/package.json +21 -23
- package/test/configuration.spec.js +1038 -0
- package/test/testEnv.js +46 -0
- package/.nycrc +0 -4
package/lib/common.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const YES = 'yes';
|
|
2
2
|
const NO = 'no';
|
|
3
|
+
|
|
4
|
+
const NOT_SET = 'not set';
|
|
5
|
+
const DEBUG = 'debug';
|
|
3
6
|
const LOCAL = 'local';
|
|
4
7
|
|
|
5
8
|
const SUMOLOGIC = 'sumologic';
|
|
@@ -7,7 +10,6 @@ const AWS_S3 = 'awsS3';
|
|
|
7
10
|
const ALL = 'all';
|
|
8
11
|
const SET_ON = 'on';
|
|
9
12
|
const SET_OFF = 'off';
|
|
10
|
-
const NOT_SET = 'not set';
|
|
11
13
|
const NO_GENERIC = '--noGeneric--';
|
|
12
14
|
const NO_PUBLIC_PROVIDER = 'noPublic';
|
|
13
15
|
const ENV_VARIABLE = 'environment';
|
|
@@ -19,156 +21,25 @@ const SWAGGER_SEP = '_';
|
|
|
19
21
|
const CUSTOMER_CODE_SEP = '__';
|
|
20
22
|
const PRODUCTIONS = ['prod', 'production'];
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
const DEFAULT_LOCATION_PROVIDER = NO_PUBLIC_PROVIDER;
|
|
24
|
-
const DEFAULT_CLOUD_PROVIDER = 'noCloud';
|
|
25
|
-
const DEFAULT_CUSTOMER_CODE = '';
|
|
26
|
-
|
|
27
|
-
const DEFAULT_CACHE_IP = 'localhost:6379';
|
|
28
|
-
const DEFAULT_CACHE_CONNECTION_TIMEOUT = 30; // in seconds
|
|
29
|
-
const DEFAULT_CACHE_RECONNECTION_OFFSET = 5; // in seconds
|
|
30
|
-
const DEFAULT_CACHE_VALIDATION_CHECK = 1000; // in ms
|
|
31
|
-
const DEFAULT_CACHE_REQUEST_TTL = 10; // in seconds
|
|
32
|
-
const DEFAULT_CACHE_API_ID_TTL = 20; // in seconds
|
|
33
|
-
const DEFAULT_CACHE_API_OPTION_TTL = 5; // in seconds
|
|
34
|
-
|
|
35
|
-
const DEFAULT_REDIS_RECONNECT_TRIES = 100;
|
|
36
|
-
const DEFAULT_REDIS_RECONNECT_INTERVAL = 500; // in ms
|
|
37
|
-
const DEFAULT_REDIS_REQUEST_MAX_MEMORY = '10mb';
|
|
38
|
-
const DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY = 'allkeys-lru';
|
|
39
|
-
const DEFAULT_REDIS_SOCKET_KEEPALIVE = 5000;
|
|
40
|
-
const DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE = false;
|
|
41
|
-
|
|
42
|
-
const DEFAULT_AWS_REGION = '---noRegion--';
|
|
43
|
-
const DEFAULT_AWS_LOCAL_PROPERTIES = '169.254.169.254'; // to access properties of the instance on AWS
|
|
44
|
-
|
|
45
|
-
const DEFAULT_DYNAMODB_LOCAL_URL = 'http://localhost:8000';
|
|
46
|
-
const DEFAULT_DYNAMO_THROUGHPUT_READ = 1;
|
|
47
|
-
const DEFAULT_DYNAMO_THROUGHPUT_WRITE = 1;
|
|
48
|
-
const DEFAULT_DYNAMO_THROUGHPUT = 1;
|
|
49
|
-
|
|
50
|
-
const DEFAULT_MONGO_MAX_POOL_SIZE = 10;
|
|
51
|
-
const DEFAULT_MONGO_MIN_POOL_SIZE = 0;
|
|
52
|
-
const DEFAULT_MONGO_MAX_IDLE_TIME = 30000; // in ms
|
|
53
|
-
const DEFAULT_MONGO_SOCKET_TIMEOUT = 20000; // in ms
|
|
54
|
-
const DEFAULT_MONGO_FAMILY = 4; // 4 -> ipv4, 6 -> ipv6
|
|
55
|
-
const DEFAULT_MONGO_SERVER_SELECTION_TIMEOUT = 30000; // in ms
|
|
56
|
-
const DEFAULT_MONGO_HEARTBEAT_FREQUENCY = 10000; // in ms
|
|
57
|
-
|
|
58
|
-
const DEFAULT_DATABASE_IP = 'localhost';
|
|
59
|
-
const DEFAULT_DATABASE_USER = null;
|
|
60
|
-
const DEFAULT_DATABASE_PASSWORD = null;
|
|
61
|
-
const DEFAULT_DATABASE_CONNECTION_TIMEOUT = 30; // in seconds
|
|
62
|
-
const DEFAULT_DATABASE_RECONNECTION_OFFSET = 5; // in seconds
|
|
63
|
-
const DEFAULT_DATABASE_VALIDATION_CHECK = 1000; // in ms
|
|
64
|
-
|
|
65
|
-
const DEFAULT_ENCRYPTION_SET = SET_OFF;
|
|
66
|
-
const DEFAULT_KMS_PROVIDER = LOCAL;
|
|
24
|
+
const SUPPORTED_SWAGGER_FILE_PROVIDERS = ['bitbucket', 'swaggerhub'];
|
|
67
25
|
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const DEFAULT_USER_DEFINITIONS_FILE = NOT_SET;
|
|
74
|
-
|
|
75
|
-
const DEFAULT_S3_AWS_TIMEOUT = 5; // in minutes
|
|
76
|
-
const DEFAULT_S3_AWS_MAX_SIZE = 5; // in mB
|
|
77
|
-
const DEFAULT_S3_AWS_MAX_EVENTS = 1000;
|
|
78
|
-
|
|
79
|
-
const DEFAULT_SERVER_SECURITY_SET = SET_ON;
|
|
80
|
-
const DEFAULT_CLUSTER_MANAGEMENT = SET_OFF;
|
|
81
|
-
const DEFAULT_CACHE_SET = SET_OFF;
|
|
82
|
-
const DEFAULT_TOPIC_SET = SET_OFF;
|
|
83
|
-
const DEFAULT_REGISTRATION_SET = SET_ON;
|
|
84
|
-
const DEFAULT_REGISTRATION_AFTER_POSTOPS_SET = SET_OFF;
|
|
85
|
-
const DEFAULT_INTERCEPT_ERROR = SET_ON;
|
|
86
|
-
|
|
87
|
-
const DEFAULT_REGISTRATION_RETRY = 3000; // in ms
|
|
88
|
-
const DEFAULT_REQUEST_TIMEOUT = 10000; // in ms
|
|
89
|
-
|
|
90
|
-
const DEFAULT_SERVER_PUBLIC_PROTOCOL = 'http:';
|
|
91
|
-
const DEFAULT_SERVER_PUBLIC_DOMAIN_NAME = null;
|
|
92
|
-
|
|
93
|
-
const DEFAULT_ADMIN_EXTERNAL_ID = 'admin';
|
|
94
|
-
|
|
95
|
-
const DEFAULT_SWAGGER_DIR = '../api';
|
|
96
|
-
const DEFAULT_SWAGGER_FILE_PROVIDER = 'bitbucket';
|
|
97
|
-
const SUPPORTED_SWAGGER_FILE_PROVIDERS = [DEFAULT_SWAGGER_FILE_PROVIDER, 'swaggerhub'];
|
|
98
|
-
|
|
99
|
-
const DEFAULT_BITBUCKET_USERNAME = ' ';
|
|
100
|
-
const DEFAULT_BITBUCKET_PASSWORD = ' ';
|
|
26
|
+
const DECIMAL = 10;
|
|
27
|
+
const toInt = (value, fallback) => {
|
|
28
|
+
const parsed = parseInt(value, DECIMAL);
|
|
29
|
+
return Number.isNaN(parsed) ? fallback : parsed;
|
|
30
|
+
};
|
|
101
31
|
|
|
102
32
|
export {
|
|
103
33
|
ALL,
|
|
104
34
|
AWS_S3,
|
|
105
35
|
CUSTOMER_CODE_SEP,
|
|
106
|
-
|
|
107
|
-
DEFAULT_AWS_LOCAL_PROPERTIES,
|
|
108
|
-
DEFAULT_AWS_REGION,
|
|
109
|
-
DEFAULT_BITBUCKET_PASSWORD,
|
|
110
|
-
DEFAULT_BITBUCKET_USERNAME,
|
|
111
|
-
DEFAULT_CACHE_API_ID_TTL,
|
|
112
|
-
DEFAULT_CACHE_API_OPTION_TTL,
|
|
113
|
-
DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
114
|
-
DEFAULT_CACHE_IP,
|
|
115
|
-
DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
116
|
-
DEFAULT_CACHE_REQUEST_TTL,
|
|
117
|
-
DEFAULT_CACHE_SET,
|
|
118
|
-
DEFAULT_CACHE_VALIDATION_CHECK,
|
|
119
|
-
DEFAULT_CLOUD_PROVIDER,
|
|
120
|
-
DEFAULT_CLUSTER_MANAGEMENT,
|
|
121
|
-
DEFAULT_CUSTOMER_CODE,
|
|
122
|
-
DEFAULT_DATABASE_CONNECTION_TIMEOUT,
|
|
123
|
-
DEFAULT_DATABASE_IP,
|
|
124
|
-
DEFAULT_DATABASE_PASSWORD,
|
|
125
|
-
DEFAULT_DATABASE_RECONNECTION_OFFSET,
|
|
126
|
-
DEFAULT_DATABASE_USER,
|
|
127
|
-
DEFAULT_DATABASE_VALIDATION_CHECK,
|
|
128
|
-
DEFAULT_DYNAMODB_LOCAL_URL,
|
|
129
|
-
DEFAULT_DYNAMO_THROUGHPUT,
|
|
130
|
-
DEFAULT_DYNAMO_THROUGHPUT_READ,
|
|
131
|
-
DEFAULT_DYNAMO_THROUGHPUT_WRITE,
|
|
132
|
-
DEFAULT_ENCRYPTION_SET,
|
|
133
|
-
DEFAULT_ENV,
|
|
134
|
-
DEFAULT_EXIT_DELAY,
|
|
135
|
-
DEFAULT_FILTER_FILE,
|
|
136
|
-
DEFAULT_INTERCEPT_ERROR,
|
|
137
|
-
DEFAULT_KMS_PROVIDER,
|
|
138
|
-
DEFAULT_LOCATION_PROVIDER,
|
|
139
|
-
DEFAULT_LOG_LEVEL,
|
|
140
|
-
DEFAULT_MONGO_FAMILY,
|
|
141
|
-
DEFAULT_MONGO_HEARTBEAT_FREQUENCY,
|
|
142
|
-
DEFAULT_MONGO_MAX_IDLE_TIME,
|
|
143
|
-
DEFAULT_MONGO_MAX_POOL_SIZE,
|
|
144
|
-
DEFAULT_MONGO_MIN_POOL_SIZE,
|
|
145
|
-
DEFAULT_MONGO_SERVER_SELECTION_TIMEOUT,
|
|
146
|
-
DEFAULT_MONGO_SOCKET_TIMEOUT,
|
|
147
|
-
DEFAULT_NO_STACK,
|
|
148
|
-
DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE,
|
|
149
|
-
DEFAULT_REDIS_RECONNECT_INTERVAL,
|
|
150
|
-
DEFAULT_REDIS_RECONNECT_TRIES,
|
|
151
|
-
DEFAULT_REDIS_REQUEST_MAX_MEMORY,
|
|
152
|
-
DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY,
|
|
153
|
-
DEFAULT_REDIS_SOCKET_KEEPALIVE,
|
|
154
|
-
DEFAULT_REGISTRATION_AFTER_POSTOPS_SET,
|
|
155
|
-
DEFAULT_REGISTRATION_RETRY,
|
|
156
|
-
DEFAULT_REGISTRATION_SET,
|
|
157
|
-
DEFAULT_REQUEST_TIMEOUT,
|
|
158
|
-
DEFAULT_S3_AWS_MAX_EVENTS,
|
|
159
|
-
DEFAULT_S3_AWS_MAX_SIZE,
|
|
160
|
-
DEFAULT_S3_AWS_TIMEOUT,
|
|
161
|
-
DEFAULT_SERVER_PUBLIC_DOMAIN_NAME,
|
|
162
|
-
DEFAULT_SERVER_PUBLIC_PROTOCOL,
|
|
163
|
-
DEFAULT_SERVER_SECURITY_SET,
|
|
164
|
-
DEFAULT_SWAGGER_DIR,
|
|
165
|
-
DEFAULT_SWAGGER_FILE_PROVIDER,
|
|
166
|
-
DEFAULT_TOPIC_SET,
|
|
167
|
-
DEFAULT_USER_DEFINITIONS_FILE,
|
|
36
|
+
DEBUG,
|
|
168
37
|
ENV_VARIABLE,
|
|
38
|
+
LOCAL,
|
|
169
39
|
MONGO_BASE_URL,
|
|
170
40
|
MONGO_BASE_URL_SRV,
|
|
171
41
|
NO,
|
|
42
|
+
NOT_SET,
|
|
172
43
|
NO_GENERIC,
|
|
173
44
|
NO_PUBLIC_PROVIDER,
|
|
174
45
|
PRODUCTIONS,
|
|
@@ -180,4 +51,5 @@ export {
|
|
|
180
51
|
SWAGGER_EXT,
|
|
181
52
|
SWAGGER_SEP,
|
|
182
53
|
YES,
|
|
54
|
+
toInt,
|
|
183
55
|
};
|
package/package.json
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/configuration",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.8",
|
|
4
4
|
"description": "Common configuration for mimik services",
|
|
5
5
|
"main": "./index.js",
|
|
6
|
+
"exports": "./index.js",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"lint": "eslint . --no-error-on-unmatched-pattern",
|
|
9
10
|
"docs": "jsdoc2md index.js > README.md",
|
|
10
|
-
"test": "
|
|
11
|
-
"test-ci": "
|
|
11
|
+
"test": "mocha --reporter mochawesome --bail --exit test/",
|
|
12
|
+
"test-ci": "c8 --reporter=lcov --reporter=text npm test",
|
|
12
13
|
"prepublishOnly": "npm run docs && npm run lint && npm run test-ci",
|
|
13
14
|
"commit-ready": "npm run docs && npm run lint && npm run test-ci"
|
|
14
15
|
},
|
|
15
|
-
"husky": {
|
|
16
|
-
"hooks": {
|
|
17
|
-
"pre-commit": "npm run commit-ready",
|
|
18
|
-
"pre-push": "npm run test"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
16
|
"keywords": [
|
|
22
17
|
"mimik",
|
|
23
18
|
"microservice",
|
|
@@ -25,30 +20,33 @@
|
|
|
25
20
|
],
|
|
26
21
|
"author": "mimik technology inc <support@mimik.com> (https://developer.mimik.com/)",
|
|
27
22
|
"license": "MIT",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=24"
|
|
25
|
+
},
|
|
28
26
|
"repository": {
|
|
29
27
|
"type": "git",
|
|
30
28
|
"url": "https://bitbucket.org/mimiktech/configuration"
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
|
-
"@mimik/request-helper": "^2.0.
|
|
34
|
-
"@mimik/sumologic-winston-logger": "^2.1.
|
|
31
|
+
"@mimik/request-helper": "^2.0.5",
|
|
32
|
+
"@mimik/sumologic-winston-logger": "^2.1.13",
|
|
35
33
|
"@mimik/user-filters": "^2.0.4",
|
|
36
|
-
"ip": "2.0.1"
|
|
37
|
-
"lodash.includes": "4.3.0",
|
|
38
|
-
"lodash.isnan": "3.0.2",
|
|
39
|
-
"lodash.isnil": "4.0.0",
|
|
40
|
-
"lodash.isstring": "4.0.1",
|
|
41
|
-
"lodash.isundefined": "3.0.1",
|
|
42
|
-
"lodash.split": "4.4.2",
|
|
43
|
-
"uuid": "11.1.0"
|
|
34
|
+
"ip": "2.0.1"
|
|
44
35
|
},
|
|
45
36
|
"devDependencies": {
|
|
46
|
-
"@eslint/js": "9.
|
|
37
|
+
"@eslint/js": "9.39.3",
|
|
47
38
|
"@mimik/eslint-plugin-document-env": "^2.0.8",
|
|
48
|
-
"@stylistic/eslint-plugin": "5.
|
|
49
|
-
"
|
|
39
|
+
"@stylistic/eslint-plugin": "5.9.0",
|
|
40
|
+
"c8": "11.0.0",
|
|
41
|
+
"chai": "6.2.2",
|
|
42
|
+
"eslint": "9.39.3",
|
|
50
43
|
"eslint-plugin-import": "2.32.0",
|
|
44
|
+
"esmock": "2.7.3",
|
|
45
|
+
"globals": "17.3.0",
|
|
51
46
|
"husky": "9.1.7",
|
|
52
|
-
"
|
|
47
|
+
"mocha": "11.7.5",
|
|
48
|
+
"mochawesome": "7.1.4",
|
|
49
|
+
"jsdoc-to-markdown": "9.1.3",
|
|
50
|
+
"sinon": "21.0.1"
|
|
53
51
|
}
|
|
54
52
|
}
|