nestjs-config-extended 1.2.0 → 1.2.2
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
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<div>
|
|
10
|
-
<img src="https://visitor-badge.glitch.me/badge?page_id=pedrosodre.nestjs-config-extended" alt="Visitor count" />
|
|
11
10
|
<img src="https://img.shields.io/github/package-json/v/pedrosodre/nestjs-config-extended" alt="Module Version" />
|
|
12
11
|
<img src="https://sonarcloud.io/api/project_badges/measure?project=nestjs-config-extended&metric=alert_status" alt="SonarCloud Alert Status">
|
|
13
12
|
<img src="https://sonarcloud.io/api/project_badges/measure?project=nestjs-config-extended&metric=security_rating" alt="SonarCloud Security Rating">
|
|
@@ -36,9 +36,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
36
36
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
39
|
var ExtendedConfigModule_1;
|
|
43
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
41
|
exports.ExtendedConfigModule = void 0;
|
|
@@ -47,7 +44,7 @@ const config_constants_1 = require("./config.constants");
|
|
|
47
44
|
const extended_config_service_1 = require("./extended-config.service");
|
|
48
45
|
const cron = __importStar(require("node-cron"));
|
|
49
46
|
const loader_util_1 = require("./util/loader.util");
|
|
50
|
-
const
|
|
47
|
+
const object_util_1 = require("./util/object.util");
|
|
51
48
|
let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
|
|
52
49
|
constructor(extendedConfigService) {
|
|
53
50
|
this.extendedConfigService = extendedConfigService;
|
|
@@ -62,11 +59,11 @@ let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
|
|
|
62
59
|
if (!disable) {
|
|
63
60
|
const variables = yield loader_util_1.retrieveVariablesByStrategy(strategy);
|
|
64
61
|
if (registerAs) {
|
|
65
|
-
|
|
62
|
+
object_util_1.setOn(preLoadedVariables, registerAs, variables);
|
|
66
63
|
}
|
|
67
64
|
else {
|
|
68
65
|
Object.keys(variables).forEach((key) => {
|
|
69
|
-
|
|
66
|
+
object_util_1.setOn(preLoadedVariables, key, variables[key]);
|
|
70
67
|
});
|
|
71
68
|
}
|
|
72
69
|
}
|
|
@@ -36,7 +36,7 @@ const common_1 = require("@nestjs/common");
|
|
|
36
36
|
const util_1 = require("util");
|
|
37
37
|
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
38
38
|
const lodash_has_1 = __importDefault(require("lodash.has"));
|
|
39
|
-
const
|
|
39
|
+
const object_util_1 = require("./util/object.util");
|
|
40
40
|
const config_constants_1 = require("./config.constants");
|
|
41
41
|
const exceptions_1 = require("./exceptions");
|
|
42
42
|
const loader_util_1 = require("./util/loader.util");
|
|
@@ -141,10 +141,10 @@ let ExtendedConfigService = class ExtendedConfigService {
|
|
|
141
141
|
}
|
|
142
142
|
set(propertyPath, value) {
|
|
143
143
|
if (this.isCacheEnabled) {
|
|
144
|
-
|
|
144
|
+
object_util_1.setOn(this.cache, propertyPath, value);
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
|
-
|
|
147
|
+
object_util_1.setOn(process.env, propertyPath, value);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
get isCacheEnabled() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setOn: <T extends Record<string, unknown> = Record<string, unknown>>(obj: Record<keyof T, unknown>, path: number | symbol | string | string[], value: unknown) => Record<keyof T, unknown>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setOn = void 0;
|
|
4
|
+
const setOn = (obj, path, value) => {
|
|
5
|
+
const validPathCharactersRegex = /([^[.\]])+/g;
|
|
6
|
+
const pathArray = Array.isArray(path)
|
|
7
|
+
? path
|
|
8
|
+
: String(path).match(validPathCharactersRegex);
|
|
9
|
+
if (!pathArray)
|
|
10
|
+
return obj;
|
|
11
|
+
let nestedObj = obj;
|
|
12
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
13
|
+
const key = pathArray[i];
|
|
14
|
+
if (nestedObj[key] === undefined) {
|
|
15
|
+
const isIndex = isNaN(Number(pathArray[i + 1]));
|
|
16
|
+
nestedObj[key] = isIndex ? {} : [];
|
|
17
|
+
}
|
|
18
|
+
if (i === pathArray.length - 1) {
|
|
19
|
+
nestedObj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
nestedObj = nestedObj[key];
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
};
|
|
25
|
+
exports.setOn = setOn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-config-extended",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Extended Configuration Module for Nest to load environment variables package",
|
|
5
5
|
"author": "Pedro Sodré",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,16 +26,15 @@
|
|
|
26
26
|
"lodash.get": "4.4.2",
|
|
27
27
|
"lodash.has": "4.5.2",
|
|
28
28
|
"lodash.isfunction": "^3.0.9",
|
|
29
|
-
"lodash.set": "4.3.2",
|
|
30
29
|
"node-cron": "^2.0.3",
|
|
31
30
|
"rxjs": "^7.2.0",
|
|
32
31
|
"uuid": "8.3.2"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@nestjs/common": "^9.
|
|
36
|
-
"@nestjs/core": "^9.
|
|
37
|
-
"@nestjs/platform-express": "^9.
|
|
38
|
-
"@nestjs/testing": "^9.
|
|
34
|
+
"@nestjs/common": "^9.4.3",
|
|
35
|
+
"@nestjs/core": "^9.4.3",
|
|
36
|
+
"@nestjs/platform-express": "^9.4.3",
|
|
37
|
+
"@nestjs/testing": "^9.4.3",
|
|
39
38
|
"@types/jest": "^26.0.20",
|
|
40
39
|
"@types/lodash.get": "4.4.6",
|
|
41
40
|
"@types/lodash.has": "4.5.6",
|
|
@@ -50,14 +49,14 @@
|
|
|
50
49
|
"prettier": "2.2.1",
|
|
51
50
|
"reflect-metadata": "0.1.13",
|
|
52
51
|
"rimraf": "3.0.2",
|
|
52
|
+
"semantic-release": "^19.0.3",
|
|
53
53
|
"ts-jest": "26.4.4",
|
|
54
54
|
"tslint": "^6.1.3",
|
|
55
|
-
"typescript": "4.1.3"
|
|
56
|
-
"semantic-release": "^19.0.3"
|
|
55
|
+
"typescript": "4.1.3"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
|
-
"@nestjs/common": "^8.0.0 || ^9.0.0",
|
|
60
|
-
"@nestjs/core": "^8.0.0 || ^9.0.0",
|
|
58
|
+
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
59
|
+
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
61
60
|
"reflect-metadata": "^0.1.12",
|
|
62
61
|
"rxjs": "^7.2.0"
|
|
63
62
|
},
|