Implement an endpoint to fetch all book records from the database. ### **User Story** **Given** books exist in the database **When** I request all books **Then** I should receive a list of books ### **Endpoint** ``` GET /books ``` ### **Tasks** * [ ] Create `GET /books` route * [ ] Create controller for fetching books * [ ] Fetch all records from `books` table * [ ] Handle empty state (return empty array) * [ ] Return response with list of books * [ ] Add Swagger documentation * [ ] Define endpoint * [ ] Add response schema (array of books) --- ### **Acceptance Criteria** * [ ] Endpoint returns `200 OK` * [ ] Response contains array of books * [ ] Empty DB returns `[]` * [ ] Swagger UI supports testing --- ### **Testing Steps** * [ ] Ensure at least one book exists * [ ] Send GET request to `/books` * [ ] Verify response is `200 OK` * [ ] Confirm response is an array * [ ] Match data with DB: ```sql SELECT * FROM books; ``` --- ### **Definition of Done** * [ ] Endpoint implemented * [ ] Data fetched correctly * [ ] Swagger docs updated * [ ] Code linted and formatted
Implement an endpoint to fetch all book records from the database.
User Story
Given books exist in the database
When I request all books
Then I should receive a list of books
Endpoint
Tasks
Create
GET /booksrouteCreate controller for fetching books
Fetch all records from
bookstableHandle empty state (return empty array)
Return response with list of books
Add Swagger documentation
Acceptance Criteria
200 OK[]Testing Steps
Ensure at least one book exists
Send GET request to
/booksVerify response is
200 OKConfirm response is an array
Match data with DB:
Definition of Done