UNPKG

easy-express-cwa

Version:

CLI tool to setup a common Express.js backend developed by codewithashim

14 lines (11 loc) 321 B
import { NextFunction, Request, RequestHandler, Response } from 'express'; const catchAsync = (fn: RequestHandler) => async (req: Request, res: Response, next: NextFunction): Promise<void> => { try { await fn(req, res, next); } catch (error) { next(error); } }; export default catchAsync;