Skip to content

erlangamara/e-commerce

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

e-commerce

E-Commerce

Deploy Link

https://oldie-music-admin.firebaseapp.com/

Server Documentation

Dependencies

Package Name Version
cors ^2.8.5
dotenv ^8.2.0
express 4.17.1
jsonwebtoken ^8.5.1
pg ^7.18.1
sequelize ^5.21.3
bcrypt ^4.0.1

Example .env

DB_USERNAME =
DB_PASSWORD =
SECRET =
PORT =

Default Port

SERVER = https://still-tundra-68355.herokuapp.com/
CLIENT = https://oldie-music-admin.firebaseapp.com/

Server

Tools: NodeJS, Express, sequelize, postgresql

USER

Url Method Description
/users/register POST Menambahkan user baru
/users/login POST Melakukan login dan mendaptkan token
/users/adminRegister POST Menambahkan admin baru
/users/adminLogin POST Melakukan login untuk admin

1. POST /users/register

Example Input (Request Body):

{
    "email": "example@example.com",
    "password": "123",
    "username": "example"
}

Response (201):

{
       access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAsImVtYWlsIjoiZXhwYW1wbGVAZXhhbXBsZS5jb20iLCJpYXQiOjE1ODM1NjQyODF9.jvh2CegZlsax09Cp_wcSiOed_84BUJTHJuC1IDAiTXs"
} 

Example Input (Request Body) :

{
    "email": ,
    "password": "123",
    "username": "example"	
}

Response ERROR (400):

{
	message: "Email is empty"
}

Example Input (Request Body) :

{
    "email": "example@example.com",
    "password": ,
    "username": "example"	
}

Response ERROR (400):

{
	message: "Password is empty"
}

Example Input (Request Body) :

{
    "email": "example@example.com",
    "password": "123",
    "username": 	
}

Response ERROR (400):

{
	message: "Username is empty"
}

2. POST /users/login

Example Input (Request Body):

{
    "email": "example@expample.com",
    "password": "123"
}

Response (201):

   {
       access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAsImVtYWlsIjoiZXhwYW1wbGVAZXhhbXBsZS5jb20iLCJpYXQiOjE1ODM1NjQyODF9.jvh2CegZlsax09Cp_wcSiOed_84BUJTHJuC1IDAiTXs"
   } 

Example Input (Request Body) :

{
    "email": "example@expample.com",
    "password": ,	
}

Response ERROR (400):

{
	message: "Wrong email/password"
}

3. POST /users/adminRegister

Example Input (Request Body):

{
    "email": "example_admin@example.com",
    "password": "123",
    "username": "example"
}

Response (201):

{
       message: "Admin created"
} 

4. POST /users/adminLogin

Example Input (Request Body):

{
    "email": "example_admin@example.com",
    "password": "123"
}

Response (201):

 {
       access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAsImVtYWlsIjoiZXhwYW1wbGVAZXhhbXBsZS5jb20iLCJpYXQiOjE1ODM1NjQyODF9.jvh2CegZlsax09Cp_wcSiOed_84BUJTHJuC1IDAiTXs"
   } 

Todo

Url Method Description
/products/ POST Menambahkan produk baru
/products/ GET Menampilkan list produk
/products/:id GET Menampilkan produk berdasarkan id
/products/:id PUT Melakukan edit ke produk
/products/:id DELETE Menghapus produk dari list
/products/cart GET Menampilkan cart
/products/addCart/:id POST Menambahkan rpoduk ke cart
/products/cart/:id DELETE Menghapus produk dari cart
/products/checkout/:id PUT Melakukan pembelian produk

1. POST /products

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA

}

Example Input (Request Body):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response (201):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Example Input:

{
	"name" : ,
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response ERROR (400):

{
	message: "Name is empty"
}

Example Input:

{
	"name" : "Gibson ES-335",
    "image_url" : ,
    "price": "75000000",
    "stock": "1"
}

Response ERROR (400):

{
	message: "Image url is empty"
}

Example Input:

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": ,
    "stock": "1"
}

