Skip to content

Instantly share code, notes, and snippets.

@theharveyz
Last active November 7, 2017 17:59
Show Gist options
  • Save theharveyz/a008367e007ef6e0c81173a6c8c9ee3f to your computer and use it in GitHub Desktop.
Save theharveyz/a008367e007ef6e0c81173a6c8c9ee3f to your computer and use it in GitHub Desktop.
express async wrapper
/**
* @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