feature/delete-comments-by-user-id
#204
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: implement DELETE /comments/user/:userId route to delete all comments by user ID
Summary
This pull request implements the
DELETE /comments/user/:userId
route that allows authenticated users to delete all comments by a specific user ID. The route ensures that only the author of the comments or an admin can perform the deletion.Changes Implemented
deleteCommentsByUserId
method tocommentController
to handle deleting all comments by user ID.commentRoutes.js
forDELETE /comments/user/:userId
, protected byauthenticateToken
.404 Not Found
if no comments are found for the user.How to Test
Delete All Comments as Author or Admin:
DELETE
request tohttp://localhost:5000/comments/user/:userId
with a valid user ID and an admin token or a token belonging to the author in theAuthorization
header.{ message: 'All comments deleted successfully' }
.Unauthorized Deletion Attempt:
DELETE
request tohttp://localhost:5000/comments/user/:userId
with a valid user ID and a token from a different user (not the author and not an admin).403 Forbidden
.No Comments Found:
DELETE
request tohttp://localhost:5000/comments/user/:userId
with a valid user ID but no comments for that user.404 Not Found
.Example Request (Admin or Author)
Example Response
New Issues Created
test/202-create-unit-tests-for-delete-comments-by-user-id
#202 : Create unit tests for DELETE /comments/user/:userId route.docs/update-api-doc-for-delete-comments-user-route
#203 : Update API documentation to include DELETE /comments/user/:userId route.Resolves
feature/delete-comments-by-user-id
#153Branch
feature/delete-comments-by-user-id