/e-commerce

Primary LanguageJavaScript

E-Commerce

API Documentation

List of Product Routes:

Route HTTP Header(s) Body Description
/product GET none none Get All Products
/product/:id GET none none Get One Product
/product POST token name: String,
description: String,
stock: Number,
price: Number
Create New Product
/product/:id PATCH token name: String,
description: String,
stock: Number,
price: Number
Update Product
/product/:id DELETE token none Delete Product

Get All Products

URL http://shopify-server.ricky-works.online/product
HTTP (Method) GET
Params none
Headers none
Data none
Success Response status: 200, Data:
[
{
"_id": 1,
"name": "Black Mug",
"description": "A Black Mug For All Your Needs",
"stock": 200,
"price": 20 000,
}
]
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

Get One Product

URL http://shopify-server.ricky-works.online/product/:id
HTTP (Method) GET
Params id: String
Headers none
Data none
Success Response status: 200, Data:
{
"_id": 1,
"name": "Black Mug",
"description": "A Black Mug For All Your Needs",
"stock": 200,
"price": 20 000,
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}
Error Response 2 status: 404, Data:
{
"msg": "Product Not Found"
}

Create New Product

URL http://shopify-server.ricky-works.online/product
HTTP (Method) POST
Params none
Headers token: String
Data name: String,
description: String
stock: Number,
price: Number
Success Response status: 201, Data:
{
"response": "Product Created Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

Update Product

URL http://shopify-server.ricky-works.online/product/:id
HTTP (Method) PATCH
Params id: String
Headers token: String
Data name: String
description: String
stock: Number
price: Number
Success Response status: 200, Data:
{
"response": "Product Updated Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

Delete Product

URL http://shopify-server.ricky-works.online/product/:id
HTTP (Method) DELETE
Params id: String
Headers token: String
Data none
Success Response status: 200, Data:
{
"response": "Product Removed Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

List Of Cart Routes:

Route HTTP Header(s) Body Description
/cart/:product_id POST token: String quantity: String Add To Cart
/cart/:product_id PATCH token: String quantity: String Update Quantity
/cart/:product_id DELETE token: String none Remove From Cart

Add To Cart

URL http://shopify-server.ricky-works.online/cart/:product_id
HTTP (Method) POST
Params product_id: String
Headers token: String
Data quantity: String
Success Response status: 201, Data:
{
"response": "Item Added To Cart Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

Update Quantity

URL http://shopify-server.ricky-works.online/cart/:product_id
HTTP (Method) PATCH
Params product_id: String
Headers token: String
Data quantity: String
Success Response status: 200, Data:
{
"response": "Item Updated Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

Remove From Cart

URL http://shopify-server.ricky-works.online/cart/:product_id
HTTP (Method) DELETE
Params product_id: String
Headers token: String
Data none
Success Response status: 200, Data:
{
"response": "Item Removed Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

List Of Transaction Routes:

Route HTTP Header(s) Body Description
/transaction/:product_id POST token: String quantity: String Create Transaction
/transaction/:product_id DELETE token: String none Delete Transaction

Create Transaction

URL http://shopify-server.ricky-works.online/transaction/:product_id
HTTP (Method) POST
Params product_id: String
Headers token: String
Data quantity: String
Success Response status: 201, Data:
{
"response": "Item Added To Transaction Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

Delete Transaction

URL http://shopify-server.ricky-works.online/transaction/:product_id
HTTP (Method) DELETE
Params product_id: String
Headers token: String
Data none
Success Response status: 201, Data:
{
"response": "Item Removed From Transaction Successfully"
}
Error Response status: 401, Data :
{
"msg": "You Are Unauthorized"
}

List Of User Routes:

Route HTTP Header(s) Body Description
/user/register POST none username: String,
email: String,
password: String
Register New User
/user/login POST none email: String, password: String Log In Old User

Register New User

URL http://shopify-server.ricky-works.online/user/register
Method POST
Params none
Headers none
Data username: String,
email: String,
password: String
Success Response status: 201 , Data:
{
"username": "Jeff",
"email": "jeff@gmail.com"
"token":"$2a$10$vT.0e3mTW3xqIJsdrR0QmedgHfCSsTOkFVDCmk392M6pl9B0l.QmO"
"role": "customer"
}
Error Response status: 400, Data:
{
"msg": "Username Is Already Taken"
}

Login User

URL http://shopify-server.ricky-works.online/user/login
Method POST
Params none
Headers none
Data email: String,
password:string
Success Response status: 200 , Data:
{
"username": "Admin",
"email": "admin@gmail.com"
"token":"$2a$10$vT.0e3mTW3xqIJsdrR0QmedgHfCSsTOkFVDCmk392M6pl9B0l.QmO"
"role": "admin"
}
Error Response status:400 , Data:
{
"msg": "Incorrect Email / Password"
}

List Of Superuser Routes:

Route HTTP Header(s) Body Description
/superuser POST token: String username: String
email: String
password: String
Register New Admin
/superuser/:id DELETE token: String none Remove Admin

Register Admin

URL http://shopify-server.ricky-works.online/superuser
Method POST
Params none
Headers token: String
Data username: String
email: String
password: String
Success Response status: 201 , Data:
{
"response": "Admin Registered Successfully"
}
Error Response status:400 , Data:
{
"msg": "You Are Unauthorized"
}

Remove Admin

URL http://shopify-server.ricky-works.online/superuser/:id
Method DELETE
Params id: String
Headers token: String
Data none
Success Response status: 200 , Data:
{
"response": "Admin Removed Successfully"
}
Error Response status:400 , Data:
{
"msg": "You Are Unauthorized"
}

Usage

Make sure you have Node.js and npm installed in your computer, and then run these commands:

$ git clone https://github.com/AudrickOng/e-commerce.git
$ cd e-commerce
$ npm install
$ npm run dev

Server Link

Access the website via http://shopify.ricky-works.online