mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 08:22:42 +00:00
add asyncHandler to async methods in routes
This commit is contained in:
@@ -5,6 +5,7 @@ const zlib = require('zlib');
|
|||||||
const GoogleActions = require('./googleActions.js');
|
const GoogleActions = require('./googleActions.js');
|
||||||
const Markdown = require('../shared/naturalcrit/markdown.js');
|
const Markdown = require('../shared/naturalcrit/markdown.js');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
|
const asyncHandler = require('express-async-handler');
|
||||||
|
|
||||||
// const getTopBrews = (cb) => {
|
// const getTopBrews = (cb) => {
|
||||||
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
|
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
|
||||||
@@ -226,10 +227,10 @@ const deleteGoogleBrew = async (account, id, res)=>{
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
router.post('/api', newBrew);
|
router.post('/api', asyncHandler(newBrew));
|
||||||
router.put('/api/:id', updateBrew);
|
router.put('/api/:id', asyncHandler(updateBrew));
|
||||||
router.put('/api/update/:id', updateBrew);
|
router.put('/api/update/:id', asyncHandler(updateBrew));
|
||||||
router.delete('/api/:id', deleteBrew);
|
router.delete('/api/:id', asyncHandler(deleteBrew));
|
||||||
router.get('/api/remove/:id', deleteBrew);
|
router.get('/api/remove/:id', asyncHandler(deleteBrew));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
Reference in New Issue
Block a user