[JITERA] Add PATCH /books/:id route to bookRoutes
Created by: chi-jitera
Overview
This pull request introduces a new PATCH route for updating book records partially in the /routes/bookRoutes.js file. The new route is mapped to the existing patchBook controller function, which handles the logic for partial updates and validation.
Changes
-
Added PATCH /books/:id route:
- This route allows clients to send partial updates to a book's information. It is mapped to the
bookController.patchBookfunction, ensuring that the existing RESTful structure is maintained.
- This route allows clients to send partial updates to a book's information. It is mapped to the
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);
router.patch('/books/:id', bookController.patchBook); // New PATCH route added
router.delete('/books/:id', bookController.deleteBook);
module.exports = router;
This addition aligns with the existing API structure and leverages the already implemented service logic for handling partial updates and validation.