From 5c51093b1de30c5f21f65b0000f526ec0626c89b Mon Sep 17 00:00:00 2001 From: david Date: Thu, 6 Nov 2025 17:15:17 +0100 Subject: [PATCH] Formateo --- .../src/api/infrastructure/database/transaction-manager.ts | 4 +--- .../src/api/infrastructure/express/api-error-mapper.ts | 2 +- .../express/middlewares/global-error-handler.ts | 7 +++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/core/src/api/infrastructure/database/transaction-manager.ts b/modules/core/src/api/infrastructure/database/transaction-manager.ts index c6364e62..547f5949 100644 --- a/modules/core/src/api/infrastructure/database/transaction-manager.ts +++ b/modules/core/src/api/infrastructure/database/transaction-manager.ts @@ -1,9 +1,7 @@ -import { loggerSingleton } from "@repo/rdx-logger"; import { Result } from "@repo/rdx-utils"; +import { logger } from "../../helpers"; import { ITransactionManager } from "./transaction-manager.interface"; -const logger = loggerSingleton(); - export abstract class TransactionManager implements ITransactionManager { protected _transaction: unknown | null = null; protected _isCompleted = false; diff --git a/modules/core/src/api/infrastructure/express/api-error-mapper.ts b/modules/core/src/api/infrastructure/express/api-error-mapper.ts index d016c327..5ca97b4c 100644 --- a/modules/core/src/api/infrastructure/express/api-error-mapper.ts +++ b/modules/core/src/api/infrastructure/express/api-error-mapper.ts @@ -13,9 +13,9 @@ import { DomainValidationError, - ValidationErrorCollection, isDomainValidationError, isValidationErrorCollection, + ValidationErrorCollection, } from "@repo/rdx-ddd"; import { diff --git a/modules/core/src/api/infrastructure/express/middlewares/global-error-handler.ts b/modules/core/src/api/infrastructure/express/middlewares/global-error-handler.ts index f67e0709..b8dffc0e 100644 --- a/modules/core/src/api/infrastructure/express/middlewares/global-error-handler.ts +++ b/modules/core/src/api/infrastructure/express/middlewares/global-error-handler.ts @@ -1,4 +1,5 @@ import { NextFunction, Request, Response } from "express"; +import { logger } from "../../../helpers"; import { ApiErrorContext, ApiErrorMapper, toProblemJson } from "../api-error-mapper"; // βœ… Construye tu mapper una vez (composition root del adaptador HTTP) @@ -10,7 +11,7 @@ export const globalErrorHandler = async ( res: Response, next: NextFunction ) => { - console.error(`❌ Global unhandled error: ${error.message}`); + //console.error(`❌ Global unhandled error: ${error.message}`); // Si ya se enviΓ³ una respuesta, delegamos al siguiente error handler if (res.headersSent) { @@ -26,7 +27,9 @@ export const globalErrorHandler = async ( const body = toProblemJson(apiError, ctx); // πŸ‘‡ Log interno con cause/traza (no lo exponemos al cliente) - // logger.error({ err, cause: (err as any)?.cause, ...ctx }, `❌ Unhandled API error: ${error.message}`); + logger.error(`❌ Global unhandled API error: ${error.message}`, { + label: "globalErrorHandler", + }); res.status(apiError.status).json(body); };