aws-parameters-store
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -22,3 +22,3 @@ declare class getParamsByPathOptions { | ||
*/ | ||
export default function getParams(namespace: string | undefined, options: Partial<getParamsByPathOptions>): Promise<any>; | ||
export default function getParams(namespace: string | undefined, options: Partial<getParamsByPathOptions>, parseJsonValues?: boolean): Promise<any>; | ||
export {}; |
@@ -29,3 +29,3 @@ "use strict"; | ||
*/ | ||
function getParams(namespace = '/', options) { | ||
function getParams(namespace = '/', options, parseJsonValues = true) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -57,9 +57,9 @@ options = new getParamsByPathOptions(options.region, options.recursive, options.withDecryption); | ||
for (const parameter of res.Parameters || []) { | ||
splitSetParam(params, parameter); | ||
setParam(params, parameter); | ||
} | ||
} | ||
return params; | ||
function splitSetParam(params, parameter) { | ||
const paramName = parameter.Name ? parameter.Name.replace(ssmNamespace, '') : null; | ||
const paramValue = parameter.Value; | ||
function setParam(params, parameter) { | ||
const paramName = parameter.Name ? parameter.Name.replace(ssmNamespace, '') : undefined; | ||
const paramValue = getParamValue(parameter.Value || null); | ||
if (paramName) { | ||
@@ -70,2 +70,14 @@ const splitedParamName = paramName.split('/'); | ||
} | ||
function getParamValue(paramValue) { | ||
let ret = paramValue; | ||
if (parseJsonValues) { | ||
try { | ||
ret = paramValue ? JSON.parse(paramValue) : undefined; | ||
} | ||
catch (err) { | ||
// suppress | ||
} | ||
} | ||
return ret; | ||
} | ||
}); | ||
@@ -72,0 +84,0 @@ } |
@@ -20,3 +20,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield _1.default('/iceberg/cp-config-api/apps-panther/', { region }); | ||
return yield _1.default('/iceberg/cp-config-api/apps-panther/params-f7a9d6f/', { region }, false); | ||
}); | ||
@@ -23,0 +23,0 @@ } |
22
index.ts
@@ -31,3 +31,3 @@ import set from 'lodash.set'; | ||
*/ | ||
export default async function getParams( namespace: string = '/', options: Partial<getParamsByPathOptions>): Promise<any> { | ||
export default async function getParams( namespace: string = '/', options: Partial<getParamsByPathOptions>, parseJsonValues: boolean = true): Promise<any> { | ||
@@ -67,11 +67,23 @@ options = new getParamsByPathOptions(options.region, options.recursive, options.withDecryption) | ||
function setParam(params: object, parameter: Parameter) { | ||
const paramName = parameter.Name ? parameter.Name.replace(ssmNamespace, '') : null; | ||
const paramValue = parameter.Value; | ||
const paramName = parameter.Name ? parameter.Name.replace(ssmNamespace, '') : undefined; | ||
const paramValue = getParamValue(parameter.Value || null); | ||
if (paramName) { | ||
const splitedParamName = paramName.split('/'); | ||
set(params, splitedParamName, paramValue); | ||
set(params, splitedParamName, paramValue); | ||
} | ||
} | ||
function getParamValue(paramValue: string | null) { | ||
let ret = paramValue; | ||
if (parseJsonValues) { | ||
try { | ||
ret = paramValue ? JSON.parse(paramValue) : undefined; | ||
} catch (err) { | ||
// suppress | ||
} | ||
} | ||
return ret; | ||
} | ||
} | ||
@@ -78,0 +90,0 @@ |
{ | ||
"name": "aws-parameters-store", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Loads parameters from aws parameter store to a json object", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,3 +7,3 @@ // import getParams from "."; | ||
async function fetchConfigFromAws() { | ||
return await getParams('/iceberg/cp-config-api/apps-panther/', { region }) | ||
return await getParams('/iceberg/cp-config-api/apps-panther/params-f7a9d6f/', { region }) | ||
} | ||
@@ -10,0 +10,0 @@ |
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
13373
279