1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-22 01:11:29 +00:00

Added tests for admin routes, lookup is working

This commit is contained in:
Scott Tolksdorf
2017-01-10 14:44:48 -05:00
parent cd2eb5fdce
commit e77532acef
3 changed files with 96 additions and 13 deletions

View File

@@ -29,26 +29,19 @@ router.delete('/admin/invalid', mw.adminOnly, (req, res, next)=>{
.catch(next);
});
router.get('/admin/lookup/:search', (req, res) => {
router.get('/admin/lookup/:search', mw.adminOnly, (req, res, next) => {
//search for mathcing edit id
//search for matching share id
// search for partial match
BrewData.get({editId : req.params.search})
.then((brew) => {
})
BrewData.get({ $or:[
{editId : { "$regex": req.params.search, "$options": "i" }},
{shareId : { "$regex": req.params.search, "$options": "i" }},
]})
.then((brews) => {
console.log(brews);
return res.json(brews);
})
})
.catch(next);
});
module.exports = router;