@konplit-services/common 1.0.79 → 1.0.81
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.
|
@@ -8,13 +8,22 @@ exports.getAllKeys = void 0;
|
|
|
8
8
|
*/
|
|
9
9
|
const getAllKeys = (obj) => {
|
|
10
10
|
let keys = [];
|
|
11
|
-
if (typeof obj !==
|
|
11
|
+
if (typeof obj !== "object" || obj === null) {
|
|
12
12
|
return keys;
|
|
13
13
|
}
|
|
14
14
|
for (let key in obj) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (Array.isArray(obj[key])) {
|
|
16
|
+
// Add the array key itself
|
|
17
|
+
//TODO: UPDATE THE IMPLEMENTATION
|
|
18
|
+
// keys.push(key);
|
|
19
|
+
// Optionally, add keys of elements within the array
|
|
20
|
+
// keys = keys.concat(obj[key].flatMap((item: any) => getAllKeys(item)));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
keys.push(key);
|
|
24
|
+
if (typeof obj[key] === "object") {
|
|
25
|
+
keys = keys.concat(getAllKeys(obj[key]));
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
return keys;
|
|
@@ -11,12 +11,12 @@ const validateInputRequest = (req, res, next) => {
|
|
|
11
11
|
const query = (0, getobject_keys_1.getAllKeys)(req.query);
|
|
12
12
|
for (let key of query) {
|
|
13
13
|
const validate = (0, validateParams_1.validateInput)(key);
|
|
14
|
-
console.log(key);
|
|
14
|
+
console.log("query", key);
|
|
15
15
|
if (validate)
|
|
16
16
|
throw new invalid_input_error_1.InvalidInputError(language_1.lang.invalid_input, key, error_codes_1.error_codes.INVALID_INPUT);
|
|
17
17
|
}
|
|
18
18
|
for (let key of body) {
|
|
19
|
-
console.log(key);
|
|
19
|
+
console.log("body", key);
|
|
20
20
|
const validate = (0, validateParams_1.validateInput)(key);
|
|
21
21
|
if (validate)
|
|
22
22
|
throw new invalid_input_error_1.InvalidInputError(language_1.lang.invalid_input, key, error_codes_1.error_codes.INVALID_INPUT);
|