Skip to content
Snippets Groups Projects
Commit e7b72df5 authored by Alan Chamathil's avatar Alan Chamathil
Browse files

Added delete all notification

parent e91a61cd
No related branches found
No related tags found
No related merge requests found
......@@ -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 ...");
})
......
......@@ -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) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment