Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/satyam-software-developer/ecommerce-api
e-commerce-api created with nodejs for backend web development.
https://github.com/satyam-software-developer/ecommerce-api
body-parser dotenv expressjs git github mongodb mongodb-atlas mongoose morgan-middleware nodejs nodemon postman render vscode
Last synced: about 8 hours ago
JSON representation
e-commerce-api created with nodejs for backend web development.
- Host: GitHub
- URL: https://github.com/satyam-software-developer/ecommerce-api
- Owner: satyam-software-developer
- License: mit
- Created: 2024-11-18T15:19:37.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-01-12T08:18:27.000Z (about 1 month ago)
- Last Synced: 2025-01-12T09:24:23.593Z (about 1 month ago)
- Topics: body-parser, dotenv, expressjs, git, github, mongodb, mongodb-atlas, mongoose, morgan-middleware, nodejs, nodemon, postman, render, vscode
- Language: JavaScript
- Homepage: https://ecommerce-api-3-8uvj.onrender.com/products
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## E-Commerce-API
The E-Commerce API provides a simple yet powerful backend solution for managing product inventory. Built with Node.js, Express.js, and MongoDB, it supports key operations like creating, updating, listing, and deleting products. The API is designed for scalability and ease of integration, with a clean, modular structure for future expansion. This project serves as a solid foundation for building more complex e-commerce systems.
1. Demo: https://drive.google.com/file/d/1e29FwQJemFnSfZupkSPV2L7AtaWgeuX3/view?usp=sharing
2. Hosted link: https://ecommerce-api-3-8uvj.onrender.com/products# ABOUT
This is an E-commerce API made using Node.Js & MongoDB.
STEPS TO USE THE API:
1. run the "npm init" command on the terminal in this project directory
2. start the server using node app.js
3. Open postman
4. Make a GET request on localhost:3000/products
5. The products should be visibleSTEPS TO CREATE A NEW PRODUCT:
1. start the server using node app.js
2. Open postman
3. put localhost:3000/products/create as the URL.
4. Select the Body tab below the URL textarea and then select x-www-form-URL-encoded
5. Add name & quantity as the keys and set the desired values for the keys.
6. Make a POST request.
7. If you receive the message saying a new product added successfully then you have done everything correctly.
8. The product is created. Check it out by making a GET request at localhost:3000/productsSTEPS TO DELETE A PRODUCT:
1. copy the object ID of the product you want to delete.
2. add the id after localhost:3000/products/
3. Make a DELETE request.
4. You will receive a message saying deleted successfully.STEPS TO UPDATE THE QUANTITY OF A PRODUCT:
1. Copy the object ID of the product whose quantity you want to update
2. Put the id after localhost:3000/products/
3. After putting the id add /update_quantity/?number={x} in the URL where x is the number by which you want to increase or decrease the quantity.
4. the URL should be looking like localhost:3000/products/{id}/update_quantity/?number={x}
5. Make a POST request and you should get a message containing the updated product# Tech Stack
- Node.js
- Express.js
- MongoDB
- Mongoose# API Endpoints
1. Create a Product
- URL: /products/create
- Method: POST
- Request Body:
{
"name": "laptop",
"quantity": 10
}
- Response:
{
"data": {
"product": {
"name": "laptop",
"quantity": 10
}
}
}2. List Products
- URL: /products
- Method: GET
- Response:
{
"data": {
"products": [
{
"id": "1",
"name": "laptop",
"quantity": 10
},
{
"id": "2",
"name": "camera",
"quantity": 5
}
]
}
}3. Delete a Product
- URL: /products/:id
- Method: DELETE
- Response:
{
"data": {
"message": "product deleted"
}
}4. Update Product Quantity
- URL: /products/:id/update_quantity/?number=10
- Method: POST
- Response:
{
"data": {
"product": {
"id": "1",
"name": "laptop",
"quantity": 20
},
"message": "updated successfully"
}
}# Folder Structure
e-commerce-api/
├── models/
│ └── product.js # Mongoose schema for Product
├── controllers/
│ └── productsController.js # Contains all controller logic
├── routes/
│ └── products.js # Routes for product-related APIs
├── app.js # Entry point for the server
├── package.json # Project metadata and dependencies
└── README.md # Documentation## License
This project is licensed under the MIT License.
## Author
SATYAM KUMAR