Skip to content

erlangamara/e-commerce-cms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

e-commerce-cms

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

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"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 63.6%
  • Vue 34.9%
  • HTML 1.5%