Skip to content

[JITERA] Implement PATCH /books/:id Endpoint for Partial Book Updates

chi le requested to merge feat/add-patch-book-endpoint-1764673115 into feat/-1762918120

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/:id that points to the bookController.patchBook method. This allows clients to send partial updates to book records.

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.

Merge request reports