Last active
November 7, 2017 17:59
-
-
Save theharveyz/a008367e007ef6e0c81173a6c8c9ee3f to your computer and use it in GitHub Desktop.
express async wrapper
This file contains 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
/** | |
* @param fn fn是 async fn...修饰的函数, 本身已经是个Promise对象!! | |
*/ | |
export const wrapper = (fn) => (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