@mimik/configuration 4.4.8 → 4.4.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/README.md +1 -0
- package/index.js +26 -0
- package/lib/common.js +5 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ The following environement variables are being used for the configuration:
|
|
|
82
82
|
| LOG_MODE | collector the be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`, 'awsKinesis'
|
|
83
83
|
| NO_STACK | disable the inclusion of a the stack in all logs | yes | logInfo.noStack
|
|
84
84
|
| FILTER_FILE | path for the filter file definition | null | logInfo.filterFile |
|
|
85
|
+
| USER_DEFINITIONS_FILE | path for the custom user definitions | null | userDefinitions.file |
|
|
85
86
|
| EXIT_DELAY | delay to allow the log transports to flush | 2000 | logInfo.exitDelay | in milliseconds
|
|
86
87
|
| CLUSTER_MANAGEMENT | switch to enable cluster communication | off | cluster.management | can be `on` or `off`
|
|
87
88
|
| REQUEST_TIMEOUT | timeout for intra cluster http request | 10000 | cluster.timeout | in milliseconds
|
package/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/* eslint no-process-env: "off" */
|
|
2
2
|
const _ = require('lodash');
|
|
3
|
+
const fs = require('fs');
|
|
3
4
|
const ip = require('ip');
|
|
4
5
|
const uuid = require('uuid');
|
|
5
6
|
const querystring = require('querystring');
|
|
6
7
|
|
|
7
8
|
const logger = require('@mimik/sumologic-winston-logger');
|
|
8
9
|
const { getCorrelationId } = require('@mimik/request-helper');
|
|
10
|
+
const { userDefinitions } = require('@mimik/user-filters');
|
|
9
11
|
/**
|
|
10
12
|
* @module configuration
|
|
11
13
|
* @example
|
|
@@ -70,6 +72,7 @@ const {
|
|
|
70
72
|
DEFAULT_FILTER_FILE,
|
|
71
73
|
DEFAULT_EXIT_DELAY,
|
|
72
74
|
DEFAULT_NO_STACK,
|
|
75
|
+
DEFAULT_USER_DEFINITIONS_FILE,
|
|
73
76
|
DEFAULT_S3_AWS_TIMEOUT,
|
|
74
77
|
DEFAULT_S3_AWS_MAX_SIZE,
|
|
75
78
|
DEFAULT_S3_AWS_MAX_EVENTS,
|
|
@@ -302,6 +305,22 @@ const setupEncryption = (encryptionOpts) => {
|
|
|
302
305
|
return encryptionConfig;
|
|
303
306
|
};
|
|
304
307
|
|
|
308
|
+
const setupUserDefinitions = (definitions) => {
|
|
309
|
+
const userDefinitionsFile = definitions.file;
|
|
310
|
+
let customDefinitions = {};
|
|
311
|
+
if (userDefinitionsFile && userDefinitionsFile !== DEFAULT_USER_DEFINITIONS_FILE) {
|
|
312
|
+
try { customDefinitions = JSON.parse(fs.readFileSync(userDefinitionsFile).toString()); }
|
|
313
|
+
catch (err) {
|
|
314
|
+
throw new Error(`Invalid file for user definitions: ${userDefinitionsFile}, error: ${err.message}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
...userDefinitions,
|
|
319
|
+
...customDefinitions,
|
|
320
|
+
file: userDefinitionsFile,
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
|
|
305
324
|
const checkConfig = (config) => {
|
|
306
325
|
const errors = [];
|
|
307
326
|
|
|
@@ -397,6 +416,9 @@ const configuration = {
|
|
|
397
416
|
encryption: {
|
|
398
417
|
set: process.env.ENCRYPTION_SET || DEFAULT_ENCRYPTION_SET,
|
|
399
418
|
},
|
|
419
|
+
userDefinitions: {
|
|
420
|
+
file: process.env.USER_DEFINITIONS_FILE || DEFAULT_USER_DEFINITIONS_FILE,
|
|
421
|
+
},
|
|
400
422
|
topic: {
|
|
401
423
|
set: process.env.TOPIC_SET || DEFAULT_TOPIC_SET,
|
|
402
424
|
},
|
|
@@ -482,6 +504,7 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
482
504
|
* | LOG_MODE | collector the be used to log events | sumologic | logInfo.mode | can be `sumologic`, `awsS3`, `all`, 'awsKinesis'
|
|
483
505
|
* | NO_STACK | disable the inclusion of a the stack in all logs | yes | logInfo.noStack
|
|
484
506
|
* | FILTER_FILE | path for the filter file definition | null | logInfo.filterFile |
|
|
507
|
+
* | USER_DEFINITIONS_FILE | path for the custom user definitions | null | userDefinitions.file |
|
|
485
508
|
* | EXIT_DELAY | delay to allow the log transports to flush | 2000 | logInfo.exitDelay | in milliseconds
|
|
486
509
|
* | CLUSTER_MANAGEMENT | switch to enable cluster communication | off | cluster.management | can be `on` or `off`
|
|
487
510
|
* | REQUEST_TIMEOUT | timeout for intra cluster http request | 10000 | cluster.timeout | in milliseconds
|
|
@@ -661,6 +684,9 @@ const setConfig = (pack, options) => {
|
|
|
661
684
|
if (options.encryption && configuration.encryption.set === SET_ON) {
|
|
662
685
|
configuration.encryption = setupEncryption(options.encryption);
|
|
663
686
|
}
|
|
687
|
+
if (options.userDefinitions) {
|
|
688
|
+
configuration.userDefinitions = setupUserDefinitions(options.userDefinitions);
|
|
689
|
+
}
|
|
664
690
|
if (options.dependencies) {
|
|
665
691
|
Object.keys(options.dependencies).forEach((dependency) => {
|
|
666
692
|
if (isMSTSet) {
|
package/lib/common.js
CHANGED
|
@@ -3,6 +3,7 @@ const AWS_S3 = 'awsS3';
|
|
|
3
3
|
const ALL = 'all';
|
|
4
4
|
const SET_ON = 'on';
|
|
5
5
|
const SET_OFF = 'off';
|
|
6
|
+
const NOT_SET = 'not set';
|
|
6
7
|
const NO_GENERIC = '--noGeneric--';
|
|
7
8
|
const NO_PUBLIC_PROVIDER = 'noPublic';
|
|
8
9
|
const ENV_VARIABLE = 'environment';
|
|
@@ -61,10 +62,12 @@ const DEFAULT_ENCRYPTION_SET = SET_OFF;
|
|
|
61
62
|
const DEFAULT_KMS_PROVIDER = 'local';
|
|
62
63
|
|
|
63
64
|
const DEFAULT_LOG_LEVEL = 'debug';
|
|
64
|
-
const DEFAULT_FILTER_FILE =
|
|
65
|
+
const DEFAULT_FILTER_FILE = NOT_SET;
|
|
65
66
|
const DEFAULT_EXIT_DELAY = 2000; // in ms
|
|
66
67
|
const DEFAULT_NO_STACK = 'yes';
|
|
67
68
|
|
|
69
|
+
const DEFAULT_USER_DEFINITIONS_FILE = NOT_SET;
|
|
70
|
+
|
|
68
71
|
const DEFAULT_S3_AWS_TIMEOUT = 5; // in minutes
|
|
69
72
|
const DEFAULT_S3_AWS_MAX_SIZE = 5; // in mB
|
|
70
73
|
const DEFAULT_S3_AWS_MAX_EVENTS = 1000;
|
|
@@ -144,6 +147,7 @@ module.exports = {
|
|
|
144
147
|
DEFAULT_FILTER_FILE,
|
|
145
148
|
DEFAULT_EXIT_DELAY,
|
|
146
149
|
DEFAULT_NO_STACK,
|
|
150
|
+
DEFAULT_USER_DEFINITIONS_FILE,
|
|
147
151
|
DEFAULT_S3_AWS_TIMEOUT,
|
|
148
152
|
DEFAULT_S3_AWS_MAX_SIZE,
|
|
149
153
|
DEFAULT_S3_AWS_MAX_EVENTS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/configuration",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.9",
|
|
4
4
|
"description": "Common configuration for mimik services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@mimik/request-helper": "^1.7.3",
|
|
33
33
|
"@mimik/sumologic-winston-logger": "^1.6.6",
|
|
34
|
+
"@mimik/user-filters": "1.3.3",
|
|
34
35
|
"ip": "1.1.5",
|
|
35
36
|
"lodash": "4.17.21",
|
|
36
37
|
"uuid": "8.3.2"
|
|
@@ -38,17 +39,17 @@
|
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@mimik/eslint-plugin-dependencies": "^2.4.1",
|
|
40
41
|
"@mimik/eslint-plugin-document-env": "^1.0.1",
|
|
41
|
-
"eslint": "8.
|
|
42
|
+
"eslint": "8.13.0",
|
|
42
43
|
"eslint-config-airbnb": "18.2.1",
|
|
43
|
-
"eslint-plugin-import": "2.
|
|
44
|
+
"eslint-plugin-import": "2.26.0",
|
|
44
45
|
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
45
|
-
"eslint-plugin-react": "7.
|
|
46
|
-
"eslint-plugin-react-hooks": "4.
|
|
46
|
+
"eslint-plugin-react": "7.29.4",
|
|
47
|
+
"eslint-plugin-react-hooks": "4.4.0",
|
|
47
48
|
"fancy-log": "2.0.0",
|
|
48
49
|
"gulp": "4.0.2",
|
|
49
50
|
"gulp-eslint": "6.0.0",
|
|
50
51
|
"gulp-git": "2.10.1",
|
|
51
52
|
"husky": "7.0.4",
|
|
52
|
-
"jsdoc-to-markdown": "7.1.
|
|
53
|
+
"jsdoc-to-markdown": "7.1.1"
|
|
53
54
|
}
|
|
54
55
|
}
|