0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-03-25 01:58:11 +00:00

Refactor /api/lock/count

This commit is contained in:
G.Ambatte
2025-04-07 08:25:42 +12:00
parent 0a4ac7a35a
commit e2b38829f2

View File

@@ -165,21 +165,18 @@ router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
}); });
router.get('/api/lock/count', mw.adminOnly, async (req, res)=>{ router.get('/api/lock/count', mw.adminOnly, async (req, res)=>{
try {
const countLocksQuery = { const countLocksQuery = {
lock : { $exists: true } lock : { $exists: true }
}; };
const count = await HomebrewModel.countDocuments(countLocksQuery) const count = await HomebrewModel.countDocuments(countLocksQuery)
.then((result)=>{ .catch((error)=>{
return result; console.error(error);
}); return res.json({ status: 'ERROR', detail: 'Unable to get lock count', error });
return res.json({
count
}); });
} catch (error) {
console.error(error); return res.json({ count });
return res.json({ status: 'ERROR', detail: 'Unable to get lock count', error });
}
}); });
router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{ router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{