diff --git a/src/index.js b/src/index.js index 0562aec19dffe84f38d58cd53614bb9e56e36e12..0d18b90cb1b55c8ee3d108d257d9bd769daf301d 100644 --- a/src/index.js +++ b/src/index.js @@ -8,16 +8,16 @@ const app = express(); app.use(express.json()); app.get("/",(req,res) =>{ - console.log("testing") - res.send("Hello") + console.log("testing"); + res.send("Hello"); }) -const notificationRouter = require("./routes/notification") -app.use("/notification",notificationRouter) +const notificationRouter = require("./routes/notification"); +app.use("/notification",notificationRouter); app.listen(3001, function(){ - console.log("Notifcation Microservice is running ...") + console.log("Notifcation Microservice is running ..."); }) diff --git a/src/routes/notification.js b/src/routes/notification.js index a1b1388d2c96ebf5d1c933ab8ea981abd34f1c82..fbe6c86cee572f6bdfe07766625f32106c54ed72 100644 --- a/src/routes/notification.js +++ b/src/routes/notification.js @@ -30,7 +30,7 @@ router.get("/info/:id", async (req,res) =>{ router.delete("/delete/:id", async (req,res) =>{ - // delete the notifications + // delete a notification // grab the notification id // delete on the database try{ @@ -44,6 +44,23 @@ router.get("/info/:id", async (req,res) =>{ } }); + + router.delete("/delete/all/:id", async (req,res) =>{ + // delete all the notifications + // grab the user id + // delete on the database + try{ + const notifications = await Notification.deleteMany({userid:req.params.id}) + if(!notifications){ + return res.status(404).send(); + } + res.send(notifications); + }catch(error){ + res.status(500).send(error); + } + + }); + router.post("/create", async (req,res) => {