Implement an endpoint to delete a book record by ID. ### **User Story** **Given** a book exists **When** I request deletion **Then** the book should be removed from the database ### **Endpoint** ``` DELETE /book/:id ``` ### **Tasks** * [x] Create `DELETE /book/:id` route * [x] Validate `id` param * [x] Check if book exists * [x] Return `404 Not Found` if not * [x] Delete record from DB * [x] Return success response * [x] Add Swagger documentation * [x] Define path param * [x] Add responses (200, 404) ### **Acceptance Criteria** * [x] Valid ID deletes the book * [x] Non-existent ID returns `404` * [x] Invalid ID returns `400` * [x] Response confirms deletion * [x] Swagger UI supports testing ### **Testing Steps** * [x] Create a book * [x] Copy its `id` * [x] Send DELETE request: ``` /book/:id ``` * [x] Verify response is `200 OK` * [x] Run SQL query: ```sql SELECT * FROM books WHERE id = <your_id>; ``` * [x] Confirm record no longer exists ### **Definition of Done** * [x] Endpoint implemented * [x] Record deleted from DB * [x] Error handling works * [x] Swagger docs updated * [x] Code linted and formatted
Implement an endpoint to delete a book record by ID.
User Story
Given a book exists
When I request deletion
Then the book should be removed from the database
Endpoint
Tasks
Create
DELETE /book/:idrouteValidate
idparamCheck if book exists
404 Not Foundif notDelete record from DB
Return success response
Add Swagger documentation
Acceptance Criteria
404400Testing Steps
Create a book
Copy its
idSend DELETE request:
Verify response is
200 OKRun SQL query:
Confirm record no longer exists
Definition of Done