This project is a Node.js and Express.js-based backend for an e-commerce platform. It utilizes MongoDB as the database and provides CRUD RESTful APIs for managing products, users, cart, wishlist, blogs, and orders.
- Node.js
- Express.js
- MongoDB
git clone
cd e-commerce-backend
npm install
Create a .env file in the root directory and define the following variables:
PORT=3000
MONGODB_URI= 'your-mongodb-uri'
npm run dev
Once the server is up and running, you can make HTTP requests to the provided APIs to manage products, users, cart, wishlist, blogs, and orders.
GET /api/products - Retrieve all products
GET /api/products/:id - Retrieve a specific product by ID
POST /api/products - Create a new product
PUT /api/products/:id - Update a product
DELETE /api/products/:id - Delete a product
GET /api/users/:id - Retrieve a specific user by ID
POST /api/users - Create a new user
PUT /api/users/:id - Update a user
DELETE /api/users/:id - Delete a user
GET /api/cart/:userId - Retrieve the cart for a specific user
POST /api/cart/:userId - Add an item to the cart for a specific user
PUT /api/cart/:userId/:productId - Update the quantity of an item in the cart for a specific user
DELETE /api/cart/:userId/:productId - Remove an item from the cart for a specific user
GET /api/wishlist/:userId - Retrieve the wishlist for a specific user
POST /api/wishlist/:userId - Add a product to the wishlist for a specific user
DELETE /api/wishlist/:userId/:productId - Remove a product from the wishlist for a specific user
GET /api/blogs - Retrieve all blogs
GET /api/blogs/:id - Retrieve a specific blog by ID
POST /api/blogs - Create a new blog
PUT /api/blogs/:id - Update a blog
DELETE /api/blogs/:id - Delete a blog
GET /api/orders/:userId - Retrieve all orders for a specific user
POST /api/orders/:userId - Create a new order for a specific user
GET /api/orders/:userId/:orderId - Retrieve a specific order for a specific user
PUT /api/orders/:userId/:orderId - Update an order for a specific user
DELETE /api/orders/:userId/:orderId - Cancel an order for a specific user
Contributions are welcome. Please submit a pull request explaining the changes you've made.