@hemia/core 0.0.13 → 0.0.14
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 +4 -2
- package/dist/hemia-core.js +3 -1
- package/package.json +2 -2
package/dist/hemia-core.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import express, { Router } from 'express';
|
|
3
|
-
import { METADATA_KEYS, ParamType, ApiResponse, isRedirectResponse, ControllerRegistry, CustomHttpError } from '@hemia/common';
|
|
3
|
+
import { METADATA_KEYS, ParamType, ApiResponse, isRedirectResponse, HttpError, ControllerRegistry, CustomHttpError } from '@hemia/common';
|
|
4
4
|
import { TRACE_METADATA_KEY } from '@hemia/trace-manager';
|
|
5
5
|
import { traceMiddleware } from '@hemia/app-context';
|
|
6
6
|
import { plainToInstance } from 'class-transformer';
|
|
@@ -227,7 +227,9 @@ async function registerRoutes(app, container, controllerIdentifiers, onTraceFini
|
|
|
227
227
|
console.error(`Error en ${route.method.toUpperCase()} ${basePath}${route.path}:`, error);
|
|
228
228
|
const status = error.statusCode || error.status || 500;
|
|
229
229
|
const message = error.message || 'Internal Server Error';
|
|
230
|
-
const
|
|
230
|
+
const errorDetail = error instanceof HttpError ? error.error : undefined;
|
|
231
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
232
|
+
const errorResponse = ApiResponse.error(message, errorDetail || (isDev ? error.stack : undefined), status);
|
|
231
233
|
const { status: errStatus, ...errorData } = errorResponse;
|
|
232
234
|
res.status(errStatus).json(errorData);
|
|
233
235
|
}
|
package/dist/hemia-core.js
CHANGED
|
@@ -229,7 +229,9 @@ async function registerRoutes(app, container, controllerIdentifiers, onTraceFini
|
|
|
229
229
|
console.error(`Error en ${route.method.toUpperCase()} ${basePath}${route.path}:`, error);
|
|
230
230
|
const status = error.statusCode || error.status || 500;
|
|
231
231
|
const message = error.message || 'Internal Server Error';
|
|
232
|
-
const
|
|
232
|
+
const errorDetail = error instanceof common.HttpError ? error.error : undefined;
|
|
233
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
234
|
+
const errorResponse = common.ApiResponse.error(message, errorDetail || (isDev ? error.stack : undefined), status);
|
|
233
235
|
const { status: errStatus, ...errorData } = errorResponse;
|
|
234
236
|
res.status(errStatus).json(errorData);
|
|
235
237
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hemia/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
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.16",
|
|
22
22
|
"@hemia/app-context": "^0.0.6",
|
|
23
23
|
"@hemia/trace-manager": "^0.0.9",
|
|
24
24
|
"@hemia/auth-sdk": "^0.0.16",
|