@nestjs/config
Advanced tools
Comparing version 0.6.0 to 0.6.1
import { DynamicModule } from '@nestjs/common'; | ||
import { FactoryProvider } from '@nestjs/common/interfaces'; | ||
import { ConfigService } from './config.service'; | ||
import { ConfigFactory, ConfigModuleOptions } from './interfaces'; | ||
export declare class ConfigModule { | ||
static forRoot(options?: ConfigModuleOptions): DynamicModule; | ||
static forFeature(config: ConfigFactory): { | ||
module: typeof ConfigModule; | ||
providers: (FactoryProvider<any> | { | ||
provide: typeof ConfigService; | ||
useFactory: (configService: ConfigService) => ConfigService<Record<string, any>>; | ||
inject: (string | symbol | Function)[]; | ||
})[]; | ||
exports: (string | symbol | Function)[]; | ||
}; | ||
static forFeature(config: ConfigFactory): DynamicModule; | ||
private static loadEnvFile; | ||
@@ -17,0 +7,0 @@ private static assignVariablesToProcess; |
@@ -15,3 +15,3 @@ import { NoInferType } from './types'; | ||
private getFromInternalConfig; | ||
private setInCache; | ||
private setInCacheIfDefined; | ||
} |
@@ -38,7 +38,2 @@ "use strict"; | ||
get(propertyPath, defaultValue) { | ||
if (this.isCacheEnabled && | ||
lodash_has_1.default(this.cache, propertyPath)) { | ||
const cachedValue = this.getFromCache(propertyPath, defaultValue); | ||
return !util_1.isUndefined(cachedValue) ? cachedValue : defaultValue; | ||
} | ||
const validatedEnvValue = this.getFromValidatedEnv(propertyPath); | ||
@@ -48,3 +43,3 @@ if (!util_1.isUndefined(validatedEnvValue)) { | ||
} | ||
const processEnvValue = this.getFromProcessEnv(propertyPath); | ||
const processEnvValue = this.getFromProcessEnv(propertyPath, defaultValue); | ||
if (!util_1.isUndefined(processEnvValue)) { | ||
@@ -67,8 +62,12 @@ return processEnvValue; | ||
const validatedEnvValue = lodash_get_1.default(this.internalConfig[config_constants_1.VALIDATED_ENV_PROPNAME], propertyPath); | ||
this.setInCache(propertyPath, validatedEnvValue); | ||
return validatedEnvValue; | ||
} | ||
getFromProcessEnv(propertyPath) { | ||
getFromProcessEnv(propertyPath, defaultValue) { | ||
if (this.isCacheEnabled && | ||
lodash_has_1.default(this.cache, propertyPath)) { | ||
const cachedValue = this.getFromCache(propertyPath, defaultValue); | ||
return !util_1.isUndefined(cachedValue) ? cachedValue : defaultValue; | ||
} | ||
const processValue = lodash_get_1.default(process.env, propertyPath); | ||
this.setInCache(propertyPath, processValue); | ||
this.setInCacheIfDefined(propertyPath, processValue); | ||
return processValue; | ||
@@ -78,6 +77,8 @@ } | ||
const internalValue = lodash_get_1.default(this.internalConfig, propertyPath); | ||
this.setInCache(propertyPath, internalValue); | ||
return internalValue; | ||
} | ||
setInCache(propertyPath, value) { | ||
setInCacheIfDefined(propertyPath, value) { | ||
if (typeof value === 'undefined') { | ||
return; | ||
} | ||
lodash_set_1.default(this.cache, propertyPath, value); | ||
@@ -84,0 +85,0 @@ } |
{ | ||
"name": "@nestjs/config", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@config)", | ||
@@ -31,15 +31,15 @@ "author": "Kamil Mysliwiec", | ||
"@hapi/joi": "17.1.1", | ||
"@nestjs/common": "7.5.2", | ||
"@nestjs/core": "7.5.2", | ||
"@nestjs/platform-express": "7.5.2", | ||
"@nestjs/testing": "7.5.2", | ||
"@nestjs/common": "7.5.4", | ||
"@nestjs/core": "7.5.4", | ||
"@nestjs/platform-express": "7.5.4", | ||
"@nestjs/testing": "7.5.4", | ||
"@types/hapi__joi": "17.1.6", | ||
"@types/jest": "26.0.15", | ||
"@types/lodash.get": "4.4.6", | ||
"@types/lodash.has": "4.5.2", | ||
"@types/lodash.has": "4.5.6", | ||
"@types/lodash.set": "4.3.6", | ||
"@types/node": "7.10.8", | ||
"@types/uuid": "8.3.0", | ||
"@typescript-eslint/eslint-plugin": "4.8.0", | ||
"@typescript-eslint/parser": "4.8.0", | ||
"@typescript-eslint/eslint-plugin": "4.8.1", | ||
"@typescript-eslint/parser": "4.8.1", | ||
"eslint": "7.13.0", | ||
@@ -51,3 +51,3 @@ "eslint-config-prettier": "6.15.0", | ||
"lint-staged": "10.5.1", | ||
"prettier": "2.1.2", | ||
"prettier": "2.2.0", | ||
"reflect-metadata": "0.1.13", | ||
@@ -58,3 +58,3 @@ "release-it": "14.2.1", | ||
"ts-jest": "26.4.4", | ||
"typescript": "4.0.5" | ||
"typescript": "4.1.2" | ||
}, | ||
@@ -61,0 +61,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
30732
592