This project is a RESTful API for an online bookstore built using Node.js and MongoDB. The API allows users to perform CRUD operations for books, search for books by title, author, or genre, add books to a shopping cart, place an order, and view order history.
.
├── public
│ ├── img
│ │ ├── Book fav.png
│ │ └── logo.png
│ ├── javascript
│ │ ├── admin.js
│ │ ├── adminLogin.js
│ │ └── index.js
│ └── stylesheets
│ ├── 404.css
│ ├── admin-login.css
│ ├── admin.css
│ └── index.css
├── src
│ ├── db
│ │ ├── models
│ │ │ ├── admin.js
│ │ │ ├── book.js
│ │ │ └── user.js
│ │ ├── mongoose.js
│ │ └── routers
│ │ ├── adminRouter.js
│ │ ├── bookRouter.js
│ │ └── userRouter.js
│ ├── index.js
│ ├── middleware
│ │ └── authentication.js
│ └── utils
│ └── SearchFilter.js
├── views
│ ├── 404.hbs
│ ├── admin.hbs
│ ├── adminLogin.hbs
│ └── index.hbs
├── .env
├── Dockerfile
├── docker-compose.yml
└── README.md
- Node.js
- MongoDB
- Docker (optional)
-
Clone the repository
https://github.com/shakil1819/REST-API-Bookstore-API-Using-CRUD-Operations.git cd REST-API-Bookstore-API-Using-CRUD-Operations
-
Install Dependencies
npm install
-
Configure MongoDB
Create a
.env
file in the root directory and add the MongoDB connection string:MONGODB_URI=mongodb://localhost:27017/bookstore
-
Build and Run the Application
npm start
Or using Docker:
docker-compose up --build
A Postman collection is provided to test the API endpoints. Import the Bookstore API.postman_collection.json
file into Postman to use the collection.
-
Admin Login
- URL:
http://localhost:3000/admin/login
- Method:
GET
- URL:
-
Admin Order History
- URL:
http://localhost:3000/admin/orders
- Method:
GET
- Headers:
Authorization: Bearer <Admin_Token>
- URL:
-
Admin Logout
- URL:
http://localhost:3000/admin/logout
- Method:
GET
- Headers:
Authorization: Bearer <Admin_Token>
- URL: