This is web api for an ecommerce store. This api covers major features of an ecommerce shop like user registration, product upload, categories, orders and authentication.
To run this project first you need to setup your enviroment for nodejs. After that you need to:
- Clone this project.
- Use
npm install
command to install all the packages.
- Setup and Configure mongb locally.
- Use
mongod
command to start mongodb server using terminal. - Use
node app.js
command to start the node server on localhost.
- Setup and Configure mongodb atlas for your project.
- Setup and Configure server(heroku) for your app.
- Create and Update
.env
file accordingly. - For Deployment, follow the guidelines provided by heroku or any other server you are using.
This api is not hosted on live server for now. Some routes of api are protected so you will need to login/register before using them.
For testing the api you can use Postman.
This application is built with the following:
This api allows all CRUD operations and it has following endpoints:
Reuest | Path | Body Parameters | Request Parameters | Explanation |
---|---|---|---|---|
GET | http://localhost:3000/api/v1/users | - | - | get all users |
GET | http://localhost:3000/api/v1/users/:id | - | user id | get user with id |
GET | http://localhost:3000/api/v1/users/get/count | - | - | get user count |
POST | http://localhost:3000/api/v1/users | all user fields | - | add user to database |
POST | http://localhost:3000/api/v1/users/register | all user fields | - | register a user |
POST | http://localhost:3000/api/v1/users/login | email, password | - | user login |
DELETE | http://localhost:3000/api/v1/users/:id | - | user id | delete user with specified id |
Reuest | Path | Body Parameters | Request Parameters | Explanation |
---|---|---|---|---|
GET | http://localhost:3000/api/v1/categories | - | - | get all categories |
GET | http://localhost:3000/api/v1/categories/:id | - | category id | get category with id |
PUT | http://localhost:3000/api/v1/categories/:id | name, icon, color | category id | update category |
POST | http://localhost:3000/api/v1/categories | all category fields | - | add category to database |
DELETE | http://localhost:3000/api/v1/categories/:id | - | category id | delete category with specified id |
Reuest | Path | Body Parameters | Request Parameters | Explanation |
---|---|---|---|---|
GET | http://localhost:3000/api/v1/products | - | - | get all products |
GET | http://localhost:3000/api/v1/products/:id | - | id | get product with id |
GET | http://localhost:3000/api/v1/products/get/count | - | - | get total product count |
GET | http://localhost:3000/api/v1/products/get/featured/:count | - | count | get specified number of featured product |
POST | http://localhost:3000/api/v1/products | all product fields, (product image upload) | - | add product to database |
PUT | http://localhost:3000/api/v1/products/:id | category id, all product field, (product image upload) | product id | update product |
PUT | http://localhost:3000/api/v1/products//gallery-images/:id | multiple product images upload | product id | add gallery images of product |
DELETE | http://localhost:3000/api/v1/products/:id | - | product id | delete product with specified id |
Reuest | Path | Body Parameters | Request Parameters | Explanation |
---|---|---|---|---|
GET | http://localhost:3000/api/v1/orders | - | - | get all orders |
GET | http://localhost:3000/api/v1/orders/:id | - | order id | get order with id |
GET | http://localhost:3000/api/v1/orders/get/userorder/:userid | - | user id | get all order of specific user |
GET | http://localhost:3000/api/v1/orders/get/totalsales | - | - | get total sales |
GET | http://localhost:3000/api/v1/orders/get/count | - | - | get order count |
PUT | http://localhost:3000/api/v1/orders/:id | status | order id | update order status |
POST | http://localhost:3000/api/v1/orders | all order fields, product, product quantity | - | add order to database |
DELETE | http://localhost:3000/api/v1/orders/:id | - | order id | delete order with specified id |
Distributed under the MIT License. See LICENSE for more information.