[JITERA] Implement PATCH endpoint for updating a book by ID
Created by: kstayner
Overview
This pull request modifies the existing updateBook method in the BookController to support PATCH requests, allowing for partial updates of book information. This change aligns with RESTful API practices, where PATCH is used for updating only specific fields of a resource.
Changes Made
-
Updated
updateBookMethod:- The
updateBookmethod inbackend/src/controllers/bookController.jshas been modified to handle PATCH requests. - The method now accepts a request body that can contain only the fields that need to be updated, rather than requiring the entire book object.
- The
-
Service Layer Adaptation:
- Ensured that the
BookService.updateBookmethod is capable of processing partial updates. This involves checking which fields are present in the request and updating only those fields in the database.
- Ensured that the
-
Testing:
- Added unit tests to verify that the PATCH endpoint correctly updates only the specified fields of a book.
- Ensured that the existing PUT functionality remains intact and unaffected by this change.
This implementation enhances the flexibility of the API, allowing clients to update only the necessary fields without needing to send the entire book object.