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** * [x] Create `GET /books` route * [x] Create controller for fetching books * [x] Fetch all records from `books` table * [x] Handle empty state (return empty array) * [x] Return response with list of books * [x] Add Swagger documentation * [x] Define endpoint * [x] Add response schema (array of books) --- ### **Acceptance Criteria** * [x] Endpoint returns `200 OK` * [x] Response contains array of books * [x] Empty DB returns `[]` * [x] Swagger UI supports testing --- ### **Testing Steps** * [x] Ensure at least one book exists * [x] Send GET request to `/books` * [x] Verify response is `200 OK` * [x] Confirm response is an array * [x] Match data with DB: ```sql SELECT * FROM books; ``` --- ### **Definition of Done** * [x] Endpoint implemented * [x] Data fetched correctly * [x] Swagger docs updated * [x] 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