@nestjs/config
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -55,2 +55,34 @@ import { NoInferType, Path, PathValue } from './types'; | ||
get<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, defaultValue: NoInferType<R>, options: ConfigGetOptions): R; | ||
/** | ||
* Get a configuration value (either custom configuration or process environment variable) | ||
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host"). | ||
* @param propertyPath | ||
*/ | ||
getOrThrow<T = any>(propertyPath: KeyOf<K>): Exclude<T, undefined>; | ||
/** | ||
* Get a configuration value (either custom configuration or process environment variable) | ||
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host"). | ||
* @param propertyPath | ||
* @param options | ||
*/ | ||
getOrThrow<T = K, P extends Path<T> = any>(propertyPath: P, options: ConfigGetOptions): Exclude<T, undefined>; | ||
/** | ||
* Get a configuration value (either custom configuration or process environment variable) | ||
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host"). | ||
* It returns a default value if the key does not exist. | ||
* If the default value is undefined an exception will be thrown. | ||
* @param propertyPath | ||
* @param defaultValue | ||
*/ | ||
getOrThrow<T = any>(propertyPath: KeyOf<K>, defaultValue: NoInferType<T>): Exclude<T, undefined>; | ||
/** | ||
* Get a configuration value (either custom configuration or process environment variable) | ||
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host"). | ||
* It returns a default value if the key does not exist. | ||
* If the default value is undefined an exception will be thrown. | ||
* @param propertyPath | ||
* @param defaultValue | ||
* @param options | ||
*/ | ||
getOrThrow<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, defaultValue: NoInferType<R>, options: ConfigGetOptions): Exclude<R, undefined>; | ||
private getFromCache; | ||
@@ -57,0 +89,0 @@ private getFromValidatedEnv; |
@@ -57,2 +57,18 @@ "use strict"; | ||
} | ||
/** | ||
* Get a configuration value (either custom configuration or process environment variable) | ||
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host"). | ||
* It returns a default value if the key does not exist. | ||
* If the default value is undefined an exception will be thrown. | ||
* @param propertyPath | ||
* @param defaultValueOrOptions | ||
*/ | ||
getOrThrow(propertyPath, defaultValueOrOptions, options) { | ||
// @ts-expect-error Bypass method overloads | ||
const value = this.get(propertyPath, defaultValueOrOptions, options); | ||
if ((0, shared_utils_1.isUndefined)(value)) { | ||
throw new TypeError(`Configuration key "${propertyPath.toString()}" does not exist`); | ||
} | ||
return value; | ||
} | ||
getFromCache(propertyPath, defaultValue) { | ||
@@ -59,0 +75,0 @@ const cachedValue = (0, lodash_1.get)(this.cache, propertyPath); |
{ | ||
"name": "@nestjs/config", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@config)", | ||
@@ -27,15 +27,15 @@ "author": "Kamil Mysliwiec", | ||
"devDependencies": { | ||
"@commitlint/cli": "17.0.0", | ||
"@commitlint/cli": "17.0.2", | ||
"@commitlint/config-angular": "17.0.0", | ||
"@nestjs/common": "8.4.4", | ||
"@nestjs/core": "8.4.5", | ||
"@nestjs/platform-express": "8.4.5", | ||
"@nestjs/testing": "8.4.5", | ||
"@types/jest": "27.5.1", | ||
"@nestjs/common": "8.4.6", | ||
"@nestjs/core": "8.4.6", | ||
"@nestjs/platform-express": "8.4.6", | ||
"@nestjs/testing": "8.4.6", | ||
"@types/jest": "28.1.0", | ||
"@types/lodash": "4.14.182", | ||
"@types/node": "17.0.34", | ||
"@types/uuid": "8.3.4", | ||
"@typescript-eslint/eslint-plugin": "5.25.0", | ||
"@typescript-eslint/parser": "5.25.0", | ||
"eslint": "8.15.0", | ||
"@typescript-eslint/eslint-plugin": "5.27.0", | ||
"@typescript-eslint/parser": "5.27.0", | ||
"eslint": "8.16.0", | ||
"eslint-config-prettier": "8.5.0", | ||
@@ -46,3 +46,3 @@ "eslint-plugin-import": "2.26.0", | ||
"joi": "17.6.0", | ||
"lint-staged": "12.4.1", | ||
"lint-staged": "13.0.0", | ||
"prettier": "2.6.2", | ||
@@ -53,4 +53,4 @@ "reflect-metadata": "0.1.13", | ||
"rxjs": "7.5.5", | ||
"ts-jest": "28.0.2", | ||
"typescript": "4.6.4" | ||
"ts-jest": "28.0.3", | ||
"typescript": "4.7.2" | ||
}, | ||
@@ -57,0 +57,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42137
779