mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-19 03:22:45 +00:00
Refactor /api/lock/count
This commit is contained in:
@@ -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;
|
|
||||||
});
|
|
||||||
return res.json({
|
|
||||||
count
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return res.json({ status: 'ERROR', detail: 'Unable to get lock count', 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)=>{
|
router.post('/api/lock/:id', mw.adminOnly, async (req, res)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user