Git Product home page Git Product logo

bookstoreapi's Introduction

Bookstore API

Description

Bookstore API is a RESTful service designed for managing a bookstore's inventory. It allows for adding, updating, deleting, and retrieving book records. The API also includes a notification feature to alert when a book's stock is low.

Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • Docker
  • Jest
  • MongoDB-Memory-Server

Installation

  1. Clone the repository:
    git clone https://github.com/lukacspapp/bookstoreAPI.git
    
  2. Navigate to the project directory:
    cd bookstoreAPI
    
  3. Ensure the correct Node.js version (20.9.0) is being used:
    nvm use 20.9.0
    
    Note: Install Node.js 20.9.0 if it's not already installed.
  4. Install dependencies:
    npm install
    
  5. Set up environment variables:
    • Create a .env file in the project root.
    • Add the following line:
      DB_URI=mongodb+srv://test:[email protected]/?retryWrites=true&w=majority
      

Running the Application

  1. Locally:
    npm run dev
    
  2. Using Docker:
    • Ensure Docker is installed on your machine.
    • Build and run the container:
      docker-compose up --build
  3. Using Docker image:
    • Pull the image from Docker Hub:
      docker pull papplukacs/bookstore-api:v1.0
      
    • Run the Docker image as a container (named bookstore-container)::
      docker run -p 3000:3000 --name bookstore-container papplukacs/bookstore-api:v1.0
      
  • The API will be available at http://localhost:3000/api/books
  • Stop the container using:
    docker stop <container-id> or docker stop bookstore-container
    
  • Remove the container using:
    docker rm <container-id> or docker rm bookstore-container
    

API Endpoints

  • GET /api/books: Retrieve all books in the inventory.
  • POST /api/books: Add a new book to the inventory.
  • GET /api/books/:id: Retrieve a book by its ID.
  • PATCH /api/books/:id: Update the details of a specific book.
  • DELETE /api/books/:id: Remove a book from the inventory.
  • GET /api/books/isbn/:isbn: Retrieve a book by its ISBN.

Testing

  • Run tests using:
    npm run test
    

API Documentation

Docker Image

Testing the API

  • Postman Collection is available here

Deployment

The Bookstore API is currently deployed on Render and can be accessed at the following base URL: https://bookstoreapi-ui68.onrender.com/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.