working delete requested wine if admin

This commit is contained in:
Adrian Thompson
2020-09-01 10:17:17 +02:00
parent 1c95244850
commit a5ae46f5c3
4 changed files with 48 additions and 6 deletions

View File

@@ -9,11 +9,18 @@ const RequestedWine = require(path.join(
const Wine = require(path.join(
__dirname + "/../schemas/Wine"
));
const mustBeAuthenticated = require(path.join(
__dirname + "/../middleware/mustBeAuthenticated"
));
router.use((req, res, next) => {
next();
});
router.route("/request/").delete(mustBeAuthenticated, async (req, res) => {
await RequestedWine.deleteOne({wineId: req.body.id})
res.json(true);
})
router.route("/request").get(async (req, res) => {
const rWines = await RequestedWine.find({}).populate("wine")