Creating MerryRiana Shop For Customer app, using express and Vuejs
MerryRiana Shop is an application for customers where they are able to purchase lots of products from 3 different categories and there is an Admin Page specialized ony for the admin.
This app has :
* RESTful endpoint for products's CRUD operation
* SPA based, Fast and Responsive
If you want to be the admin, then sign in with the following account:
Email : [email protected]
Password : mamakumama
Client URL : https://merryrianashop-8f0ad.web.app
Server URL : https://merryrianashop.herokuapp.com
Make sure you have Node.js and npm in your computer and then run `npm install`.
In order to get access to all of the routes, you will need a `JWT(JSON Web Token) Token` which will be generated automatically after you sign in successfully.
Run `nodemon app.js` to start the server.
Run `live-server --host=localhost` to start the client
Common case response if you are exploring all Products endpoint
Response (401) = { "msg": "User Not Authenticated" }
Response (403) = { "msg": "Forbidden Access" }
Response (500) = { "msg": "Internal Server Error" }
Request Header
Not needed
Request Body
{
"email" : "<your email>",
"password" : "<your password>"
}
Response (200)
{ "access_token" : "<your account access token>",
"email" : "<your email address>",
"name" : "<your email name>",
"role" : "<notAdmin>",
}
Response (400)
{ "error" : "LOGIN ERROR"
"message": "Invalid Email / Password"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Request Header
Not needed
Request Body
{
"email" : "<your email>",
"password" : "<your password>",
}
Response (201)
{ "access_token" : "<your account access token>",
"email" : "<your email address>",
"name" : "<your email name>",
"role" : "<SuperAdmin>",
}
Response (400)
{ "error" : "VALIDATION_ERROR"
"message": "Name required, password required, this is email is already taken, role required
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Request Header
Not needed
Request Body
{
"email" : "<your email>",
"password" : "<your password>",
}
Response (200)
{ "access_token" : "<your account access token>",
"email" : "<your email address>",
"name" : "<your email name>",
"role" : "<SuperAdmin>"
}
Response (400)
{ "error" : "LOGIN ERROR"
"message": "Invalid Email / Password"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Request Header
Not needed
Request Body
{
"email" : "<your email>",
"password" : "<your password>",
"name" : "<your name>",
}
Response (200)
{ "access_token" : "<your account access token>",
"email" : "<your email address>",
"name" : "<your email name>",
"role" : "<notAdmin>"
}
Response (400)
{ "error" : "SequelizeValidationError"
"message": "name required, Password required, Email required, Duplicate email, Invalid Email format"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Request Header
Not needed
Request Body
{
"id_token": "id_token"
}
Response (200)
{
access_token: access_token,
User:{
"name": "<User's name>",
"email": "<User's email>",
"password": "<User's password>",
"role" : "<notAdmin>"
}
}
Response (500)
{
"error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Get all products
Request Header
not needed
Request Body
Not needed
Response (200)
{
Product :[{
"id": "<product id>,
"name": "<product name>",
"image_url": "<product image_url>",
"price": "<product price>",
"stock": "<product stock>",
"category": "<product category>",
},
{
"id": "<product id>,
"name": "<product name>",
"image_url": "<product image_url>",
"price": "<product price>",
"stock": "<product stock>",
"category": "<product category>",
}]
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Get product with a specific id
Request Params
Products's ID
Request Header
{ access_token : <your account access token> }
Request Body
Not needed
Response (200)
{
Product :{
"id": "<product id>,
"name": "<product name>",
"image_url": "<product image_url>",
"price": "<product price>",
"stock": "<product stock>",
"category": "<product category>",
"User":{
email : : "<User's email>",
}
}
}
Response (400)
{
"error" : "DATA_NOT_FOUND"
"message": "Invalid id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Create new product
Request Header
{ access_token : <your account access token> }
Request Body
{
"name": "<title to get insert into>",
"category": "<category to get insert into>",
"stock": "<category to get insert into>",
"image_url": "<image_url to get insert into>",
"price": "<price to get insert into>",
"desc": "<image_url to get insert into>",
}
Response (201 - Created)
{
"name": "<Product name>",
"category": "<Product caaegory>",
"stock": "<Product stock>",
"image_url": "<Product image url>",
"desc": "<Product desc>",
}
Response (400)
{
"error" : "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Update products with specific id
Request Params
Products's ID
Request Header
{ access_token : <your account access token> }
Request Body
{
Product :{
"name": "<input product name>",
"image_url": "<input product image_url>",
"price": "<input product price>",
"stock": "<input product stock>",
"category" :"<input product category>",
}
}
Response (200)
{
Product :{
"name": "<edited product name>",
"image_url": "<edited product image_url>",
"price": "<edited product price>",
"stock": "<edited product stock>",
"category" :"<edited product category>",
}
}
Response (400)
{
"error" : "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (403)
{
"error" : "FORBIDDEN_ACCESS",
"message": "You are not authorized to access the file"
}
Response (500)
{
"error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Delete product with specific id
Request Params
Products's ID
Request Header
{ access_token : <your account access token> }
Request Body
Product's ID
Response (200)
{
product:[1]
}
Response (400)
{ "message": "Invalid Id" }
Response (403)
{
"error" : "FORBIDDEN_ACCESS",
"message": "You are not authorized to access the file"
}
Response (500)
{
"error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Purchase Product in Cart
Request Header
{ access_token : <your account access token> }
Request Body
{
Cart:{
UserId: <User's Id>,
ProductId: <Product's Id>,
qty: <Purchase amount>,
totalPrice: <Purchase Total Price>
}
}
Response (200)
{
"msg":"Checkout succeeded"
}
Response (400)
{ "error" : "OUT_OF_STOCK",
"message": "Product is currently running out of stock"
}
Response (400)
{ "error" : "INSUFFICIENT_STOCK",
"message": "<Product's name> only have/has <Product's stock> left"
}
Response (500)
{
"error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Get all User's Shopping Histories
Request Header
{
"access_token": "access_token"
}
Request Body
Not neeeded
Response (200)
{
"name": "<Product name>",
"category": "<Product caaegory>",
"stock": "<Product stock>",
"image_url": "<Product image url>",
"desc": "<Product desc>",
}
Response (400)
{
"error": "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Get all User's Products
Request Header
{
"access_token": "access_token"
}
Request Body
Not neeeded
Response (200)
{
"name": "<Product name>",
"category": "<Product caaegory>",
"stock": "<Product stock>",
"image_url": "<Product image url>",
"desc": "<Product desc>",
}
Response (400)
{
"error": "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Create User's Cart
Request Header
{
"access_token": "access_token"
}
Request Body
{
id: "<Product's ID>",
qty: "<User's quantity input>"
}
Response (200)
{
"name": "<Product name>",
"category": "<Product caaegory>",
"stock": "<Product stock>",
"image_url": "<Product image url>",
"desc": "<Product desc>",
}
Response (400)
{
"error": "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Get User's Cart
Request Header
{
"access_token": "access_token"
}
Request Body
{
not needed
}
Response (200)
{
"Cart":{
"UserId":"integer",
"ProductId": "integer",
"totalPrice": "integer",
"qty": "integer",
Product:{
{
"name": "<Product name>",
"category": "<Product caaegory>",
"stock": "<Product stock>",
"image_url": "<Product image url>",
"desc": "<Product desc>",
}
}
},
User:{
"name": "<User's name>",
"email": "<User's email>",
"password": "<User's password>"
}
}
Response (400)
{
"error": "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
edit User's Cart
Request Header
{
"access_token": "access_token"
}
Request Body
{
not needed
}
Response (200)
{
"productId": "integer",
"qty": "integer",
}
Response (400)
{
"error": "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}
Delete User's Cart
Request Header
{
"access_token": "access_token"
}
Request Body
{
"productId": "integer",
"qty": "integer",
}
Response (200)
{
"product": [1]
}
Response (400)
{
"error": "DATA_NOT_FOUND",
"message": "Invalid Id"
}
Response (500)
{ "error" : "UNKNOWN_ERROR",
"message": "Something went wrong"
}