Simple digital distribution platform for purchasing and playing video games.
- Node.js
- MongoDB
JWT_SECRET
$ npm install
$ npm start
- URL:
GET
/
- Response:
200
OK
{ "page": "Home", "project": "E-commerce" }
- Description:
- Creates a new user
- URL:
POST
/register
- Body:
name
:String
(required)email
:String
(required)password
:String
(required)
- Success response:
201
Created
{
"_id": "...",
"name": "...",
"email": "...",
"password": "<hashed password>"
}
- Fail response(s):
400
Bad request500
Internal Server Error
- Description:
- Logs a user in
- URL:
POST
/login
- Body:
email
:String
(required)password
:String
(required)
- Success response:
200
OK
{
"token": "...",
"id": "...",
"email": "...",
}
- Fail response(s):
400
Bad request500
Internal Server Error
- Description:
- Create a product
- URL:
POST
/products
- Headers:
token
:String
(required)
- Body:
name
:String
(required)description
:String
(required)price
:Number
(required)featuredImg
:String
stock
:Number
tags
:Array
- Success response:
200
OK
{
"_id": "...",
"name": "...",
"description": "...",
"featuredImg": "...",
"stock": "...",
"tags": "...",
"price": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Get list of all products
- URL:
GET
/products
- Headers:
token
:String
(required)
- Success response:
200
OK
[
{
"_id": "...",
"name": "...",
"description": "...",
"featuredImg": "...",
"stock": "...",
"tags": "...",
"price": "...",
}
]
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Find one product
- URL:
get
/products/:productId
- Headers:
token
:String
(required)
- Success response:
200
OK
{
"_id": "...",
"name": "...",
"description": "...",
"featuredImg": "...",
"stock": "...",
"tags": "...",
"price": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Update one product
- URL:
PUT
/products/:productId
- Headers:
token
:String
(required)
- Body:
name
:String
(required)description
:String
(required)price
:Number
(required)featuredImg
:String
stock
:Number
tags
:Array
- Success response:
200
OK
{
"_id": "...",
"name": "...",
"description": "...",
"featuredImg": "...",
"stock": "...",
"tags": "...",
"price": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Delete one product
- URL:
DELETE
/products/:productId
- Headers:
token
:String
(required)
- Success response:
200
OK
{
"message": "Successfully deleted product.",
"id": "<productId>",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Adds one product into a cart model
- URL:
POST
/carts
- Headers:
token
:String
(required)
- Body:
product
:String
(required)
- Success response:
200
OK
{
"_id": "...",
"user": "<userId>",
"product": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Get list of all carts
- URL:
GET
/carts
- Headers:
token
:String
(required)
- Success response:
200
OK
{
"_id": "...",
"user": "<userId>",
"product": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Get list of all user's carts
- URL:
GET
/carts/myCart
- Headers:
token
:String
(required)
- Success response:
200
OK
{
"_id": "...",
"user": "<userId>",
"product": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Remove one product from user's cart
- URL:
DELETE
/carts/:cartId
- Headers:
token
:String
(required)
- Success response:
200
OK
{
"message": "Successfully deleted cart.",
"id": "<cartId>",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Adds one product into a cart model
- URL:
POST
/transactions
- Headers:
token
:String
(required)
- Body:
total
:Number
(required)products
:Array
- Success response:
200
OK
{
"_id": "...",
"user": "<userId>",
"total": "...",
"products": "...",
"deliveryStatus": false,
"createdAt": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Get list of all transactions
- URL:
GET
/transactions
- Headers:
token
:String
(required)
- Success response:
200
OK
[
{
"_id": "...",
"user": "<userId>",
"total": "...",
"products": "...",
"deliveryStatus": false,
"createdAt": "...",
}
]
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Get list of all user's transactions
- URL:
GET
/transactions/myTransaction
- Headers:
token
:String
(required)
- Success response:
200
OK
[
{
"_id": "...",
"user": "<userId>",
"total": "...",
"products": "...",
"deliveryStatus": false,
"createdAt": "...",
}
]
- Fail response(s):
401
Unauthorized500
Internal Server Error
- Description:
- Change delivery status purchsed products
- URL:
PUT
/transactions/:transactionId
- Headers:
token
:String
(required)
- Body:
deliveryStatus
:Boolean
(required)
- Success response:
200
OK
{
"_id": "...",
"user": "<userId>",
"total": "...",
"products": "...",
"deliveryStatus": false,
"createdAt": "...",
}
- Fail response(s):
401
Unauthorized500
Internal Server Error
{
"message": "<error message>"
}
400
Bad Request