A RESTful API built using Node.js, Express.js, and MongoDB for managing bookstore data. This project supports full CRUD operations with proper validation and follows REST API best practices.
- Add a new book
- Get all books
- Get a single book by ID
- Update book details
- Delete a book
- Input validation (title required, price must be positive)
- Proper HTTP status codes and JSON responses
- Clean MVC architecture
- Backend: Node.js, Express.js
- Database: MongoDB
- ODM: Mongoose
- Testing Tool: Postman
bookstore-api/
│
├── models/
│ └── Book.js
├── controllers/
│ └── bookController.js
├── routes/
│ └── bookRoutes.js
├── config/
│ └── db.js
├── index.js
├── .env
└── package.json
git clone https://github.com/your-username/bookstore-api.git
cd bookstore-api
npm install
PORT=5000
MONGO_URI=your_mongodb_connection_string
npm run dev
Server will start at:
http://localhost:8080
POST /api/books
GET /api/books
GET /api/books/:id
PUT /api/books/:id
PATCH /api/books/:id
DELETE /api/books/:id
{
"title": "Atomic Habits",
"author": "James Clear",
"price": 499,
"category": "Self-help",
"stock": 10
}| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request |
| 404 | Not Found |
- Add authentication (JWT)
- Search and filtering
- Pagination
- Deployment (Render / Railway)
Feel free to fork this repository and contribute.
Created by Your Name GitHub: https://github.com/just-aakash