mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-16 14:42:45 +00:00
update getBrew usages to not fetch google brew during updates
This commit is contained in:
@@ -27,7 +27,7 @@ const getId = (req)=>{
|
|||||||
return { id, googleId };
|
return { id, googleId };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBrew = (accessType)=>{
|
const getBrew = (accessType, fetchGoogle = true)=>{
|
||||||
// Create middleware with the accessType passed in as part of the scope
|
// Create middleware with the accessType passed in as part of the scope
|
||||||
return async (req, res, next)=>{
|
return async (req, res, next)=>{
|
||||||
// Get relevant IDs for the brew
|
// Get relevant IDs for the brew
|
||||||
@@ -45,7 +45,7 @@ const getBrew = (accessType)=>{
|
|||||||
stub = stub?.toObject();
|
stub = stub?.toObject();
|
||||||
|
|
||||||
// If there is a google id, try to find the google brew
|
// If there is a google id, try to find the google brew
|
||||||
if(googleId || stub?.googleId) {
|
if(fetchGoogle && (googleId || stub?.googleId)) {
|
||||||
let googleError;
|
let googleError;
|
||||||
const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType)
|
const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType)
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
@@ -327,8 +327,8 @@ const deleteBrew = async (req, res, next)=>{
|
|||||||
};
|
};
|
||||||
|
|
||||||
router.post('/api', asyncHandler(newBrew));
|
router.post('/api', asyncHandler(newBrew));
|
||||||
router.put('/api/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew));
|
router.put('/api/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew));
|
||||||
router.put('/api/update/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew));
|
router.put('/api/update/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew));
|
||||||
router.delete('/api/:id', asyncHandler(deleteBrew));
|
router.delete('/api/:id', asyncHandler(deleteBrew));
|
||||||
router.get('/api/remove/:id', asyncHandler(deleteBrew));
|
router.get('/api/remove/:id', asyncHandler(deleteBrew));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user