Created
September 27, 2019 15:53
-
-
Save groovecoder/7607bccad012c9e46dd87f1aa11c20b0 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
// Helps handle errors for all async route controllers | |
// See https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 | |
function asyncMiddleware (fn) { | |
return (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