Skip to content

NandaRusfikri/Go-CRUD-JWT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Spec Go-CRUD-JWT

Create User

Request :

  • Method : POST
  • Endpoint : localhost:3000/user
  • Header :
    • Content-Type: application/json
    • Accept: application/json
  • Body :
form-data:
  name:nanda
  phone:12345678
  email:saya@nanda.dev
  username:nanda
  password:nanda

Response :

{
    "data": {
        "id": 3,
        "name": "nanda",
        "phone": "12345678",
        "email": "saya@nanda.dev",
        "username": "nanda",
        "password": "nanda",
        "CreatedAt": "2021-07-17 20:52:28.205326"
    }
}

Login

Request :

  • Method : POST
  • Endpoint : localhost:3000/login
  • Header :
    • Content-Type: application/json
    • Accept: application/json
  • Body :
form-data:
  username:nanda
  password:nanda

Response :

{
    "message": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.9xaLm7gtDvsvJ4wgmsAvZoOZfAgN7HUAc2htDY9hT2g",
    "data": [
        {
            "id": 3,
            "name": "kucing",
            "phone": "12345678",
            "email": "kucing@kucing.com",
            "username": "kucing",
            "gender": false
        }
    ]
}

Get List User

Request :

  • Method : GET

  • Endpoint : localhost:3000/users

  • Header :

    • Authorization: token
    • Accept: application/json
  • Params :

Query Params:
  limit: 2
  offset: 2
  name: "nanda"
  

Response :

{
    "count": 1,
    "data": [
        {
            "id": 1,
            "name": "nandarusfikri",
            "phone": "123456",
            "email": "nanda@nanda.com",
            "username": "bebek",
            "gender": false
        }
    ]
}

Delete User

Request :

  • Method : DELETE
  • Endpoint : localhost:3000/user?id=1
  • Header :
    • Authorization: token

Response :

{
    "data": {
        "id": 2,
        "DeletedAt": "2021-07-17 20:52:28"
    }
}

Update User

Request :

  • Method : PUT

  • Endpoint : localhost:3000/user

  • Header :

    • Authorization: token
  • Body :

form-data:
  name:nanda
  phone:12345678
  email:saya@nanda.dev
  username:nanda
  password:nanda

Response :

{
    "data": {
        "id": 3,
        "name": "nanda",
        "phone": "12345678",
        "email": "saya@nanda.dev",
        "username": "nanda",
        "password": "nanda",
        "CreatedAt": "2021-07-17 20:52:28.205326"
    }
}

Setup Database

create database nandarusfikri

About

curd REST API with Mysql Go JWT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages