Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs/config

Package Overview
Dependencies
Maintainers
3
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/config - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

1

dist/config-host.module.js

@@ -9,2 +9,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigHostModule = void 0;
const common_1 = require("@nestjs/common");

@@ -11,0 +12,0 @@ const config_constants_1 = require("./config.constants");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VALIDATED_ENV_PROPNAME = exports.PARTIAL_CONFIGURATION_PROPNAME = exports.PARTIAL_CONFIGURATION_KEY = exports.VALIDATED_ENV_LOADER = exports.CONFIGURATION_LOADER = exports.CONFIGURATION_TOKEN = exports.CONFIGURATION_SERVICE_TOKEN = void 0;
exports.CONFIGURATION_SERVICE_TOKEN = Symbol('CONFIG_SERVICE');

@@ -4,0 +5,0 @@ exports.CONFIGURATION_TOKEN = 'CONFIGURATION_TOKEN';

2

dist/config.module.d.ts

@@ -11,3 +11,3 @@ import { DynamicModule } from '@nestjs/common';

provide: typeof ConfigService;
useFactory: (configService: ConfigService<Record<string, any>>) => ConfigService<Record<string, any>>;
useFactory: (configService: ConfigService) => ConfigService<Record<string, any>>;
inject: (string | symbol | Function)[];

@@ -14,0 +14,0 @@ })[];

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -11,4 +23,4 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;

@@ -21,2 +33,3 @@ };

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigModule = void 0;
const common_1 = require("@nestjs/common");

@@ -41,3 +54,8 @@ const dotenv = __importStar(require("dotenv"));

}
if (options.validationSchema) {
if (options.validate) {
const validatedConfig = options.validate(config);
validatedEnvConfig = validatedConfig;
this.assignVariablesToProcess(validatedConfig);
}
else if (options.validationSchema) {
const validationOptions = this.getSchemaValidationOptions(options);

@@ -61,3 +79,8 @@ const { error, value: validatedConfig, } = options.validationSchema.validate(config, validationOptions);

provide: config_service_1.ConfigService,
useFactory: (configService) => configService,
useFactory: (configService) => {
if (options.cache) {
configService.isCacheEnabled = true;
}
return configService;
},
inject: [config_constants_1.CONFIGURATION_SERVICE_TOKEN, ...configProviderTokens],

@@ -64,0 +87,0 @@ };

import { NoInferType } from './types';
export declare class ConfigService<K = Record<string, any>> {
private readonly internalConfig;
get isCacheEnabled(): boolean;
set isCacheEnabled(value: boolean);
private readonly cache;
private _isCacheEnabled;
constructor(internalConfig?: Record<string, any>);
get<T = any>(propertyPath: keyof K): T | undefined;
get<T = any>(propertyPath: keyof K, defaultValue: NoInferType<T>): T;
private getFromCache;
private getFromValidatedEnv;
private getFromProcessEnv;
private getFromInternalConfig;
private setInCache;
}

@@ -18,4 +18,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigService = void 0;
const common_1 = require("@nestjs/common");
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");

@@ -26,15 +29,55 @@ const config_constants_1 = require("./config.constants");

this.internalConfig = internalConfig;
this.cache = {};
this._isCacheEnabled = false;
}
get isCacheEnabled() {
return this._isCacheEnabled;
}
set isCacheEnabled(value) {
this._isCacheEnabled = value;
}
get(propertyPath, defaultValue) {
const validatedEnvValue = lodash_get_1.default(this.internalConfig[config_constants_1.VALIDATED_ENV_PROPNAME], propertyPath);
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);
if (!util_1.isUndefined(validatedEnvValue)) {
return validatedEnvValue;
}
const processEnvValue = this.getFromProcessEnv(propertyPath);
if (!util_1.isUndefined(processEnvValue)) {
return processEnvValue;
}
const internalValue = this.getFromInternalConfig(propertyPath);
if (!util_1.isUndefined(internalValue)) {
return internalValue;
}
return defaultValue;
}
getFromCache(propertyPath, defaultValue) {
const cachedValue = lodash_get_1.default(this.cache, propertyPath);
return util_1.isUndefined(cachedValue)
? defaultValue
: cachedValue;
}
getFromValidatedEnv(propertyPath) {
const validatedEnvValue = lodash_get_1.default(this.internalConfig[config_constants_1.VALIDATED_ENV_PROPNAME], propertyPath);
this.setInCache(propertyPath, validatedEnvValue);
return validatedEnvValue;
}
getFromProcessEnv(propertyPath) {
const processValue = lodash_get_1.default(process.env, propertyPath);
if (!util_1.isUndefined(processValue)) {
return processValue;
}
this.setInCache(propertyPath, processValue);
return processValue;
}
getFromInternalConfig(propertyPath) {
const internalValue = lodash_get_1.default(this.internalConfig, propertyPath);
return util_1.isUndefined(internalValue) ? defaultValue : internalValue;
this.setInCache(propertyPath, internalValue);
return internalValue;
}
setInCache(propertyPath, value) {
lodash_set_1.default(this.cache, propertyPath, value);
}
};

