-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description
Develop an endpoint to handle requests to retrieve all categories. This endpoint will return a list of categories to the client.
Acceptance Criteria
- The endpoint retrieves all categories that are not marked as deleted.
- Returns a
200 OKstatus code with the list of categories. - Handles errors appropriately, returning the correct status codes for unexpected issues.
Requirements
- Implement API endpoint for retrieving all categories.
- Ensure that the endpoint only retrieves categories that are not marked as deleted.
- Handle unexpected errors and return the appropriate status code.
Expected Outcome
- Users should be able to send a request to retrieve all categories.
- Users should receive a list of categories with appropriate status codes based on the outcome of the request.
Endpoints
[GET] /api/v1/categories
-
Description: Retrieves all categories that are not marked as deleted.
-
Success Response:
-
Status:
200 OK -
Body:
{ "categories": [ { "id": 1, "name": "Technology", "description": "Posts related to technology", "created_at": "2024-07-18T00:00:00Z", "updated_at": "2024-07-18T00:00:00Z" }, { "id": 2, "name": "Health", "description": "Posts related to health", "created_at": "2024-07-18T00:00:00Z", "updated_at": "2024-07-18T00:00:00Z" } ] }
-
-
Internal Server Error Response:
-
Status:
500 Internal Server Error -
Body:
{ "error": "Internal server error." }
-
Testing
Test Scenarios
-
Successful Retrieval of All Categories
- Ensure that the endpoint successfully retrieves all categories that are not marked as deleted.
- Verify that the response includes the list of categories and a
200 OKstatus code.
-
Internal Server Error
- Simulate an internal server error to raise an exception.
- Verify that the endpoint returns a
500 Internal Server Errorstatus code and an appropriate error message.
Metadata
Metadata
Assignees
Labels
No labels