Spaces:
Sleeping
Sleeping
File size: 369 Bytes
4bf0aa2 | 1 2 3 4 5 6 7 8 9 10 | import { Request, Response, NextFunction } from 'express';
export const errorMiddleware = (err: any, req: Request, res: any, next: NextFunction) => {
const statusCode = res.statusCode === 200 ? 500 : res.statusCode;
res.status(statusCode).json({
message: err.message,
stack: process.env.NODE_ENV === 'production' ? null : err.stack,
});
};
|