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": "[email protected]",
"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": "[email protected]",
"password": ,
"username": "example"
}
Response ERROR (400):
{
message: "Password is empty"
}
Example Input (Request Body) :
{
"email": "[email protected]",
"password": "123",
"username":
}
Response ERROR (400):
{
message: "Username is empty"
}
Example Input (Request Body):
{
"email": "[email protected]",
"password": "123"
}
Response (201):
{
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAsImVtYWlsIjoiZXhwYW1wbGVAZXhhbXBsZS5jb20iLCJpYXQiOjE1ODM1NjQyODF9.jvh2CegZlsax09Cp_wcSiOed_84BUJTHJuC1IDAiTXs"
}
Example Input (Request Body) :
{
"email": "[email protected]",
"password": ,
}
Response ERROR (400):
{
message: "Wrong email/password"
}
Example Input (Request Body):
{
"email": "[email protected]",
"password": "123",
"username": "example"
}
Response (201):
{
message: "Admin created"
}
Example Input (Request Body):
{
"email": "[email protected]",
"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 |
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"
}