Response ERROR (400):

{
	message: "Price is empty"
}

Example Input:

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": 
}

Response ERROR (400):

{
	message: "Stock is empty"
}

Example Input (Request Headers):

{

}

Example Input (Request Body):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response ERROR (401):

{
	message: "jwt must be provided"
}

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8

}

Example Input (Request Body):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response ERROR (403):

{
	message: "not authorized"
}

2. GET /products

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA

}

Response (200):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1",
    "createdAt": "2020-03-20T07:15:12.149Z",
    "updatedAt": "2020-03-20T07:15:12.149Z",
}

Example Input (Request Headers) :

{
    	
}

Response ERROR (401):

{
	message: "jwt must be provided"
}

3. GET /products/:id

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Response (201):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1",
    "createdAt": "2020-03-20T07:15:12.149Z",
    "updatedAt": "2020-03-20T07:15:12.149Z",
}

Example Input (Request Headers):

{

}

Response ERROR (404):

{
	message: "jwt must be provided"
}

4. PUT /products/:id

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Example Input (Request Body):

{
	"name" : "Gibson ES-335 1965",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response (200):

{
	"name" : "Gibson ES-335 1965",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8

}

Example Input (Request Body):

{
	"name" : "Gibson ES-335 1965",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response ERROR (403):

{
	message: "not authorized"
}

Response ERROR (404):

	"error not found"

5. DELETE /products/:id

Example Input (Request Headers):

{
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Response (200):

{
	"name" : "Gibson ES-335",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1",
    "createdAt": "2020-03-20T07:15:12.149Z",
    "updatedAt": "2020-03-20T07:15:12.149Z",
}

Example Input (Request Headers):

{

}

Response ERROR (401):

{
	message: "jwt must be provided"
}

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8

}

Example Input (Request Body):

{
	"name" : "Gibson ES-335 1965",
    "image_url" : "www.test.com",
    "price": "75000000",
    "stock": "1"
}

Response ERROR (403):

{
	message: "not authorized"
}

Response ERROR (404):

{
	"error not found"
}

6. GET /cart

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Response (200):

{
    "id": 25,
    "email": "test2@mail.com",
    "password": "$2b$10$0s2YrbBETxp3THXXuIcTpOlFEBtqz4fVPQmL2NBZPx8Ksbp8Unx1u",
    "role": "user",
    "username": "test2",
    "createdAt": "2020-03-25T03:01:18.995Z",
    "updatedAt": "2020-03-25T03:01:18.995Z",
    "Products": [
        {
            "id": 23,
            "name": "Gibson ES-335 1965",
            "image_url": "https://images.reverb.com/image/upload/s--khVlIviQ--/a_exif,c_limit,e_unsharp_mask:80,f_auto,fl_progressive,g_south,h_1600,q_80,w_1600/v1375890834/lyeysuhotdqn5e4olepq.jpg",
            "price": 75000000,
            "stock": 2,
            "createdAt": "2020-03-18T17:30:56.731Z",
            "updatedAt": "2020-03-25T14:06:14.886Z",
            "UserProduct": {
                "UserId": 25,
                "ProductId": 23,
                "createdAt": "2020-03-26T03:13:45.097Z",
                "updatedAt": "2020-03-26T03:13:45.097Z"
            }
        }
    ]
}

7. POST /addCart/:id

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Response (201):

{
    "message": "Product added to your cart"
}

8. DELETE /addCart/:id

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Response (200):

{
    "message": "Removed from your cart"
}

9. PUT /checkout/:id

Example Input (Request Headers):

{
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}

Example Input (Request Body):

{
  "stock": 1
}

Response (200):

{
    "message": "Thankyou for purchasing"
}

About

E-Commerce

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Vue 81.2%
  • JavaScript 14.6%
  • HTML 4.2%