Created
January 1, 2019 20:10
-
-
Save ibakhtin/06693358f55a82943b47a9b91412b490 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
const asyncMiddleware = fn => (req, res, next) => { | |
Promise.resolve(fn(req, res, next).catch(next); | |
}; | |
const getUser = async (req, res, next) => { | |
const { id } = req.params; | |
const user = await User.findById(id); | |
} | |
router.get("/user/:id", asyncMiddleware(getUser)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment