Giter VIP home page Giter VIP logo

e-commerce-cms's Introduction

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

2. POST /users/login

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

3. POST /users/adminRegister

Example Input (Request Body):

{
    "email": "[email protected]",
    "password": "123",
    "username": "example"
}

Response (201):

{
       message: "Admin created"
} 

4. POST /users/adminLogin

Example Input (Request Body):

{
    "email": "[email protected]",
    "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"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.