Created
February 11, 2021 22:34
-
-
Save ChaseH88/265901129e2877fb4952d3ef9ad15cb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Request, Response, RequestHandler, NextFunction } from 'express'; | |
| export const asyncHandler = ( | |
| fn: (req: Request, res: Response, next: NextFunction) => void | |
| ): RequestHandler => (req, res, next) => { | |
| Promise.resolve(fn(req, res, next)).catch(next); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment