0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +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)=>{
try {
const countLocksQuery = {
lock : { $exists: true }
};
const count = await HomebrewModel.countDocuments(countLocksQuery)
.then((result)=>{
return result;
});
return res.json({
count
const countLocksQuery = {
lock : { $exists: true }
};
const count = await HomebrewModel.countDocuments(countLocksQuery)
.catch((error)=>{
console.error(error);
return res.json({ status: 'ERROR', detail: 'Unable to get lock count', error });
});
} catch (error) {
console.error(error);
return res.json({ status: 'ERROR', detail: 'Unable to get lock count', error });
}
return res.json({ count });
});
router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{