api: drop error handler's log from leaking into test envs

Pedro Lucas Porcellis porcellis@eletrotupi.com 2 months ago 33435d313f82e2cc63720eb0f82c7c016427f2df
Parents: d4d62db
2 file(s) changed
  • api/src/middleware/auth.ts +1 -0
  • api/src/middleware/errorHandler.ts +4 -2
api/src/middleware/auth.ts
@@ -30,4 +30,4 @@ return res.status(401).json({ error: 'Unauthorized: Token expired' });
30 30 }
31 31 next(err);
32 32 }
33 - };
33 + };
api/src/middleware/errorHandler.ts
@@ -8,8 +8,10 @@ _req: Request,
8 8 res: Response,
9 9 _next: NextFunction
10 10 ) => {
11 - // TODO: Rig some improved, centralized error logging here
12 - console.error(`[ErrorHandler]: ${err}`);
11 + if (process.env.NODE_ENV === "development") {
12 + // TODO: Rig some improved, centralized error logging here
13 + console.error(`[ErrorHandler]: ${err}`);
14 + }
13 15
14 16 if (isDomainError(err)) {
15 17 return res.status(err.status)