Skip to content

Commit

Permalink
SUP HARSHEEL
Browse files Browse the repository at this point in the history
  • Loading branch information
niccholasw committed Aug 29, 2024
1 parent aba6a23 commit a19a68c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/controllers/DonutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,15 @@ const putDonut = async (req: Request, res: Response) => {
}
};

export { getDonuts, createDonut, putDonut };
const deleteDonut = async (req: Request, res: Response) => {
try {
const { id } = req.params;
await DonutModel.findByIdAndDelete(id);
res.status(200).send("Donut deleted!");
} catch (error: any) {
console.error("Error:", error);
res.status(500).send("Internal server error");
}
};

export { getDonuts, createDonut, putDonut, deleteDonut };
3 changes: 3 additions & 0 deletions backend/routes/donutRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
getDonuts,
createDonut,
putDonut,
deleteDonut
} from "../controllers/DonutController";

const donutRoutes = Router();
Expand All @@ -13,4 +14,6 @@ donutRoutes.post("/", createDonut);

donutRoutes.put("/", putDonut);

donutRoutes.delete("/", deleteDonut);

export default donutRoutes;

0 comments on commit a19a68c

Please sign in to comment.