Membuat Content Management System untuk e-commerce E-Commerce-CMS with name Tokoku. This app has:
- POST /login
- GET /products
- POST /products
- GET /products/:id
- PUT /products/:id
- DELETE /products/:id
Login to Tokoku
Request Header
not needed
Request Body
{
"email": "<email to get insert into>",
"password": "<password to get insert into>"
}Response (200)
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJmYXVkemFuIiwiaWF0IjoxNTk4OTU1OTk2fQ.-bZ3Gi4AXPQMtrHfbxJ605On57u4gRXfU0ok88aIW94"
}Response (400 - Bad Request)
{
"message": "Invalid email or password"
}Response (500 - Internal Server Error)
{
"message": "Internal Server Error"
}Show all Tokoku products
Request Header
{
"access_token": "<your access token>"
}Request Body
not needed
Response (200)
{
"id": "<id_of_the_product>",
"name": "<product_name>",
"image_url": "<product_image_url>",
"price": "<product_price>",
"stock": "<product_stock>",
"createdAt": "2020-09-09T14:55:06.648Z",
"updatedAt": "2020-09-09T15:30:58.690Z",
}Response (401 - Not Authenticated)
{
"message": "Doesnt recognize user.."
}Response (500 - Internal server error)
{
"message": "Internal Server Error"
}Create new products
Request Header
{
"access_token": "<your access token>"
}Request Body
{
"name": "<name to get insert into>",
"image_url": "<image_url to get insert into>",
"price": "<price to get insert into>",
"stock": "<stock to get insert into>"
}Response (201 - Created)
{
"id": "<given id by system>",
"name": "<posted name>",
"image_url": "<posted image_url>",
"price": "<posted price>",
"stock": "<posted stock>",
"createdAt": "2020-03-20T07:15:12.149Z",
"updatedAt": "2020-03-20T07:15:12.149Z",
}Response (401 - Not Authenticated)
{
"message": "Doesnt recognize user.."
}Response (400 - Bad Request)
{
"message": "Please fill the field!, Do not input value under 1!"
}Find detail product by ID
Request Header
{
"access_token": "<your access token>"
}Request Body
not needed
Response (200)
{
"id": 1,
"name": "<product_name>",
"image_url": "<product_image_url>",
"price": "<product_price>",
"stock": "<product_stock>",
"createdAt": "2020-09-09T14:55:06.648Z",
"updatedAt": "2020-09-09T15:30:58.690Z",
}Response (401 - Not Authenticated)
{
"message": "Doesnt recognize user.."
}Response (404 - Not Found)
{
"message": "Not Found"
}Update product by ID
Request Header
{
"access_token": "<your access token>"
}Request Body
{
"name": "<name to get insert into>",
"image_url": "<image_url to get insert into>",
"price": "<price to get insert into>",
"stock": "<stock to get insert into>"
}Response (200)
{
"id": "<selected id>",
"name": "<updated name>",
"image_url": "<updated image_url>",
"price": "<updated price>",
"stock": "<updated stock>",
"createdAt": "2020-03-20T07:15:12.149Z",
"updatedAt": "2020-03-20T07:15:12.149Z",
}Response (400 - Bad request)
{
"message": "Please fill the field!, Do not input value under 1!"
}Response (404 - Not Found)
{
"message": "Not Found"
}Response (500 - Internal Server Error)
{
"message": "Internal Server Error"
}Delete product data by ID
Request Header
{
"access_token": "<your access token>"
}Request Body
not needed
Response (200)
{
"id": 1,
"name": "<product_name>",
"image_url": "<product_image_url>",
"price": "<product_price>",
"stock": "<product_stock>",
"createdAt": "2020-09-09T14:55:06.648Z",
"updatedAt": "2020-09-09T15:30:58.690Z",
}Response (404 - Not Found)
{
"message": "Not Found"
}Response (500 - Internal Server Error)
{
"message": "Internal Server Error"
}