Created
July 9, 2015 15:17
-
-
Save grabbou/52709cff517dfb1f43d7 to your computer and use it in GitHub Desktop.
Babel
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} from 'express'; | |
import {wrap} from '../../utils'; | |
const router = Router(); | |
async function getAllChampagnes(req, res) { | |
const champagnes = await req.db.models.Champagne | |
.find() | |
.exec(); | |
res.send(champagnes); | |
} | |
router.get('/champagnes', wrap(getAllChampagnes)); | |
export default 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
babel file.js --stage 1 | |
// PS. I have 20 similar handlers and they do not fail. |
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
export function wrap(fn) { | |
return (...args) => fn(...args).catch(args[2]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment