E-Commerce
https://oldie-music-admin.firebaseapp.com/
| 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 |
DB_USERNAME =
DB_PASSWORD =
SECRET =
PORT =
SERVER = https://still-tundra-68355.herokuapp.com/
CLIENT = https://oldie-music-admin.firebaseapp.com/
Tools: NodeJS, Express, sequelize, postgresql
| 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 |
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"
}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"
}Example Input (Request Body):
{
"email": "example_admin@example.com",
"password": "123",
"username": "example"
}Response (201):
{
message: "Admin created"
} Example Input (Request Body):
{
"email": "example_admin@example.com",
"password": "123"
}Response (201):
{
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAsImVtYWlsIjoiZXhwYW1wbGVAZXhhbXBsZS5jb20iLCJpYXQiOjE1ODM1NjQyODF9.jvh2CegZlsax09Cp_wcSiOed_84BUJTHJuC1IDAiTXs"
} | 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 |
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"
}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_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"
}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"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"
}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"
}
}
]
}Example Input (Request Headers):
{
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}Response (201):
{
"message": "Product added to your cart"
}Example Input (Request Headers):
{
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}Response (200):
{
"message": "Removed from your cart"
}Example Input (Request Headers):
{
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJmYXV6YW5AZW1haWwuY29tIiwiaWF0IjoxNTgzMjI0NDUzfQ.f9xFh_GctsZvEDEgdlmMYU13CPOlOdD4Btme8oi0tgA
}Example Input (Request Body):
{
"stock": 1
}Response (200):
{
"message": "Thankyou for purchasing"
}