From cf6e3444e6913b30d2a9915df214da850d0bcc6f Mon Sep 17 00:00:00 2001 From: WilcoApp Date: Tue, 16 Apr 2024 13:39:26 +0000 Subject: [PATCH] Initial commit --- backend/routes/api/comments.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/backend/routes/api/comments.js b/backend/routes/api/comments.js index c41a3138c..47b0bc591 100644 --- a/backend/routes/api/comments.js +++ b/backend/routes/api/comments.js @@ -3,35 +3,3 @@ const mongoose = require("mongoose"); const Comment = mongoose.model("Comment"); module.exports = router; - -/** - * @route GET /api/comments - * @desc Get all comments - * @access Public - */ -router.get("/", (req, res, next) => { - Comment.find() - .then(comments => { - return res.json({ comments: comments.map(comment => comment.toJSONFor()) }); - }) - .catch(next); -}); - -/** - * @route DELETE /api/comments/:comment - * @desc Delete a comment - * @access Public - * @param {string} req.params.comment - The ID of the comment to be deleted - */ -router.delete("/:comment", async (req, res, next) => { - try { - const comment = await Comment.findById(req.comment._id); - if (!comment) { - return res.sendStatus(404); - } - await comment.remove(); - return res.sendStatus(204); - } catch (error) { - next(error); - } -});