@@ -41,0 +84,0 @@ ConfigService = __decorate([

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./config.module"));
__export(require("./config.service"));
__export(require("./utils"));
__exportStar(require("./config.module"), exports);
__exportStar(require("./config.service"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./utils"), exports);
import { ConfigFactory } from './config-factory.interface';
export interface ConfigModuleOptions {
cache?: boolean;
isGlobal?: boolean;

@@ -8,2 +9,3 @@ ignoreEnvFile?: boolean;

encoding?: string;
validate?: (config: Record<string, any>) => Record<string, any>;
validationSchema?: any;

@@ -10,0 +12,0 @@ validationOptions?: Record<string, any>;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./config-factory.interface"), exports);
__exportStar(require("./config-module-options.interface"), exports);
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./config.type"), exports);
__exportStar(require("./no-infer.type"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConfigProvider = void 0;
const uuid_1 = require("uuid");

@@ -4,0 +5,0 @@ const get_config_token_util_1 = require("./get-config-token.util");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigToken = void 0;
function getConfigToken(token) {

@@ -4,0 +5,0 @@ return `CONFIGURATION(${token})`;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRegistrationToken = void 0;
const config_constants_1 = require("../config.constants");

@@ -4,0 +5,0 @@ function getRegistrationToken(config) {

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./register-as.util"));
__exportStar(require("./register-as.util"), exports);

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeConfigObject = void 0;
const lodash_set_1 = __importDefault(require("lodash.set"));

@@ -8,0 +9,0 @@ function mergeConfigObject(host, partial, token) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerAs = void 0;
const config_constants_1 = require("../config.constants");

@@ -4,0 +5,0 @@ const get_config_token_util_1 = require("./get-config-token.util");

{
"name": "@nestjs/config",
"version": "0.5.0",
"version": "0.6.0",
"description": "Nest - modern, fast, powerful node.js web framework (@config)",

@@ -23,34 +23,36 @@ "author": "Kamil Mysliwiec",

"lodash.get": "4.4.2",
"lodash.has": "4.5.2",
"lodash.set": "4.3.2",
"uuid": "8.1.0"
"uuid": "8.3.1"
},
"devDependencies": {
"@commitlint/cli": "8.3.5",
"@commitlint/config-angular": "8.3.4",
"@commitlint/cli": "11.0.0",
"@commitlint/config-angular": "11.0.0",
"@hapi/joi": "17.1.1",
"@nestjs/common": "7.0.13",
"@nestjs/core": "7.0.13",
"@nestjs/platform-express": "7.0.13",
"@nestjs/testing": "7.0.13",
"@types/hapi__joi": "17.1.0",
"@types/jest": "25.2.3",
"@nestjs/common": "7.5.2",
"@nestjs/core": "7.5.2",
"@nestjs/platform-express": "7.5.2",
"@nestjs/testing": "7.5.2",
"@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.set": "4.3.6",
"@types/node": "7.10.8",
"@types/uuid": "8.0.0",
"@typescript-eslint/eslint-plugin": "3.0.0",
"@typescript-eslint/parser": "3.0.0",
"eslint": "7.1.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.20.2",
"husky": "4.2.5",
"jest": "26.0.1",
"lint-staged": "10.2.6",
"prettier": "2.0.5",
"@types/uuid": "8.3.0",
"@typescript-eslint/eslint-plugin": "4.8.0",
"@typescript-eslint/parser": "4.8.0",
"eslint": "7.13.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-import": "2.22.1",
"husky": "4.3.0",
"jest": "26.6.3",
"lint-staged": "10.5.1",
"prettier": "2.1.2",
"reflect-metadata": "0.1.13",
"release-it": "13.6.1",
"release-it": "14.2.1",
"rimraf": "3.0.2",
"rxjs": "6.5.5",
"ts-jest": "26.0.0",
"typescript": "3.9.3"
"rxjs": "6.6.3",
"ts-jest": "26.4.4",
"typescript": "4.0.5"
},

@@ -57,0 +59,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc