This pull request introduces a new endpoint to our book management application, allowing users to retrieve all books belonging to a specific category. It also includes validation to ensure the requested category exists and comprehensive tests to cover the new functionality.
Summary
Added validation to the /books/category/:categoryName endpoint to check if the category exists before attempting to retrieve books. If the category does not exist, it returns a 404 status with an "Invalid category" message.
Implemented a new test suite bookCategory.test.js to ensure the endpoint behaves as expected. This includes tests for:
Successfully retrieving books by a valid category.
Handling requests for categories that do not exist with appropriate error messages.
Ensuring the response structure matches the expected JSON format, including all relevant book details except for id and _v.
Modified app.js to include the new validation logic and handle requests to the new endpoint.
Utilized chai and chai-http for writing and executing the tests.
Files added/modified:
app.js (modified)
test/bookCategory.test.js (added)
Fixes #9.
🎉 Latest improvements to Sweep:
New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
PR Feedback: 👍
Description
This pull request introduces a new endpoint to our book management application, allowing users to retrieve all books belonging to a specific category. It also includes validation to ensure the requested category exists and comprehensive tests to cover the new functionality.
Summary
/books/category/:categoryName
endpoint to check if the category exists before attempting to retrieve books. If the category does not exist, it returns a404
status with an "Invalid category" message.bookCategory.test.js
to ensure the endpoint behaves as expected. This includes tests for:id
and_v
.app.js
to include the new validation logic and handle requests to the new endpoint.chai
andchai-http
for writing and executing the tests.Files added/modified:
app.js
(modified)test/bookCategory.test.js
(added)Fixes #9.
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can:
This is an automated message generated by Sweep AI.