0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-28 04:52:40 +00:00

basic functionality

This commit is contained in:
Víctor Losada Hernández
2024-01-22 23:52:42 +01:00
parent da699e999f
commit 66fd56fccb
3 changed files with 94 additions and 52 deletions

View File

@@ -78,7 +78,26 @@ router.get('/admin/lookup/:id', mw.adminOnly, async (req, res, next) => {
});
/* Searches for matching title, also attempts to partial match */
router.get('/admin/archive/:title', mw.adminOnly, async (req, res, next) => {
try {
const brews = await HomebrewModel.find({
title: { $regex: req.params.title, $options: 'i' },
published: true
}).exec();
if (!brews || brews.length === 0) {
// No published documents found with the given title
return res.status(404).json({ error: 'Published documents not found' });
}
return res.json(brews);
} catch (error) {
console.error(error);
return res.status(500).json({ error: 'Internal Server Error' });
}
});
/* Find 50 brews that aren't compressed yet */
router.get('/admin/finduncompressed', mw.adminOnly, (req, res)=>{