@abyss-project/monitor 1.0.67 → 1.0.68
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.
|
@@ -7,6 +7,7 @@ exports.Killable = exports.Query = exports.Params = exports.Body = exports.Middl
|
|
|
7
7
|
const types_1 = require("../../types");
|
|
8
8
|
const _1 = require(".");
|
|
9
9
|
const joi_to_swagger_1 = __importDefault(require("joi-to-swagger"));
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
10
11
|
function Route(options) {
|
|
11
12
|
return function (target, propertyKey, descriptor) {
|
|
12
13
|
Reflect.defineMetadata(_1.ROUTE_WATERMARK, true, target, propertyKey);
|
|
@@ -106,7 +107,7 @@ function Body(schema, options) {
|
|
|
106
107
|
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
107
108
|
const originalMethod = descriptor.value;
|
|
108
109
|
descriptor.value = function (...args) {
|
|
109
|
-
const result = schema.options({ presence: 'required' }).validate(args[0].body);
|
|
110
|
+
const result = schema.options({ presence: 'required' }).validate((0, utils_1.deepTrim)(args[0].body));
|
|
110
111
|
if (result.error) {
|
|
111
112
|
throw result.error;
|
|
112
113
|
}
|
|
@@ -128,7 +129,7 @@ function Params(schema, options) {
|
|
|
128
129
|
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
129
130
|
const originalMethod = descriptor.value;
|
|
130
131
|
descriptor.value = function (...args) {
|
|
131
|
-
const result = schema.options({ presence: 'required' }).validate(args[0].params);
|
|
132
|
+
const result = schema.options({ presence: 'required' }).validate((0, utils_1.deepTrim)(args[0].params));
|
|
132
133
|
if (result.error) {
|
|
133
134
|
throw result.error;
|
|
134
135
|
}
|
|
@@ -150,7 +151,7 @@ function Query(schema, options) {
|
|
|
150
151
|
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
151
152
|
const originalMethod = descriptor.value;
|
|
152
153
|
descriptor.value = function (...args) {
|
|
153
|
-
const result = schema.options({ presence: 'required' }).validate(args[0].query);
|
|
154
|
+
const result = schema.options({ presence: 'required' }).validate((0, utils_1.deepTrim)(args[0].query));
|
|
154
155
|
if (result.error) {
|
|
155
156
|
throw result.error;
|
|
156
157
|
}
|
|
@@ -161,7 +162,7 @@ function Query(schema, options) {
|
|
|
161
162
|
}
|
|
162
163
|
exports.Query = Query;
|
|
163
164
|
function Killable() {
|
|
164
|
-
return function (target, propertyKey
|
|
165
|
+
return function (target, propertyKey) {
|
|
165
166
|
Reflect.defineMetadata(_1.KILLABLE_WATERMARK, true, target, propertyKey);
|
|
166
167
|
};
|
|
167
168
|
}
|
|
@@ -166,7 +166,7 @@ const isRoute = (target, propertyKey) => {
|
|
|
166
166
|
return false;
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
|
-
const setLocalsMiddleware = (controller, options = { prefix: '/' }, controllerPrefix, path,
|
|
169
|
+
const setLocalsMiddleware = (controller, options = { prefix: '/' }, controllerPrefix, path, _method, _propertyKey) => (req, res, next) => {
|
|
170
170
|
res.locals.controller = controller.name;
|
|
171
171
|
res.locals.path = `${options.prefix}${controllerPrefix}${path !== null ? path || req.path : ''}`;
|
|
172
172
|
next();
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -21,3 +21,4 @@ __exportStar(require("./alert.utils"), exports);
|
|
|
21
21
|
__exportStar(require("./non-blocking-promise.utils"), exports);
|
|
22
22
|
__exportStar(require("./request-tracker.utils"), exports);
|
|
23
23
|
__exportStar(require("./graceful-shutdown.utils"), exports);
|
|
24
|
+
__exportStar(require("./string.utils"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deepTrim: <T extends unknown>(input: T) => T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepTrim = void 0;
|
|
4
|
+
const deepTrim = (input) => {
|
|
5
|
+
try {
|
|
6
|
+
if (typeof input === 'string')
|
|
7
|
+
return input.trim();
|
|
8
|
+
if (Array.isArray(input))
|
|
9
|
+
return input.map(exports.deepTrim);
|
|
10
|
+
if (input !== null && typeof input === 'object') {
|
|
11
|
+
return Object.fromEntries(Object.entries(input).map(([k, v]) => [k, (0, exports.deepTrim)(v)]));
|
|
12
|
+
}
|
|
13
|
+
return input;
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.error('[deepTrim] Unexpected error, returning original input:', err);
|
|
17
|
+
return input;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.deepTrim = deepTrim;
|