0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Just renaming/rearranging variables

This commit is contained in:
Trevor Buckner
2021-08-26 23:09:56 -04:00
parent 1ed5c219ec
commit 1e8c285eef
2 changed files with 13 additions and 12 deletions

View File

@@ -163,7 +163,8 @@ GoogleActions = {
version : brew.version,
renderer : brew.renderer,
tags : brew.tags,
systems : brew.systems.join() }
systems : brew.systems.join()
}
},
media : {
mimeType : 'text/plain',

View File

@@ -19,6 +19,15 @@ const getGoodBrewTitle = (text)=>{
.slice(0, MAX_TITLE_LENGTH);
};
const excludePropsFromUpdate = (brew)=>{
// Remove undesired properties
const propsToExclude = ['views', 'lastViewed'];
for (const prop of propsToExclude) {
delete brew[prop];
};
return brew;
};
const mergeBrewText = (text, style)=>{
if(typeof style !== 'undefined') {
text = `\`\`\`css\n` +
@@ -61,19 +70,10 @@ const newBrew = (req, res)=>{
});
};
const cleanBrew = (brew)=>{
// Remove undesired properties
const undesiredPropertyNames=['views', 'lastViewed'];
for (const undesiredProperty of undesiredPropertyNames) {
delete brew[undesiredProperty];
};
return brew;
};
const updateBrew = (req, res)=>{
HomebrewModel.get({ editId: req.params.id })
.then((brew)=>{
const updateBrew = cleanBrew(req.body);
const updateBrew = excludePropsFromUpdate(req.body);
brew = _.merge(brew, updateBrew);
brew.text = mergeBrewText(brew.text, brew.style);
@@ -164,7 +164,7 @@ const updateGoogleBrew = async (req, res, next)=>{
try { oAuth2Client = GoogleActions.authCheck(req.account, res); } catch (err) { return res.status(err.status).send(err.message); }
const brew = cleanBrew(req.body);
const brew = excludePropsFromUpdate(req.body);
brew.text = mergeBrewText(brew.text, brew.style);
try {