generator-kube-microservice-node
Version:
A k8s micro-service generator with deployment, service, Dockerfile. Built with express/mongo/redis
14 lines (11 loc) • 649 B
text/typescript
import { logger } from '../../shared/utils/logger';
import { Request, Response, NextFunction } from 'express';
import GenericException from '../../shared/exceptions/GenericException';
import RouteNotFoundException from '../../shared/exceptions/RouteNotFoundException';
export const RouteNotFoundMiddleware = (req: Request, res: Response, next: NextFunction) => {
next(new RouteNotFoundException(req));
};
export const ExceptionMiddleware = (err: GenericException, req: Request, res: Response, next: NextFunction) => {
logger.error(`${err.stack}`, { label: 'RuntimeException' });
return res.status(err.statusCode).send(err.formatError());
};