mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 13:02:45 +00:00
Refactor /api/lock
This commit is contained in:
@@ -180,7 +180,7 @@ router.get('/api/lock/count', mw.adminOnly, async (req, res)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{
|
router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{
|
||||||
try {
|
|
||||||
const lock = req.body;
|
const lock = req.body;
|
||||||
lock.applied = new Date;
|
lock.applied = new Date;
|
||||||
|
|
||||||
@@ -198,14 +198,15 @@ router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{
|
|||||||
brew.lock = lock;
|
brew.lock = lock;
|
||||||
brew.markModified('lock');
|
brew.markModified('lock');
|
||||||
|
|
||||||
await brew.save();
|
await brew.save()
|
||||||
|
.catch((error)=>{
|
||||||
|
console.error(error);
|
||||||
|
return res.json({ status: 'ERROR', error, message: `Unable to set lock on brew ${req.params.id}` });
|
||||||
|
});
|
||||||
|
|
||||||
// console.log(`Lock applied to brew ID ${brew.shareId} - ${brew.title}`);
|
// console.log(`Lock applied to brew ID ${brew.shareId} - ${brew.title}`);
|
||||||
return res.json({ status: 'LOCKED', detail: `Lock applied to brew ID ${brew.shareId} - ${brew.title}`, ...lock });
|
return res.json({ status: 'LOCKED', detail: `Lock applied to brew ID ${brew.shareId} - ${brew.title}`, ...lock });
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
return res.json({ status: 'ERROR', error, message: `Unable to set lock on brew ${req.params.id}` });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.put('/api/unlock/:id', mw.adminOnly, async (req, res)=>{
|
router.put('/api/unlock/:id', mw.adminOnly, async (req, res)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user