[JITERA] Implement Book Search Logic
Created by: chi-jitera
Overview
This pull request introduces the initial implementation of the book search functionality for the application. It includes the creation of a Mongoose model for books, a controller to handle fetching all books, and an Express router to define the /books endpoint.
Changes
-
Model Creation (
/models/book.js):- Created a Mongoose schema for the Book model, which includes fields for
title,author,publishedDate, andgenre. This schema will serve as the structure for book documents in the MongoDB database.
- Created a Mongoose schema for the Book model, which includes fields for
-
Controller Implementation (
/controllers/bookController.js):- Developed a controller function
getAllBooksthat retrieves all book records from the database. It includes error handling to manage any issues that arise during the database query.
- Developed a controller function
-
Route Definition (
/routes/bookRoutes.js):- Set up an Express router that defines the
/booksendpoint. This route is linked to thegetAllBookscontroller function, allowing clients to fetch the list of all books.
- Set up an Express router that defines the
These changes lay the groundwork for the book search feature and ensure that the application adheres to best practices in Node.js and Express development.