UNPKG

typescript-express-starter

Version:
9 lines (6 loc) 320 B
import type { Request, Response, NextFunction, RequestHandler } from 'express'; export type AsyncHandler = (req: Request, res: Response, next: NextFunction) => Promise<void>; export const asyncHandler = (fn: AsyncHandler): RequestHandler => (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next);