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
The request cannot be fulfilled due to bad syntax. General error when fulfilling the request would cause an invalid state. Domain validation errors, missing data, etc. are some examples.
- `401` Unauthorized
The request requires user authentication. If the request already included Authorization credentials, then this response indicates that authorization has been refused for those credentials. This happens when authentication is possible but has failed or not yet been provided.
- `404` Not Found 😥
The server has not found anything matching the Request-URI or the requested resource is not found.
- `500` Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.