[JITERA] Implement PATCH /books/:id Endpoint for Partial Book Updates
Created by: chi-jitera
Overview
This pull request implements the PATCH /books/:id endpoint to allow partial updates to book records. The service layer already supports this functionality through the patchBook method in services/bookService.js, and the controller is prepared to handle the request.
Changes
-
Updated
routes/bookRoutes.js:- Registered a new PATCH route for
/books/:idthat points to thebookController.patchBookmethod. This allows clients to send partial updates to book records.
- Registered a new PATCH route for
Code Changes
const express = require('express');
const bookController = require('../controllers/bookController');
const router = express.Router();
router.post('/books', bookController.createBook);
router.get('/books', bookController.getAllBooks);
router.get('/books/search', bookController.searchBooks);
router.get('/books/:id', bookController.getBookById);
router.put('/books/:id', bookController.updateBook);
// REGISTER PATCH endpoint for partial book update
router.patch('/books/:id', bookController.patchBook);
router.delete('/books/:id', bookController.deleteBook);
module.exports = router;
This change allows for more flexible updates to book records, improving the API's usability.