Open
Description
Description
This API endpoint allows an authorized user to edit a comment. This endpoint will validate input data and update the comment securely in the database.
Acceptance Criteria
- The endpoint allows a user to update a comment it created.
- The endpoint must be accessible via
/api/v1/comments/edit/{comment_id}
- The endpoint should accept HTTP PUT request
- The endpoint should ensure that the comment content field necessarily provided
- On successful validation of input data, the comment data should be updated.
- Returns 200 OK status code on success
Request Body application/json
{
"content": "string"
}
Success load
{
"message": "Comment successful updated",
"data": {
"id": "string",
"content": "string",
"update_at": "datetime"
}
}
Error load
{
"message": "Unauthorized request",
"status_code": 401
}
Purpose
The purpose of the endpoint is to give authorized users the ability to edit/update their comments.
Requirements
- Implement backend logic to handle comment edit submission
- Validate and sanitize input data
- Update comment data securely in the database
- Return appropriate response on success or failure
Expected Outcome
The endpoint should allow users to edit their comments successfully
Test
- Write unit tests to ensure the comment edit endpoint validates input correctly and updates the post securely.
- Perform a security test to ensure an unauthorized user can not update a comment.