Last active
November 9, 2015 22:51
-
-
Save kulakowka/6a234c4f914d1576b92d to your computer and use it in GitHub Desktop.
ES 2015 express-router
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 {Router} 'express' | |
export default const router = Router() | |
router.get('/items', | |
(req, res, next) => { | |
Item | |
.find() | |
.exec() | |
.catch(next) | |
.then(users => { | |
res.locals.users = users | |
next() | |
}) | |
}, | |
(req, res, next) => res.render('list') | |
) | |
router.get('/items/:id', | |
(req, res, next) => Item.findById(req.params.id).exec().catch(next) | |
.then(user => res.locals.user = user && next()), | |
(req, res, next) => res.render('show') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment