-
Library Book Management
- Add, edit, and update books.
- Retrieve all books or filter books by category.
- Access the latest books with sorting and limit options.
-
Book Borrowing Management
- Borrow books by users.
- Retrieve borrowed books by user email.
- Return books and update the borrowing status.
-
User Authentication Integration JWT Integration
-
Routes designed to integrate with user authentication for personalized data retrieval.
-
The backend uses JSON Web Tokens (JWT) for secure user authentication. Users must register and log in to receive a token, which is then used to access protected API endpoints.
-
-
Filtering and Searching
- Filter books by category or retrieve user-specific borrowed books based on email.
-
Database Operations
- Optimized MongoDB queries with upsert and sorting capabilities.
- Ensure efficient data handling and avoid duplicate entries with query checks.
- GET
/books/all-books
- Fetch all book records. - POST
/books/add-book
- Add a new book record. - POST
/books/filter-by-category
- Filter books by category. - POST
/books/single-book
- Fetch details of a specific book by ID. - PUT
/books/update-book/:id
- Update an existing book by ID.
- GET
/books/borrowed-book/:email
- Fetch all borrowed books for a user by email. (Tried to implement aggrigation.) - POST
/books/borrow-book
- Borrow a new book for a user. - GET
/books/return-book/:id
- Return a specific borrowed book by ID.
- express - Web framework for building RESTful APIs.
- cors - Enable Cross-Origin Resource Sharing.
- dotenv - Manage environment variables.
- mongodb - MongoDB client for database operations.
- jsonwebtoken - Used for creating and verifying JSON Web Tokens (JWT) for secure user authentication.
- cookie-parser - Middleware for parsing cookies, used to manage JWTs stored in cookies for user sessions.
To securely manage environment variables, create a .env
file in the root of your project and include the following:
PORT = port number
DB_USER = username
DB_Pass = db pass
JWT_SECRET = use your own
NODE_ENV = development
Follow the steps below to set up and run the backend of the ReadSphere Library Management System locally:
- Clone the repository:
- Run npm install
- Run npm run start for node or npm run dev for nodemon