dynamic-config-store
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -17,3 +17,4 @@ import immer from 'immer'; | ||
} | ||
function getOverridesFromEnv(prefix, obj) { | ||
var processEnv = typeof process !== "undefined" ? process.env : {}; | ||
function getOverridesFromEnv(prefix, obj, configNameString) { | ||
var overrideObj = {}; | ||
@@ -24,7 +25,8 @@ for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { | ||
if (obj[key] != null && typeof obj[key] === "object") { | ||
overrideObj[key] = getOverridesFromEnv(overrideKey + "__", obj[key]); | ||
overrideObj[key] = getOverridesFromEnv(overrideKey + "__", obj[key], configNameString); | ||
} | ||
else { | ||
if (typeof process.env[overrideKey] !== "undefined" && process.env[overrideKey] != null) { | ||
overrideObj[key] = JSON.parse(process.env[overrideKey], reviveDateObjects); | ||
if (typeof processEnv[overrideKey] !== "undefined" && processEnv[overrideKey] != null) { | ||
console.warn("CONFIG" + configNameString + ": found override environment property '" + overrideKey + "'"); | ||
overrideObj[key] = JSON.parse(processEnv[overrideKey], reviveDateObjects); | ||
} | ||
@@ -63,3 +65,3 @@ } | ||
var type = cur.type, env = cur.env, _b = cur.required, required = _b === void 0 ? true : _b, func = cur.func; | ||
if (typeof process.env[env] === "undefined") { | ||
if (typeof processEnv[env] === "undefined") { | ||
if (required) { | ||
@@ -85,3 +87,3 @@ throw new Error("CONFIG" + configNameString + ": property '" + prefixKey + key + "', Couldn't get the REQUIRED environment variable [" + env + "] - you must define it. (alternatively set the link to not-required and provide a default)"); | ||
else { | ||
var envString = process.env[env]; | ||
var envString = processEnv[env]; | ||
var value = void 0; | ||
@@ -131,3 +133,3 @@ if (type === ETypeOfEnvLink.JSON_STRING) { | ||
try { | ||
this._envOverrides = getOverridesFromEnv(envOverridePrefix, this._values); | ||
this._envOverrides = getOverridesFromEnv(envOverridePrefix, this._values, this._configName.length > 0 ? " (" + this._configName + ")" : ""); | ||
} | ||
@@ -134,0 +136,0 @@ catch (e) { |
@@ -19,3 +19,4 @@ "use strict"; | ||
} | ||
function getOverridesFromEnv(prefix, obj) { | ||
var processEnv = typeof process !== "undefined" ? process.env : {}; | ||
function getOverridesFromEnv(prefix, obj, configNameString) { | ||
var overrideObj = {}; | ||
@@ -26,7 +27,8 @@ for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { | ||
if (obj[key] != null && typeof obj[key] === "object") { | ||
overrideObj[key] = getOverridesFromEnv(overrideKey + "__", obj[key]); | ||
overrideObj[key] = getOverridesFromEnv(overrideKey + "__", obj[key], configNameString); | ||
} | ||
else { | ||
if (typeof process.env[overrideKey] !== "undefined" && process.env[overrideKey] != null) { | ||
overrideObj[key] = JSON.parse(process.env[overrideKey], reviveDateObjects); | ||
if (typeof processEnv[overrideKey] !== "undefined" && processEnv[overrideKey] != null) { | ||
console.warn("CONFIG" + configNameString + ": found override environment property '" + overrideKey + "'"); | ||
overrideObj[key] = JSON.parse(processEnv[overrideKey], reviveDateObjects); | ||
} | ||
@@ -65,3 +67,3 @@ } | ||
var type = cur.type, env = cur.env, _b = cur.required, required = _b === void 0 ? true : _b, func = cur.func; | ||
if (typeof process.env[env] === "undefined") { | ||
if (typeof processEnv[env] === "undefined") { | ||
if (required) { | ||
@@ -87,3 +89,3 @@ throw new Error("CONFIG" + configNameString + ": property '" + prefixKey + key + "', Couldn't get the REQUIRED environment variable [" + env + "] - you must define it. (alternatively set the link to not-required and provide a default)"); | ||
else { | ||
var envString = process.env[env]; | ||
var envString = processEnv[env]; | ||
var value = void 0; | ||
@@ -133,3 +135,3 @@ if (type === ETypeOfEnvLink.JSON_STRING) { | ||
try { | ||
this._envOverrides = getOverridesFromEnv(envOverridePrefix, this._values); | ||
this._envOverrides = getOverridesFromEnv(envOverridePrefix, this._values, this._configName.length > 0 ? " (" + this._configName + ")" : ""); | ||
} | ||
@@ -136,0 +138,0 @@ catch (e) { |
@@ -22,3 +22,4 @@ (function (global, factory) { | ||
} | ||
function getOverridesFromEnv(prefix, obj) { | ||
var processEnv = typeof process !== "undefined" ? process.env : {}; | ||
function getOverridesFromEnv(prefix, obj, configNameString) { | ||
var overrideObj = {}; | ||
@@ -29,7 +30,8 @@ for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { | ||
if (obj[key] != null && typeof obj[key] === "object") { | ||
overrideObj[key] = getOverridesFromEnv(overrideKey + "__", obj[key]); | ||
overrideObj[key] = getOverridesFromEnv(overrideKey + "__", obj[key], configNameString); | ||
} | ||
else { | ||
if (typeof process.env[overrideKey] !== "undefined" && process.env[overrideKey] != null) { | ||
overrideObj[key] = JSON.parse(process.env[overrideKey], reviveDateObjects); | ||
if (typeof processEnv[overrideKey] !== "undefined" && processEnv[overrideKey] != null) { | ||
console.warn("CONFIG" + configNameString + ": found override environment property '" + overrideKey + "'"); | ||
overrideObj[key] = JSON.parse(processEnv[overrideKey], reviveDateObjects); | ||
} | ||
@@ -67,3 +69,3 @@ } | ||
var type = cur.type, env = cur.env, _b = cur.required, required = _b === void 0 ? true : _b, func = cur.func; | ||
if (typeof process.env[env] === "undefined") { | ||
if (typeof processEnv[env] === "undefined") { | ||
if (required) { | ||
@@ -89,3 +91,3 @@ throw new Error("CONFIG" + configNameString + ": property '" + prefixKey + key + "', Couldn't get the REQUIRED environment variable [" + env + "] - you must define it. (alternatively set the link to not-required and provide a default)"); | ||
else { | ||
var envString = process.env[env]; | ||
var envString = processEnv[env]; | ||
var value = void 0; | ||
@@ -135,3 +137,3 @@ if (type === exports.ETypeOfEnvLink.JSON_STRING) { | ||
try { | ||
this._envOverrides = getOverridesFromEnv(envOverridePrefix, this._values); | ||
this._envOverrides = getOverridesFromEnv(envOverridePrefix, this._values, this._configName.length > 0 ? " (" + this._configName + ")" : ""); | ||
} | ||
@@ -138,0 +140,0 @@ catch (e) { |
{ | ||
"name": "dynamic-config-store", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Simple configuration utility for deployments and libraries", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
82984
667
3