@hemia/core 0.0.14 → 0.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.
- package/dist/hemia-core.esm.js +11 -3
- package/dist/hemia-core.js +11 -3
- package/package.json +2 -2
package/dist/hemia-core.esm.js
CHANGED
|
@@ -192,9 +192,17 @@ async function registerRoutes(app, container, controllerIdentifiers, onTraceFini
|
|
|
192
192
|
const validators = Reflect.getMetadata(METADATA_KEYS.VALIDATORS, instance, route.methodName) || [];
|
|
193
193
|
for (const { index, validator } of validators) {
|
|
194
194
|
const value = args[index];
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
try {
|
|
196
|
+
const result = await Promise.resolve(validator(value));
|
|
197
|
+
if (result === false) {
|
|
198
|
+
return res.status(400).json(ApiResponse.error('Validation failed', undefined, 400));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (error.name === 'ValidationException') {
|
|
203
|
+
return res.status(400).json(ApiResponse.error('Validation failed', error.toJSON ? error.toJSON() : error.errors, 400));
|
|
204
|
+
}
|
|
205
|
+
throw error;
|
|
198
206
|
}
|
|
199
207
|
}
|
|
200
208
|
// EJECUCIÓN DEL CONTROLLER
|
package/dist/hemia-core.js
CHANGED
|
@@ -194,9 +194,17 @@ async function registerRoutes(app, container, controllerIdentifiers, onTraceFini
|
|
|
194
194
|
const validators = Reflect.getMetadata(common.METADATA_KEYS.VALIDATORS, instance, route.methodName) || [];
|
|
195
195
|
for (const { index, validator } of validators) {
|
|
196
196
|
const value = args[index];
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
try {
|
|
198
|
+
const result = await Promise.resolve(validator(value));
|
|
199
|
+
if (result === false) {
|
|
200
|
+
return res.status(400).json(common.ApiResponse.error('Validation failed', undefined, 400));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error.name === 'ValidationException') {
|
|
205
|
+
return res.status(400).json(common.ApiResponse.error('Validation failed', error.toJSON ? error.toJSON() : error.errors, 400));
|
|
206
|
+
}
|
|
207
|
+
throw error;
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
// EJECUCIÓN DEL CONTROLLER
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hemia/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Core utilities for Hemia projects",
|
|
5
5
|
"main": "dist/hemia-core.js",
|
|
6
6
|
"module": "dist/hemia-core.esm.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
19
19
|
"@rollup/plugin-json": "^6.1.0",
|
|
20
20
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
21
|
-
"@hemia/common": "^0.0.
|
|
21
|
+
"@hemia/common": "^0.0.17",
|
|
22
22
|
"@hemia/app-context": "^0.0.6",
|
|
23
23
|
"@hemia/trace-manager": "^0.0.9",
|
|
24
24
|
"@hemia/auth-sdk": "^0.0.16",
|