Skip to content

aditya-singh-99/Library-Management-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System

This is a Node.js-based library management system using Express and Mongoose. It provides an API to manage users, books, and transactions (issuing and returning books).

Features

  • Manage users and books.
  • Issue and return books.
  • Search for books and retrieve information about transactions.

Prerequisites

  • Node.js
  • MongoDB

Installation

  1. Clone the repository:

    git clone https://github.com/aditya-singh-99/Library-Management-API.git
    cd Library-Management-API
    npm install
  2. Install the dependencies:

    npm install
  3. Set up environment variables:

    Copy the .env.sample file to create a .env file and update the necessary values:

    cp .env.sample .env

    Edit the .env file to add your MongoDB URIs:

    PORT=Your_Port
    MONGO_LIBRARY_URI=Library_DB_Connection_String
    MONGO_TRANSACTIONS_URI=Transactions_DB_Connection_String
  4. Start the server:

    npm install

Sure! Here are your API endpoints in Markdown format:

API Endpoints

Users

  • Get All Users
    • Endpoint: GET /users/all
    • Description: Retrieve all users.

Books

  • Get All Books

    • Endpoint: GET /books/all
    • Description: Retrieve all books in the library.
  • Search Books

    • Endpoint: GET /books/search
    • Description: Search books by name, category, or rent range.
    • Query Params:
      • name (optional) - Search by book name
      • category (optional) - Search by book category
      • rent_min (optional) - Minimum rent value
      • rent_max (optional) - Maximum rent value

Transactions

  • Issue Book

    • Endpoint: POST /transactions/issue
    • Description: Issue a book to a user.
    • Request Body:
      • name - User name
      • email - User email
      • phone - User phone
      • title - Book title
  • Return Book

    • Endpoint: POST /transactions/return
    • Description: Return a book issued to a user.
    • Request Body:
      • name - User name
      • email - User email
      • phone - User phone
      • title - Book title
  • Get Issued Books

    • Endpoint: GET /transactions/issued
    • Description: Retrieve books currently issued.
    • Query Params:
      • title (required) - Book title
  • Get Total Rent by Book

    • Endpoint: GET /transactions/book
    • Description: Retrieve the total rent generated by a specific book.
    • Query Params:
      • title (required) - Book title
  • Get Transactions by User

    • Endpoint: GET /transactions/user
    • Description: Retrieve all transactions related to a specific user.
    • Query Params:
      • email (required) - User email
  • Get Transactions in Date Range

    • Endpoint: GET /transactions/range
    • Description: Retrieve all transactions issued within a specific date range.
    • Query Params:
      • startDate (required) - Start date in MM-DD-YYYY format
      • endDate (required) - End date in MM-DD-YYYY format

Error Handling

All endpoints return appropriate HTTP status codes and error messages if an error occurs (e.g., 404 Not Found if a resource is not found).

Technologies Used

  • Node.js: Backend runtime.
  • Express: Web framework for Node.js.
  • Mongoose: MongoDB object modeling for Node.js.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published