Skip to content

just-aakash/bookstore-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore API

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.


🚀 Features

  • 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

🛠️ Tech Stack

  • Backend: Node.js, Express.js
  • Database: MongoDB
  • ODM: Mongoose
  • Testing Tool: Postman

📁 Project Structure

bookstore-api/
│
├── models/
│   └── Book.js
├── controllers/
│   └── bookController.js
├── routes/
│   └── bookRoutes.js
├── config/
│   └── db.js
├── index.js
├── .env
└── package.json

⚙️ Installation & Setup

1. Clone the repository

git clone https://github.com/your-username/bookstore-api.git
cd bookstore-api

2. Install dependencies

npm install

3. Create .env file

PORT=5000
MONGO_URI=your_mongodb_connection_string

4. Run the server

npm run dev

Server will start at:

http://localhost:8080

📌 API Endpoints

Add Book

POST /api/books

Get All Books

GET /api/books

Get Single Book

GET /api/books/:id

Update Book

PUT /api/books/:id
PATCH /api/books/:id

Delete Book

DELETE /api/books/:id

Example Request (POST)

{
  "title": "Atomic Habits",
  "author": "James Clear",
  "price": 499,
  "category": "Self-help",
  "stock": 10
}

📊 Status Codes

Code Meaning
200 Success
201 Created
400 Bad Request
404 Not Found

🧠 Future Improvements

  • Add authentication (JWT)
  • Search and filtering
  • Pagination
  • Deployment (Render / Railway)

🤝 Contributing

Feel free to fork this repository and contribute.


📬 Contact

Created by Your Name GitHub: https://github.com/just-aakash


About

A RESTful Bookstore API built with Node.js, Express, and MongoDB, supporting full CRUD operations with validation and proper HTTP status handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors