mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-22 18:17:52 +00:00
Small tweaks and linting
This commit is contained in:
@@ -15,12 +15,12 @@ const getGoodBrewTitle = (text) => {
|
||||
const ending = text.indexOf('\n', titlePos);
|
||||
return text.substring(titlePos + 2, ending);
|
||||
} else {
|
||||
return _.find(text.split('\n'), line => line);
|
||||
return _.find(text.split('\n'), (line)=>line);
|
||||
}
|
||||
};
|
||||
|
||||
const newBrew = (req, res)=>{
|
||||
let authors = (req.account) ? [req.account.username] : [];
|
||||
const authors = (req.account) ? [req.account.username] : [];
|
||||
|
||||
const newHomebrew = new HomebrewModel(_.merge({},
|
||||
req.body,
|
||||
@@ -45,8 +45,6 @@ const newBrew = (req, res) => {
|
||||
});
|
||||
};
|
||||
|
||||
router.post('/api', newBrew);
|
||||
|
||||
const updateBrew = (req, res)=>{
|
||||
HomebrewModel.get({ editId: req.params.id })
|
||||
.then((brew)=>{
|
||||
@@ -75,17 +73,16 @@ const updateBrew = (req, res) => {
|
||||
});
|
||||
};
|
||||
|
||||
router.put('/api/update/:id', updateBrew);
|
||||
router.put('/api/:id', updateBrew);
|
||||
|
||||
const deleteBrew = (req, res)=>{
|
||||
HomebrewModel.find({ editId: req.params.id }, (err, objs)=>{
|
||||
if (!objs.length || err)
|
||||
if(!objs.length || err) {
|
||||
return res.status(404).send('Can not find homebrew with that id');
|
||||
}
|
||||
|
||||
const brew = objs[0];
|
||||
|
||||
// Remove current user as author
|
||||
if(req.account) {
|
||||
// Remove current user as author
|
||||
brew.authors = _.pull(brew.authors, req.account.username);
|
||||
brew.markModified('authors');
|
||||
}
|
||||
@@ -106,8 +103,11 @@ const deleteBrew = (req, res) => {
|
||||
});
|
||||
};
|
||||
|
||||
router.get('/api/remove/:id', deleteBrew);
|
||||
router.post('/api', newBrew);
|
||||
router.put('/api/:id', updateBrew);
|
||||
router.put('/api/update/:id', updateBrew);
|
||||
router.delete('/api/:id', deleteBrew);
|
||||
router.get('/api/remove/:id', deleteBrew);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user