From fec1766e269925a06f5e3761c02307d2cd179653 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Mon, 21 Nov 2022 16:21:36 -0600 Subject: [PATCH] switch fetchGoogle to stubOnly --- server/homebrew.api.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 484ca8bb5..b46bbd1ab 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -27,7 +27,7 @@ const getId = (req)=>{ return { id, googleId }; }; -const getBrew = (accessType, fetchGoogle = true)=>{ +const getBrew = (accessType, stubOnly = false)=>{ // Create middleware with the accessType passed in as part of the scope return async (req, res, next)=>{ // Get relevant IDs for the brew @@ -45,7 +45,7 @@ const getBrew = (accessType, fetchGoogle = true)=>{ stub = stub?.toObject(); // If there is a google id, try to find the google brew - if(fetchGoogle && (googleId || stub?.googleId)) { + if(!stubOnly && (googleId || stub?.googleId)) { let googleError; const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType) .catch((err)=>{ @@ -59,7 +59,7 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } // If after all of that we still don't have a brew, throw an exception - if(!stub && fetchGoogle) { + if(!stub && !stubOnly) { throw 'Brew not found in Homebrewery database or Google Drive'; } @@ -324,8 +324,8 @@ const deleteBrew = async (req, res, next)=>{ }; router.post('/api', asyncHandler(newBrew)); -router.put('/api/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew)); -router.put('/api/update/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew)); +router.put('/api/:id', asyncHandler(getBrew('edit', true)), asyncHandler(updateBrew)); +router.put('/api/update/:id', asyncHandler(getBrew('edit', true)), asyncHandler(updateBrew)); router.delete('/api/:id', asyncHandler(deleteBrew)); router.get('/api/remove/:id', asyncHandler(deleteBrew));