mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 15:03:07 +00:00
lint
This commit is contained in:
@@ -18,7 +18,7 @@ const { nanoid } = require('nanoid');
|
|||||||
const getBrew = (accessType)=>{
|
const getBrew = (accessType)=>{
|
||||||
// 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)=>{
|
||||||
// Set the id and initial potential google id, where the google id is present on the existing brew.
|
// Set the id and initial potential google id, where the google id is present on the existing brew.
|
||||||
let id = req.params.id, googleId = req.body?.googleId;
|
let id = req.params.id, googleId = req.body?.googleId;
|
||||||
|
|
||||||
// If the id is longer than 12, then it's a google id + the edit id. This splits the longer id up.
|
// If the id is longer than 12, then it's a google id + the edit id. This splits the longer id up.
|
||||||
@@ -26,7 +26,7 @@ const getBrew = (accessType)=>{
|
|||||||
googleId = id.slice(0, -12);
|
googleId = id.slice(0, -12);
|
||||||
id = id.slice(-12);
|
id = id.slice(-12);
|
||||||
}
|
}
|
||||||
// Try to find the document in the Homebrewery database -- if it doesn't exist, that's fine.
|
// Try to find the document in the Homebrewery database -- if it doesn't exist, that's fine.
|
||||||
let stub = await HomebrewModel.get(accessType === 'edit' ? { editId: id } : { shareId: id })
|
let stub = await HomebrewModel.get(accessType === 'edit' ? { editId: id } : { shareId: id })
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
if(googleId) {
|
if(googleId) {
|
||||||
@@ -181,7 +181,7 @@ const updateBrew = async (req, res)=>{
|
|||||||
|
|
||||||
brew.text = mergeBrewText(brew);
|
brew.text = mergeBrewText(brew);
|
||||||
|
|
||||||
if(brew.googleId && removeFromGoogle) {
|
if(brew.googleId && removeFromGoogle) {
|
||||||
// If the google id exists and we're removing it from google, set afterSave to delete the google brew and mark the brew's google id as undefined
|
// If the google id exists and we're removing it from google, set afterSave to delete the google brew and mark the brew's google id as undefined
|
||||||
afterSave = async ()=>{
|
afterSave = async ()=>{
|
||||||
return await deleteGoogleBrew(req.account, googleId, brew.editId, res)
|
return await deleteGoogleBrew(req.account, googleId, brew.editId, res)
|
||||||
@@ -189,7 +189,7 @@ const updateBrew = async (req, res)=>{
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
res.status(err?.status || err?.response?.status || 500).send(err.message || err);
|
res.status(err?.status || err?.response?.status || 500).send(err.message || err);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
brew.googleId = undefined;
|
brew.googleId = undefined;
|
||||||
} else if(!brew.googleId && saveToGoogle) {
|
} else if(!brew.googleId && saveToGoogle) {
|
||||||
@@ -245,7 +245,7 @@ const updateBrew = async (req, res)=>{
|
|||||||
if(!saved) return;
|
if(!saved) return;
|
||||||
// Call and wait for afterSave to complete
|
// Call and wait for afterSave to complete
|
||||||
const after = await afterSave();
|
const after = await afterSave();
|
||||||
if (!after) return;
|
if(!after) return;
|
||||||
|
|
||||||
res.status(200).send(saved);
|
res.status(200).send(saved);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user