@nestjs/config
Advanced tools
Comparing version 0.6.3 to 1.0.0
@@ -1,6 +0,9 @@ | ||
import { NoInferType } from './types'; | ||
import { NoInferType, Path, PathValue } from './types'; | ||
export interface ConfigGetOptions { | ||
infer: true; | ||
} | ||
export declare class ConfigService<K = Record<string, any>> { | ||
private readonly internalConfig; | ||
get isCacheEnabled(): boolean; | ||
set isCacheEnabled(value: boolean); | ||
private set isCacheEnabled(value); | ||
private get isCacheEnabled(); | ||
private readonly cache; | ||
@@ -10,3 +13,5 @@ private _isCacheEnabled; | ||
get<T = any>(propertyPath: keyof K): T | undefined; | ||
get<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, options: ConfigGetOptions): R | undefined; | ||
get<T = any>(propertyPath: keyof K, defaultValue: NoInferType<T>): T; | ||
get<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, defaultValue: NoInferType<R>, options: ConfigGetOptions): R | undefined; | ||
private getFromCache; | ||
@@ -17,2 +22,3 @@ private getFromValidatedEnv; | ||
private setInCacheIfDefined; | ||
private isGetOptionsObject; | ||
} |
@@ -20,6 +20,6 @@ "use strict"; | ||
const common_1 = require("@nestjs/common"); | ||
const shared_utils_1 = require("@nestjs/common/utils/shared.utils"); | ||
const lodash_get_1 = __importDefault(require("lodash.get")); | ||
const lodash_has_1 = __importDefault(require("lodash.has")); | ||
const lodash_set_1 = __importDefault(require("lodash.set")); | ||
const util_1 = require("util"); | ||
const config_constants_1 = require("./config.constants"); | ||
@@ -32,19 +32,22 @@ let ConfigService = class ConfigService { | ||
} | ||
set isCacheEnabled(value) { | ||
this._isCacheEnabled = value; | ||
} | ||
get isCacheEnabled() { | ||
return this._isCacheEnabled; | ||
} | ||
set isCacheEnabled(value) { | ||
this._isCacheEnabled = value; | ||
} | ||
get(propertyPath, defaultValue) { | ||
get(propertyPath, defaultValueOrOptions, options) { | ||
const validatedEnvValue = this.getFromValidatedEnv(propertyPath); | ||
if (!util_1.isUndefined(validatedEnvValue)) { | ||
if (!shared_utils_1.isUndefined(validatedEnvValue)) { | ||
return validatedEnvValue; | ||
} | ||
const defaultValue = this.isGetOptionsObject(defaultValueOrOptions) && !options | ||
? undefined | ||
: defaultValueOrOptions; | ||
const processEnvValue = this.getFromProcessEnv(propertyPath, defaultValue); | ||
if (!util_1.isUndefined(processEnvValue)) { | ||
if (!shared_utils_1.isUndefined(processEnvValue)) { | ||
return processEnvValue; | ||
} | ||
const internalValue = this.getFromInternalConfig(propertyPath); | ||
if (!util_1.isUndefined(internalValue)) { | ||
if (!shared_utils_1.isUndefined(internalValue)) { | ||
return internalValue; | ||
@@ -56,3 +59,3 @@ } | ||
const cachedValue = lodash_get_1.default(this.cache, propertyPath); | ||
return util_1.isUndefined(cachedValue) | ||
return shared_utils_1.isUndefined(cachedValue) | ||
? defaultValue | ||
@@ -69,3 +72,3 @@ : cachedValue; | ||
const cachedValue = this.getFromCache(propertyPath, defaultValue); | ||
return !util_1.isUndefined(cachedValue) ? cachedValue : defaultValue; | ||
return !shared_utils_1.isUndefined(cachedValue) ? cachedValue : defaultValue; | ||
} | ||
@@ -86,2 +89,5 @@ const processValue = lodash_get_1.default(process.env, propertyPath); | ||
} | ||
isGetOptionsObject(options) { | ||
return options && (options === null || options === void 0 ? void 0 : options.infer) && Object.keys(options).length === 1; | ||
} | ||
}; | ||
@@ -88,0 +94,0 @@ ConfigService = __decorate([ |
@@ -1,3 +0,4 @@ | ||
declare type ConfigFactoryReturnValue = Record<string, any> | Promise<Record<string, any>>; | ||
export declare type ConfigFactory<T extends ConfigFactoryReturnValue = ConfigFactoryReturnValue> = () => T; | ||
import { ConfigObject } from '../types'; | ||
declare type ConfigFactoryReturnValue<T extends ConfigObject> = T | Promise<T>; | ||
export declare type ConfigFactory<T extends ConfigObject = ConfigObject> = () => ConfigFactoryReturnValue<T>; | ||
export {}; |
@@ -0,2 +1,4 @@ | ||
export * from './config-object.type'; | ||
export * from './config.type'; | ||
export * from './no-infer.type'; | ||
export * from './path-value.type'; |
@@ -13,3 +13,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./config-object.type"), exports); | ||
__exportStar(require("./config.type"), exports); | ||
__exportStar(require("./no-infer.type"), exports); | ||
__exportStar(require("./path-value.type"), exports); |
import { ConfigFactory } from '../interfaces'; | ||
import { ConfigObject } from '../types'; | ||
export declare type ConfigFactoryKeyHost = { | ||
KEY: string; | ||
}; | ||
export declare function registerAs<T extends ConfigFactory = ConfigFactory>(token: string, configFactory: T): T & ConfigFactoryKeyHost; | ||
export declare function registerAs<TConfig extends ConfigObject, TFactory extends ConfigFactory = ConfigFactory<TConfig>>(token: string, configFactory: TFactory): TFactory & ConfigFactoryKeyHost; |
{ | ||
"name": "@nestjs/config", | ||
"version": "0.6.3", | ||
"version": "1.0.0", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@config)", | ||
@@ -10,2 +10,3 @@ "author": "Kamil Mysliwiec", | ||
"build": "rimraf -rf dist && tsc -p tsconfig.json", | ||
"format": "prettier --write \"{lib,test}/**/*.ts\"", | ||
"lint": "eslint 'lib/**/*.ts' --fix", | ||
@@ -21,3 +22,3 @@ "prepublish:npm": "npm run build", | ||
"dependencies": { | ||
"dotenv": "8.2.0", | ||
"dotenv": "10.0.0", | ||
"dotenv-expand": "5.1.0", | ||
@@ -30,36 +31,35 @@ "lodash.get": "4.4.2", | ||
"devDependencies": { | ||
"@commitlint/cli": "11.0.0", | ||
"@commitlint/config-angular": "11.0.0", | ||
"@hapi/joi": "17.1.1", | ||
"@nestjs/common": "7.6.8", | ||
"@nestjs/core": "7.6.8", | ||
"@nestjs/platform-express": "7.6.8", | ||
"@nestjs/testing": "7.6.8", | ||
"@types/hapi__joi": "17.1.6", | ||
"@types/jest": "26.0.20", | ||
"@commitlint/cli": "12.1.4", | ||
"@commitlint/config-angular": "12.1.4", | ||
"@nestjs/common": "8.0.0", | ||
"@nestjs/core": "8.0.0", | ||
"@nestjs/platform-express": "8.0.0", | ||
"@nestjs/testing": "8.0.0", | ||
"@types/jest": "26.0.24", | ||
"@types/lodash.get": "4.4.6", | ||
"@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.14.2", | ||
"@typescript-eslint/parser": "4.14.2", | ||
"eslint": "7.19.0", | ||
"eslint-config-prettier": "7.2.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"husky": "4.3.8", | ||
"jest": "26.6.3", | ||
"lint-staged": "10.5.3", | ||
"prettier": "2.2.1", | ||
"@types/node": "16.0.0", | ||
"@types/uuid": "8.3.1", | ||
"@typescript-eslint/eslint-plugin": "4.28.2", | ||
"@typescript-eslint/parser": "4.28.2", | ||
"eslint": "7.30.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-import": "2.23.4", | ||
"husky": "7.0.1", | ||
"jest": "27.0.6", | ||
"joi": "17.4.0", | ||
"lint-staged": "11.0.0", | ||
"prettier": "2.3.2", | ||
"reflect-metadata": "0.1.13", | ||
"release-it": "14.2.2", | ||
"release-it": "14.10.0", | ||
"rimraf": "3.0.2", | ||
"rxjs": "6.6.3", | ||
"ts-jest": "26.5.0", | ||
"typescript": "4.1.3" | ||
"rxjs": "7.2.0", | ||
"ts-jest": "27.0.3", | ||
"typescript": "4.3.5" | ||
}, | ||
"peerDependencies": { | ||
"@nestjs/common": "^6.10.0 || ^7.0.0", | ||
"reflect-metadata": "^0.1.12", | ||
"rxjs": "^6.0.0" | ||
"@nestjs/common": "^7.0.0 || ^8.0.0", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^6.0.0 || ^7.2.0" | ||
}, | ||
@@ -66,0 +66,0 @@ "lint-staged": { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33967
28
47
623
1
+ Added@nestjs/common@8.4.7(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@0.27.2(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddotenv@10.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedtslib@2.4.0(transitive)
- Removed@nestjs/common@7.6.18(transitive)
- Removedaxios@0.21.1(transitive)
- Removeddotenv@8.2.0(transitive)
- Removedrxjs@6.6.7(transitive)
- Removedtslib@1.14.12.2.0(transitive)
Updateddotenv@10.0.0