Develop an endpoint to handle requests to delete a blog post where it is only open to super admin. If the data is deleted successfully, it will be returned to the client with a '202' status. If an error occurs, an appropriate error status will be returned.
Acceptance Criteria
The endpoint deletes a blog post data.
The endpoint can be called only by a super admin.
Returns a 202 status code and the correct response body when blog is deleted successfully.
Returns a 404 status code and the correct response body when blog is not found.
Returns a 403 status code and the correct response body when a user that is not an admin tries to access the endpoint.
Returns an appropriate error message when an error occurs.
Requirements
[ ] Implement API endpoint for deleting blog posts.
[ ] Confirm deletion action to prevent accidental deletions.
[ ] Make sure the endpoint can only be called by a super admin
[ ] Ensure blog post safely deleted in the database.
[ ] Handle unexpected errors and return the appropriate status code.
Expected Outcome
Super Admin should be able to send a request to the backend to delete a blog post, with data temporarily removed and confirmation provided.
Description
Develop an endpoint to handle requests to delete a blog post where it is only open to super admin. If the data is deleted successfully, it will be returned to the client with a '202' status. If an error occurs, an appropriate error status will be returned.
Acceptance Criteria
202
status code and the correct response body when blog is deleted successfully.404
status code and the correct response body when blog is not found.403
status code and the correct response body when a user that is not an admin tries to access the endpoint.Requirements
Expected Outcome
Endpoints
[DELETE] /api/v1/blogs/:id
Description: Delete a Blog Data.
Path Parameters:
id
: The of the blog to be deleted. Default is1
.Success Response:
202 OK
Error Response:
500 Internal Server Error
Unauthorized User Response:
403 Forbidden
Unauthorized User Response:
404 Not Found
Invalid Method Response:
405 Method Not Allowed
Bad Request Response:
400 Bad Request
Testing
Test Scenarios
Successful Deletion of Blog Post
202
.No Blog Post Found
404
.Insufficient Permission
403
.Internal Server Error
500 Internal Server Error
status code.Invalid Id Parameters
id
parameters (e.g., non existing obect Id).400 Bad Request
status code.Invalid Method
405 Method Not Allowed
status code.