@bolt.tech/bolt-paramstore 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,14 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getParameters = void 0;
|
|
13
13
|
const client_ssm_1 = require("@aws-sdk/client-ssm");
|
|
14
|
-
const htSdk = require("@hypertestco/node-sdk");
|
|
15
14
|
const ssm = new client_ssm_1.SSMClient({
|
|
16
15
|
region: "ap-southeast-1",
|
|
17
16
|
});
|
|
18
|
-
const
|
|
19
|
-
global.process.env = Object.assign(Object.assign({}, global.process.env), params);
|
|
20
|
-
};
|
|
21
|
-
const fetchParameters = (path, nextToken = undefined) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const getParameters = (path, nextToken = undefined) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
18
|
var _a;
|
|
23
19
|
try {
|
|
24
20
|
const command = new client_ssm_1.GetParametersByPathCommand({
|
|
@@ -33,73 +29,18 @@ const fetchParameters = (path, nextToken = undefined) => __awaiter(void 0, void
|
|
|
33
29
|
(_a = data === null || data === void 0 ? void 0 : data.Parameters) === null || _a === void 0 ? void 0 : _a.map((data) => {
|
|
34
30
|
var _a;
|
|
35
31
|
const key = ((_a = data === null || data === void 0 ? void 0 : data.Name) === null || _a === void 0 ? void 0 : _a.substring(data.Name.lastIndexOf("/") + 1, data.Name.length)) || "";
|
|
36
|
-
const value = data.Value
|
|
32
|
+
const value = data.Value;
|
|
37
33
|
exportObject[key] = value;
|
|
38
34
|
});
|
|
35
|
+
global.process.env = Object.assign(Object.assign({}, global.process.env), exportObject);
|
|
39
36
|
if (nextToken) {
|
|
40
|
-
|
|
41
|
-
return Object.assign(Object.assign({}, exportObject), nextParams); // Merge parameters from next page
|
|
37
|
+
yield (0, exports.getParameters)(path, nextToken);
|
|
42
38
|
}
|
|
43
|
-
return exportObject;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
console.log(error);
|
|
47
|
-
return {}; // Return empty object in case of error, handle error in getParameters for status
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const getParameters = (path, nextToken = undefined) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
try {
|
|
52
|
-
const fetchedParams = yield htSdk.executeUnmocked(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
return fetchParameters(path, nextToken);
|
|
54
|
-
}));
|
|
55
|
-
populateEnvironment(fetchedParams);
|
|
56
39
|
return { status: 200, message: "VARIABLES FETCHED SUCCESSFULLY." };
|
|
57
40
|
}
|
|
58
41
|
catch (error) {
|
|
59
|
-
console.log(error);
|
|
60
|
-
|
|
42
|
+
console.log("🔴 Parameter store: ", error);
|
|
43
|
+
throw error;
|
|
61
44
|
}
|
|
62
45
|
});
|
|
63
46
|
exports.getParameters = getParameters;
|
|
64
|
-
// getParameters("/dev/common/", undefined);
|
|
65
|
-
// import { SSMClient, GetParametersByPathCommand } from "@aws-sdk/client-ssm";
|
|
66
|
-
// const ssm = new SSMClient({
|
|
67
|
-
// region: "ap-southeast-1",
|
|
68
|
-
// });
|
|
69
|
-
// export const getParameters = async (
|
|
70
|
-
// path: string,
|
|
71
|
-
// nextToken: string | undefined = undefined
|
|
72
|
-
// ) => {
|
|
73
|
-
// try {
|
|
74
|
-
// const command = new GetParametersByPathCommand({
|
|
75
|
-
// Path: path,
|
|
76
|
-
// WithDecryption: true,
|
|
77
|
-
// Recursive: true,
|
|
78
|
-
// NextToken: nextToken,
|
|
79
|
-
// });
|
|
80
|
-
// const data = await ssm.send(command);
|
|
81
|
-
// nextToken = data.NextToken;
|
|
82
|
-
// const exportObject: any = {};
|
|
83
|
-
// data?.Parameters?.map((data) => {
|
|
84
|
-
// const key: string =
|
|
85
|
-
// data?.Name?.substring(
|
|
86
|
-
// data.Name.lastIndexOf("/") + 1,
|
|
87
|
-
// data.Name.length
|
|
88
|
-
// ) || "";
|
|
89
|
-
// const value = data.Value;
|
|
90
|
-
// exportObject[key] = value;
|
|
91
|
-
// });
|
|
92
|
-
// global.process.env = {
|
|
93
|
-
// ...global.process.env,
|
|
94
|
-
// ...exportObject,
|
|
95
|
-
// };
|
|
96
|
-
// if (nextToken) {
|
|
97
|
-
// await getParameters(path, nextToken);
|
|
98
|
-
// }
|
|
99
|
-
// return { status: 200, message: "VARIABLES FETCHED SUCCESSFULLY." };
|
|
100
|
-
// } catch (error) {
|
|
101
|
-
// console.log(error);
|
|
102
|
-
// return { status: 500, message: `ERROR: ${error}` };
|
|
103
|
-
// }
|
|
104
|
-
// };
|
|
105
|
-
// // getParameters("/dev/common/", undefined);
|
|
@@ -21,12 +21,13 @@ const getSecret = (secretId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
21
21
|
});
|
|
22
22
|
const data = yield smc.send(command);
|
|
23
23
|
if (!data.SecretString) {
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error(`⚠️ Secret ${secretId} is empty!`);
|
|
25
25
|
}
|
|
26
26
|
return JSON.parse(data.SecretString);
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
console.log(
|
|
29
|
+
console.log("🔴 Secret manager: ", error);
|
|
30
|
+
throw error;
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
exports.getSecret = getSecret;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolt.tech/bolt-paramstore",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"start": "node build/index.js",
|
|
11
11
|
"dev": "tsc && npm start",
|
|
12
|
-
"prepare": "npm run build"
|
|
12
|
+
"prepare": "npm run build",
|
|
13
|
+
"pub": "rm -rf build/ && npm run build && npm publish --access=public"
|
|
14
|
+
|
|
13
15
|
},
|
|
14
16
|
"keywords": [],
|
|
15
17
|
"author": "",
|
|
@@ -23,7 +25,6 @@
|
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
|
25
27
|
"@aws-sdk/client-ssm": "^3.112.0",
|
|
26
|
-
"@types/node": "^18.0.0"
|
|
27
|
-
"@hypertestco/node-sdk": "0.2.25-37"
|
|
28
|
+
"@types/node": "^18.0.0"
|
|
28
29
|
}
|
|
29
30
|
}
|