@rnw-community/nestjs-typed-config 0.30.0 → 0.32.1
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.
|
@@ -1,49 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
7
|
};
|
|
8
|
+
var NestJSTypedConfigModule_1;
|
|
23
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
10
|
exports.NestJSTypedConfigModule = void 0;
|
|
25
11
|
// eslint-disable-next-line max-classes-per-file
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function NestJSTypedConfigModule() {
|
|
31
|
-
}
|
|
32
|
-
NestJSTypedConfigModule_1 = NestJSTypedConfigModule;
|
|
12
|
+
const common_1 = require("@nestjs/common");
|
|
13
|
+
const config_1 = require("@nestjs/config");
|
|
14
|
+
const nest_js_typed_config_service_1 = require("./nest-js-typed-config.service");
|
|
15
|
+
let NestJSTypedConfigModule = NestJSTypedConfigModule_1 = class NestJSTypedConfigModule {
|
|
33
16
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
39
|
-
}
|
|
40
|
-
return Service;
|
|
41
|
-
}(nest_js_typed_config_service_1.NestJSTypedConfigService));
|
|
42
|
-
var CustomConfigModule = {
|
|
17
|
+
static create(validationSchema) {
|
|
18
|
+
class Service extends nest_js_typed_config_service_1.NestJSTypedConfigService {
|
|
19
|
+
}
|
|
20
|
+
const CustomConfigModule = {
|
|
43
21
|
imports: [
|
|
44
22
|
config_1.ConfigModule.forRoot({
|
|
45
23
|
cache: true,
|
|
46
|
-
validationSchema
|
|
24
|
+
validationSchema,
|
|
47
25
|
validationOptions: { abortEarly: false },
|
|
48
26
|
isGlobal: true,
|
|
49
27
|
}),
|
|
@@ -54,12 +32,10 @@ var NestJSTypedConfigModule = /** @class */ (function () {
|
|
|
54
32
|
global: true,
|
|
55
33
|
};
|
|
56
34
|
return [CustomConfigModule, Service];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return NestJSTypedConfigModule;
|
|
63
|
-
}());
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
NestJSTypedConfigModule = NestJSTypedConfigModule_1 = __decorate([
|
|
38
|
+
(0, common_1.Module)({})
|
|
39
|
+
], NestJSTypedConfigModule);
|
|
64
40
|
exports.NestJSTypedConfigModule = NestJSTypedConfigModule;
|
|
65
41
|
//# sourceMappingURL=nest-js-typed-config.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest-js-typed-config.module.js","sourceRoot":"","sources":["../src/nest-js-typed-config.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nest-js-typed-config.module.js","sourceRoot":"","sources":["../src/nest-js-typed-config.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,gDAAgD;AAChD,2CAAwC;AACxC,2CAA8C;AAE9C,iFAA0E;AAM1E,IAAa,uBAAuB,+BAApC,MAAa,uBAAuB;IAChC,wDAAwD;IACxD,MAAM,CAAC,MAAM,CACT,gBAAqC;QAErC,MAAM,OAAQ,SAAQ,uDAA2D;SAAG;QAEpF,MAAM,kBAAkB,GAAkB;YACtC,OAAO,EAAE;gBACL,qBAAY,CAAC,OAAO,CAAC;oBACjB,KAAK,EAAE,IAAI;oBACX,gBAAgB;oBAChB,iBAAiB,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;oBACxC,QAAQ,EAAE,IAAI;iBACjB,CAAC;aACL;YACD,SAAS,EAAE,CAAC,OAAO,CAAC;YACpB,OAAO,EAAE,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,yBAAuB;YAC/B,MAAM,EAAE,IAAI;SACf,CAAC;QAEF,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACJ,CAAA;AAxBY,uBAAuB;IADnC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,uBAAuB,CAwBnC;AAxBY,0DAAuB"}
|
|
@@ -8,62 +8,60 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var NestJSTypedConfigService_1;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
13
|
exports.NestJSTypedConfigService = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const config_1 = require("@nestjs/config");
|
|
17
|
+
const shared_1 = require("@rnw-community/shared");
|
|
17
18
|
/* eslint-disable class-methods-use-this */
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
let NestJSTypedConfigService = NestJSTypedConfigService_1 = class NestJSTypedConfigService {
|
|
20
|
+
constructor(config) {
|
|
20
21
|
this.config = config;
|
|
21
22
|
this.envCache = new Map();
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
NestJSTypedConfigService.prototype.get = function (envVariable) {
|
|
24
|
+
get(envVariable) {
|
|
25
25
|
if (this.envCache.has(envVariable)) {
|
|
26
|
-
|
|
27
|
-
common_1.Logger.debug(
|
|
26
|
+
const value = this.envCache.get(envVariable);
|
|
27
|
+
common_1.Logger.debug(`Using env variable "${envVariable}" from cache`, NestJSTypedConfigService_1.name);
|
|
28
28
|
return value;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
const variableValue = this.config.get(envVariable);
|
|
31
31
|
if (envVariable.includes('_FILE')) {
|
|
32
|
-
|
|
32
|
+
const fileEnvValue = this.handleFileEnvVariable(envVariable, variableValue);
|
|
33
33
|
this.envCache.set(envVariable, fileEnvValue);
|
|
34
34
|
return fileEnvValue;
|
|
35
35
|
}
|
|
36
36
|
this.envCache.set(envVariable, variableValue);
|
|
37
|
-
common_1.Logger.debug(
|
|
37
|
+
common_1.Logger.debug(`Using env variable "${envVariable}"`, NestJSTypedConfigService_1.name);
|
|
38
38
|
return variableValue;
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
}
|
|
40
|
+
handleFileEnvVariable(envVariable, filePath) {
|
|
41
41
|
if ((0, shared_1.isNotEmptyString)(filePath)) {
|
|
42
|
-
common_1.Logger.debug(
|
|
42
|
+
common_1.Logger.debug(`Using env variable "${envVariable}" from file "${filePath}"`, NestJSTypedConfigService_1.name);
|
|
43
43
|
return this.readFileEnvFromFS(envVariable, filePath);
|
|
44
44
|
}
|
|
45
45
|
return this.readFileEnvFromEnvironment(envVariable);
|
|
46
|
-
}
|
|
47
|
-
|
|
46
|
+
}
|
|
47
|
+
readFileEnvFromEnvironment(envVariable) {
|
|
48
48
|
/* eslint-disable @typescript-eslint/non-nullable-type-assertion-style */
|
|
49
|
-
|
|
50
|
-
common_1.Logger.debug(
|
|
49
|
+
const value = this.config.get(envVariable.replace('_FILE', ''));
|
|
50
|
+
common_1.Logger.debug(`Using env variable "${envVariable}" from environment "${value}"`, NestJSTypedConfigService_1.name);
|
|
51
51
|
return value;
|
|
52
|
-
}
|
|
53
|
-
|
|
52
|
+
}
|
|
53
|
+
readFileEnvFromFS(envVariable, variableValue) {
|
|
54
54
|
if (!(0, fs_1.existsSync)(variableValue)) {
|
|
55
|
-
throw new Error(
|
|
55
|
+
throw new Error(`Could not read file "${envVariable}"`);
|
|
56
56
|
}
|
|
57
57
|
return (0, fs_1.readFileSync)(variableValue)
|
|
58
58
|
.toString()
|
|
59
59
|
.trim();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return NestJSTypedConfigService;
|
|
67
|
-
}());
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
NestJSTypedConfigService = NestJSTypedConfigService_1 = __decorate([
|
|
63
|
+
(0, common_1.Injectable)(),
|
|
64
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
65
|
+
], NestJSTypedConfigService);
|
|
68
66
|
exports.NestJSTypedConfigService = NestJSTypedConfigService;
|
|
69
67
|
//# sourceMappingURL=nest-js-typed-config.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest-js-typed-config.service.js","sourceRoot":"","sources":["../src/nest-js-typed-config.service.ts"],"names":[],"m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EAAC,QAAQ,CAAC,EAAE;YAC5B,eAAM,CAAC,KAAK,CAAC,uBAAuB,WAAW,gBAAgB,QAAQ,GAAG,EAAE,0BAAwB,CAAC,IAAI,CAAC,CAAC;YAE3G,OAAO,IAAI,CAAC,iBAAiB,CAAI,WAAW,EAAE,QAAQ,CAAC,CAAC;SAC3D;QAED,OAAO,IAAI,CAAC,0BAA0B,CAAI,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEO,0BAA0B,CAAoB,WAAc;QAChE,yEAAyE;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAM,CAAyB,CAAC;QAE7F,eAAM,CAAC,KAAK,CACR,uBAAuB,WAAW,uBAAuB,KAAe,GAAG,EAC3E,0BAAwB,CAAC,IAAI,CAChC,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,iBAAiB,CAAoB,WAAc,EAAE,aAAmC;QAC5F,IAAI,CAAC,IAAA,eAAU,EAAC,aAAuB,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,GAAG,CAAC,CAAC;SAC3D;QAED,OAAO,IAAA,iBAAY,EAAC,aAAuB,CAAC;aACvC,QAAQ,EAAE;aACV,IAAI,EAA0B,CAAC;IACxC,CAAC;CACJ,CAAA;AA/DY,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAQ4B,sBAAa;GAPzC,wBAAwB,CA+DpC;AA/DY,4DAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnw-community/nestjs-typed-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NestJS typed config",
|
|
6
6
|
"keywords": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=14.0.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "0709e0937b28f3bac24b11de5d43f195b8c68c36",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@rnw-community/shared": "^0.8.0"
|
|
41
41
|
},
|