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.
- Node.js
- Express.js
- MongoDB
- Mongoose
- Docker
- Jest
- MongoDB-Memory-Server
- Clone the repository:
git clone https://github.com/lukacspapp/bookstoreAPI.git
- Navigate to the project directory:
cd bookstoreAPI
- Ensure the correct Node.js version (20.9.0) is being used:
Note: Install Node.js 20.9.0 if it's not already installed.
nvm use 20.9.0
- Install dependencies:
npm install
- 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
- Create a
- Locally:
npm run dev
- Using Docker:
- Ensure Docker is installed on your machine.
- Build and run the container:
docker-compose up --build
- 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
- Pull the image from Docker Hub:
- 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
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.
- Run tests using:
npm run test
- API documentation is available on Confluence
- The Docker image is available on Docker Hub
- Postman Collection is available here
The Bookstore API is currently deployed on Render and can be accessed at the following base URL: https://bookstoreapi-ui68.onrender.com/