This is a simple ecommerce backend API build with Node.js, Express, and MySQL.
-
Clone the repository.
git clone https://github.com/bhardwaj-shubham/ecommerce-api.git
-
Install the dependencies.
npm install
-
Configure the project.
- Create a
.env
file in the root directory. Add the environment variables from the.env.sample
file.
- Create a
-
Create a MySQL database.
- Create a MySQL database with the name given in
.env.sample
.
- Create a MySQL database with the name given in
-
Start the application.
npm run dev
-
The API will be running on
http://localhost:4000
.
The API has the following routes:
-
For products:
- GET
/api/v1/products/all-products
: Get all products. - GET
/api/v1/products/:productId
: Get a product by ID. - POST
/api/v1/products/add-product
: Create a new product. - PUT
/api/v1/products/:productId
: Update a product by ID. - POST
/api/v1/products/:productId/reviews
: Create a Review of product. - POST
/api/v1/products/buy/
: Buy a product. - DELETE
/api/v1/products/:productId
: Delete a product by ID.
- GET
-
For users:
- POST
/api/v1/users/signup
: Create a new User. - POST
/api/v1/users/login
: Login a user. - POST
/api/v1/users/logout
: Logout a user. - GET
/api/v1/users/current-user
: Get current a user. - POST
/api/v1/users/refresh-token
: Refresh a user token. - POST
/api/v1/users/change-password
: Change password of a user. - POST
/api/v1/users/update-account
: Update account of a user. - GET
/api/v1/users/purchase-history
: Get purchase history of a user.
- POST
-
For sellers:
- POST
/api/v1/sellers/signup
: Create a new Seller. - POST
/api/v1/sellers/login
: Login a seller. - POST
/api/v1/sellers/logout
: Logout a seller. - GET
/api/v1/sellers/current-seller
: Get current a seller. - POST
/api/v1/sellers/refresh-token
: Refresh a seller token. - POST
/api/v1/sellers/change-password
: Change password of a seller. - PATCH
/api/v1/seller/update-account
: Update account of a seller. - GET
/api/v1/sellers/products
: Get all products of a seller.
- POST
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Commit your changes.
- Push to the branch.
- Submit a pull request.
This project is licensed under the MIT License.