UNPKG

create-new-express-app

Version:

A CLI tool to create a TypeScript Express application with best practices

17 lines (14 loc) 530 B
import { type Request, type Response, type NextFunction } from "express"; const asyncHandler = <P, ResBody, ReqBody, ReqQuery>( fn: ( req: Request<P, ResBody, ReqBody, ReqQuery>, res: Response<ResBody>, next: NextFunction // eslint-disable-next-line @typescript-eslint/no-explicit-any ) => Promise<any> ) => (req: Request<P, ResBody, ReqBody, ReqQuery>, res: Response<ResBody>, next: NextFunction) => { Promise.resolve(fn(req, res, next)).catch(next); }; export default asyncHandler;