This is the backend project for an e-commerce application, built using Node.js and Express. It provides a set of RESTful API endpoints for managing products, categories, orders, users, and authentication.
- Node.js
- Express
- MongoDB (or your preferred database)
- JWT for authentication
- Node.js and npm installed
- MongoDB installed and running
-
Clone the repository:
git clone https://github.com/MrNewbie-KH/e-commerce-api.git cd e-commerce-api
-
Install the dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the following:PORT=3000 MONGODB_URI=mongodb://localhost:27017/e-commerce JWT_SECRET=your_jwt_secret
-
Start the server:
npm start
Once the server is running, you can interact with the API using tools like Postman.
- POST /api/auth/register: Register a new user
- POST /api/auth/login: Login a user
- GET /api/users: Get all users
- GET /api/users/:id: Get a single user
- PUT /api/users/:id: Update a user
- DELETE /api/users/:id: Delete a user
- GET /api/products: Get all products
- GET /api/products/:id: Get a single product
- POST /api/products: Create a new product
- PUT /api/products/:id: Update a product
- DELETE /api/products/:id: Delete a product
- GET /api/categories: Get all categories
- GET /api/categories/:id: Get a single category
- POST /api/categories: Create a new category
- PUT /api/categories/:id: Update a category
- DELETE /api/categories/:id: Delete a category
- GET /api/orders: Get all orders
- GET /api/orders/:id: Get a single order
- POST /api/orders: Create a new order
- PUT /api/orders/:id: Update an order
- DELETE /api/orders/:id: Delete an order
- GET /api/cart: Get the user's cart
- POST /api/cart: Add item to cart
- PUT /api/cart/:itemId: Update item in cart
- DELETE /api/cart/:itemId: Remove item from cart
- POST /api/payment: Process payment
- POST /api/upload: Upload a file
- GET /api/reviews/:productId: Get reviews for a product
- POST /api/reviews/:productId: Add a review for a product
- PUT /api/reviews/:reviewId: Update a review
- DELETE /api/reviews/:reviewId: Delete a review
- GET /api/wishlist: Get the user's wishlist
- POST /api/wishlist: Add item to wishlist
- DELETE /api/wishlist/:itemId: Remove item from wishlist
- GET /api/coupons: Get all coupons
- GET /api/coupons/:code: Get a single coupon by code
- POST /api/coupons: Create a new coupon
- PUT /api/coupons/:id: Update a coupon
- DELETE /api/coupons/:id: Delete a coupon
Make sure to set up your .env
file with the correct configuration for your environment.
If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Submit a pull request.
Feel free to modify this README file to better suit your project's needs.