nest-typed-config
Advanced tools
Comparing version 2.4.5 to 2.4.6
@@ -23,2 +23,7 @@ import type { OptionsSync } from 'cosmiconfig'; | ||
ignoreEnvironmentVariableSubstitution?: boolean; | ||
/** | ||
* If "true", disallow undefined environment variables. | ||
* Default: true | ||
*/ | ||
disallowUndefinedEnvironmentVariables?: boolean; | ||
} | ||
@@ -25,0 +30,0 @@ /** |
@@ -51,3 +51,3 @@ "use strict"; | ||
*/ | ||
const placeholderResolver = (template, data) => { | ||
const placeholderResolver = (template, data, disallowUndefinedEnvironmentVariables) => { | ||
const replace = (placeholder, key) => { | ||
@@ -58,3 +58,3 @@ let value = data; | ||
} | ||
if (!value) { | ||
if (!value && disallowUndefinedEnvironmentVariables) { | ||
throw new Error(`Environment variable is not set for variable name: '${key}'`); | ||
@@ -86,3 +86,3 @@ } | ||
return () => { | ||
var _a; | ||
var _a, _b; | ||
const { searchPlaces, searchFrom } = getSearchOptions(options); | ||
@@ -98,3 +98,3 @@ const loaders = Object.assign({ '.toml': loadToml }, options.loaders); | ||
if (!((_a = options.ignoreEnvironmentVariableSubstitution) !== null && _a !== void 0 ? _a : true)) { | ||
const replacedConfig = placeholderResolver(JSON.stringify(result.config), process.env); | ||
const replacedConfig = placeholderResolver(JSON.stringify(result.config), process.env, (_b = options.disallowUndefinedEnvironmentVariables) !== null && _b !== void 0 ? _b : true); | ||
config = JSON.parse(replacedConfig); | ||
@@ -101,0 +101,0 @@ } |
@@ -44,2 +44,7 @@ import type { OptionsSync } from 'cosmiconfig'; | ||
ignoreEnvironmentVariableSubstitution?: boolean; | ||
/** | ||
* If "true", disallow undefined environment variables. | ||
* Default: true | ||
*/ | ||
disallowUndefinedEnvironmentVariables?: boolean; | ||
} | ||
@@ -83,2 +88,3 @@ | ||
data: Record<string, any>, | ||
disallowUndefinedEnvironmentVariables: boolean, | ||
): string => { | ||
@@ -91,3 +97,3 @@ const replace = (placeholder: any, key: string) => { | ||
if (!value) { | ||
if (!value && disallowUndefinedEnvironmentVariables) { | ||
throw new Error( | ||
@@ -153,2 +159,3 @@ `Environment variable is not set for variable name: '${key}'`, | ||
process.env, | ||
options.disallowUndefinedEnvironmentVariables ?? true, | ||
); | ||
@@ -155,0 +162,0 @@ config = JSON.parse(replacedConfig); |
{ | ||
"name": "nest-typed-config", | ||
"version": "2.4.5", | ||
"version": "2.4.6", | ||
"description": "Intuitive, type-safe configuration module for Nest framework", | ||
@@ -53,3 +53,3 @@ "author": "Nikaple Zhou", | ||
"@nestjs/axios": "0.1.0", | ||
"@nestjs/cli": "9.0.0", | ||
"@nestjs/cli": "9.1.1", | ||
"@nestjs/common": "9.0.11", | ||
@@ -66,4 +66,4 @@ "@nestjs/core": "9.0.11", | ||
"@types/node": "16.11.56", | ||
"@typescript-eslint/eslint-plugin": "5.34.0", | ||
"@typescript-eslint/parser": "5.34.0", | ||
"@typescript-eslint/eslint-plugin": "5.36.1", | ||
"@typescript-eslint/parser": "5.36.1", | ||
"cosmiconfig": "7.0.1", | ||
@@ -86,4 +86,4 @@ "dotenv": "10.0.0", | ||
"ts-jest": "27.1.5", | ||
"typedoc": "0.23.10", | ||
"typescript": "4.7.4", | ||
"typedoc": "0.23.12", | ||
"typescript": "4.8.2", | ||
"yaml": "1.10.2" | ||
@@ -90,0 +90,0 @@ }, |
@@ -359,2 +359,7 @@ <h1 align="center">Nest-Typed-Config</h1> | ||
ignoreEnvironmentVariableSubstitution?: boolean; | ||
/** | ||
* If "true", disallow undefined environment variables. | ||
* Default: true | ||
*/ | ||
disallowUndefinedEnvironmentVariables?: boolean; | ||
} | ||
@@ -361,0 +366,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
103155
1669
727