Skip to content

mrafid01/go-hacktiv8-Kanban-Board

Repository files navigation

Hacktiv8 Final Project 3

Kanban Board is an application for project management. User in this application will be able to add their tasks to the categories provided by an admin.

Installation

Requires Golang and MySQL

Config the .env first to connect into database

  • Clone repository
git clone https://github.com/mrafid01/go-hacktiv8-Kanban-Board.git
  • Change directory
cd go-hacktiv8-Kanban-Board
  • Run "main.go" file
go run main.go

Project Structure

Press to switch into the folder you want to go

📦go-hacktiv8-Kanban-Board
┣ 📂config
┃ ┣ 📜db.go
┃ ┗ 📜db_test.go
┣ 📂controller
┃ ┣ 📜category_controller.go
┃ ┣ 📜task_controller.go
┃ ┗ 📜user_controller.go
┣ 📂helper
┃ ┣ 📜error.go
┃ ┣ 📜error_test.go
┃ ┣ 📜response.go
┃ ┗ 📜response_test.go
┣ 📂middleware
┃ ┣ 📜jwt.go
┃ ┣ 📜jwt_test.go
┃ ┣ 📜middleware.go
┃ ┗ 📜middleware_test.go
┣ 📂model
┃ ┣ 📂entity
┃ ┃ ┣ 📜category.go
┃ ┃ ┣ 📜task.go
┃ ┃ ┗ 📜user.go
┃ ┣ 📂input
┃ ┃ ┣ 📜category_input.go
┃ ┃ ┣ 📜task_input.go
┃ ┃ ┗ 📜user_input.go
┃ ┗ 📂response
┃ ┃ ┣ 📜category_response.go
┃ ┃ ┣ 📜task_response.go
┃ ┃ ┗ 📜user_response.go
┣ 📂repository
┃ ┣ 📜category_repository.go
┃ ┣ 📜task_repository.go
┃ ┗ 📜user_repository.go
┣ 📂service
┃ ┣ 📜category_service.go
┃ ┣ 📜task_service.go
┃ ┗ 📜user_service.go
┣ 📜.env
┣ 📜Hacktiv8-KanbanBoard-Kelompok-7.postman_collection.json
┣ 📜README.md
┣ 📜go.mod
┣ 📜go.sum
┣ 📜main.go
┗ 📜project_environments.postman_environment.json

Postman Documentation Publish Version 🚀

LINK https://documenter.getpostman.com/view/23401248/2s8YsnYcEk

Endpoint

1. User

Create Admin Account

digunakan untuk membuat akun dengan role Admin.

  • Method: POST
  • Endpoint:
http://localhost:8080/users/admin
  • Request:
    • Request Body:
    {
        "full_name": "string",
        "email": "string",
        "password": "string"
    }
  • Response Body:
    • Status: 201,
    • Message: "created",
    • Body:
    {
      "data": {
          "id": integer,
          "full_name": "string",
          "email": "string",
          "created_at": "date"
    	}
    }

Create User Account

digunakan untuk membuat akun dengan role User member.

  • Method: POST
  • Endpoint:
http://localhost:8080/users/register
  • Request:
    • Request Body:
    {
        "full_name": "string",
        "email": "string",
        "password": "string"
    }
  • Response Body:
    • Status: 201,
    • Message: "created",
    • Body:
    {
      "data": {
          "id": integer,
          "full_name": "string",
          "email": "string",
          "created_at": "date"
    	}
    }

Notes: Untuk endpoint ini, role dari data user akan otomatis menjadi member. Boleh langsung diharcode di controllernya sebelum disimpan ke dalam database.

Login Account

digunakan untuk melakukan login atau autentikasi Member/Admin.

  • Method: POST
  • Endpoint:
http://localhost:8080/users/login
  • Request:
    • Request Body:
    {
        "email": "string",
        "password": "string"
    }
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "token": "jwt string"
    	}
    }

Notes: Pada endpoint ini, wajib melakukan logika user login yang dimana harus melakukan pengecekan email dan password user. Pengecekan password wajib dilakukan dengan bantuan library/package Bcrypt.

Update Account Data

digunakan untuk melakukan perubahan full name dan email akun.

  • Method: PUT
  • Endpoint:
http://localhost:8080/users/update-account
  • Request:
    • Headers: Authorization (Bearer Token)
    • Request Body:
    {
        "full_name": "string",
        "email": "string"
    }
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "full_name": "string",
          "email": "string",
          "updated_at": "date"
    	}
    }

Notes: Endpoint ini memerlukan proses autentikasi. Proses autentikasi wajib dilakukan dengan package/library JsonWebToken. Endpoint ini berguna untuk user mengupdate data dirinya.

Delete Account

digunakan untuk melakukan penghapusan akun.

  • Method: DELETE
  • Endpoint:
http://localhost:8080/users/delete-account
  • Request:
    • Headers: Authorization (Bearer Token)
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "message": "Your account has been successfully deleted"
    	}
    }

Notes: Endpoint ini memerlukan proses autentikasi. Proses autentikasi wajib dilakukan dengan package/library JsonWebToken. Endpoint ini berguna untuk user menghapus akunnya.

2. Categories

Notes: Seluruh endpoint untuk mengakses endpoint categories selain method GET memerlukan proses autentikasi menggunakan package JsonWebToken dan memerlukan proses autorisasi. Autorisasi diperlukan karena yang boleh mengakses endpoint categories selain method GET adalah user dengan role admin.

Create Categories Type (must an admin)

digunakan untuk membuat tipe kategori.

  • Method: POST
  • Endpoint:
http://localhost:8080/categories
  • Request:
    • Headers: Authorization (Bearer Token)
    • Request Body:
    {
        "type": "string"
    }
  • Response Body:
    • Status: 201,
    • Message: "created",
    • Body:
    {
      "data": {
          "id": integer,
          "type": "string",
          "created_at": "date"
    	}
    }

Get All Categories Type

digunakan untuk menampilkan semua tipe kategori.

  • Method: GET
  • Endpoint:
http://localhost:8080/categories
  • Request:
    • Headers: Authorization (Bearer Token)
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "type": "string",
          "updated_at": "date",
          "created_at": "date",
          "Tasks": {
              "id": integer,
              "title": "string",
              "description": "string",
              "user_id": integer,
              "category_id": integer,
              "created_at": "date",
              "updated_at": "date"
                  }
          }
    }

Update Categories Type (must an admin)

digunakan untuk melakukan perubahan tipe kategori.

  • Method: PATCH
  • Endpoint:
http://localhost:8080//categories/:categoryId
  • Request:
    • Headers: Authorization (Bearer Token)
    • Params: categoryId (integer)
    • Request Body:
    {
        "type": "string"
    }
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "type": "string",
          "updated_at": "date"
    	}
    }

Delete Categories Type (must an admin)

digunakan untuk melakukan penghapusan tipe kategori.

  • Method: DELETE
  • Endpoint:
http://localhost:8080//categories/:categoryId
  • Request:
    • Headers: Authorization (Bearer Token)
    • Params: categoryId (integer)
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "message": "Category has been successfully deleted"
    	}
    }

Notes: Seluruh endpoint untuk mengakses endpoint products memerlukan proses autentikasi menggunakan package JsonWebToken.

3. Tasks

Create Task

digunakan untuk membuat task baru.

  • Method: POST
  • Endpoint:
http://localhost:8080/tasks
  • Request:
    • Headers: Authorization (Bearer Token)
    • Request Body:
    {
        "title": "string",
        "description": "string",
        "category_id": integer
    }
  • Response Body:
    • Status: 201,
    • Message: "created",
    • Body:
    {
      "data": {
          "id": integer,
          "title": "string",
          "status": "boolean",
          "description": "string",
          "user_id": integer,
          "category_id": integer,
          "created_at": "date"
    	}
    }

Notes: Pada endpoint ini, harus dilakukan pengecekkan jika data category dengan id yang diberikan pada request body dengan field categoryId ada atau tidak pada database. Jika ada maka boleh disimpan ke database namun jika tidak ada maka harus melempar error. Kemudian untuk field status nilai awalnya akan otomatis menjadi false. Boleh langsung di hardcode di controllernya.

Get Tasks

digunakan untuk menampilkan task.

  • Method: GET
  • Endpoint:
http://localhost:8080/tasks
  • Request:
    • Headers: Authorization (Bearer Token)
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "title": "string",
          "status": "boolean",
          "description": "string",
          "user_id": integer,
          "category_id": integer,
          "created_at": "date",
          "User": {
                  "id": integer,
                  "email": "string",
                  "full_name": "string"
                  }
    	  }
    }

Update Task Title & Description

digunakan untuk melakukan pembaharuan task title dan task description.

  • Method: PUT
  • Endpoint:
http://localhost:8080/tasks/:taskID
  • Request:
    • Headers: Authorization (Bearer Token)
    • Params: taskId (integer)
    • Request Body:
    {
        "title": "string",
        "description": "string"
    }
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "title": "string",
          "description": "string",
          "status": "boolean",
          "user_id": integer,
          "category_id": integer,
          "updated_at": "date"
    	}
    }

Notes: Pada endpoint ini, perlu dilakukan proses autorisasi yang dimana user hanya boleh mengupdate task milikinya sendiri.

Update Task Status

digunakan untuk melakukan perubahan dari status task (true/false).

  • Method: PATCH
  • Endpoint:
http://localhost:8080/tasks/update-status/:taskID
  • Request:
    • Headers: Authorization (Bearer Token)
    • Params: taskId (integer)
    • Request Body:
    {
        "status": "boolean"
    }
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "title": "string",
          "description": "string",
          "status": "boolean",
          "user_id": integer,
          "category_id": integer,
          "updated_at": "date"
    	}
    }

Notes: Pada endpoint ini, perlu dilakukan proses autorisasi yang dimana user hanya boleh mengupdate task milikinya sendiri.

Update Task Category

digunakan untuk melakukan perubahan dari kategori task.

  • Method: PATCH
  • Endpoint:
http://localhost:8080/tasks/update-category/:taskID
  • Request:
    • Headers: Authorization (Bearer Token)
    • Params: taskId (integer)
    • Request Body:
    {
        "category_id": integer
    }
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "id": integer,
          "title": "string",
          "description": "string",
          "status": "boolean",
          "user_id": integer,
          "category_id": integer,
          "updated_at": "date"
    	}
    }

Notes: Pada endpoint ini, perlu dilakukan proses autorisasi yang dimana user hanya boleh mengupdate category id dari task milikinya sendiri. Lalu perlu dilakukan pengecekan jika category dengan id yang dinput oleh user ada di dalam database, maka proses dapat dilanjut. Namun jika tidak ada maka akan langsung melempar error.

Delete Task

digunakan untuk melakukan penghapusan task.

  • Method: DELETE
  • Endpoint:
http://localhost:8080/tasks/:taskID
  • Request:
    • Headers: Authorization (Bearer Token)
    • Params: taskId (integer)
  • Response Body:
    • Status: 200,
    • Message: "ok",
    • Body:
    {
      "data": {
          "message": "Task has been successfully deleted"
    	}
    }

Notes: Pada endpoint ini, perlu dilakukan proses autorisasi yang dimana user hanya boleh menghapus task miliknya sendiri.


Group 7

1. Alrico Rizki Wibowo  — GLNG-KS04-017

2. Ricky Khairul Faza  — GLNG-KS04-022

3. Muhammad Rafid  — GLNG-KS04-024

Pembagian Tugas

Alrico Rizki Wibowo

Alrico Rizki Wibowo mengerjakan beberapa hal berikut :

  • Endpoint : POST /tasks
  • Endpoint : GET /tasks
  • Endpoint : PUT /tasks/:taskId
  • Endpoint : PATCH /tasks/update-status/:taskId
  • Endpoint : PATCH /tasks/update-category/:taskId
  • Endpoint : DELETE /tasks/:taskId
  • Endpoint : POST /categories
  • Endpoint : GET /categories
  • Endpoint : PATCH /categories/:categoryId
  • Endpoint : DELETE /categories/:categoryId
  • Additional : README.md, .env, dan fix entity

Muhammad Rafid

Muhammad Rafid mengerjakan beberapa hal berikut :

  • Endpoint : POST /users/register
  • Endpoint : POST /users/admin
  • Endpoint : POST /users/login
  • Endpoint : PUT /users/update-account
  • Endpoint : DELETE /users/delete-account
  • Endpoint : POST /tasks
  • Endpoint : GET /tasks
  • Endpoint : PUT /tasks/:taskId
  • Endpoint : PATCH /tasks/update-status/:taskId
  • Endpoint : PATCH /tasks/update-category/:taskId
  • Endpoint : DELETE /tasks/:taskId
  • Helper : Generate & Validate Token, Validator, Middleware, dan Unit Test
  • Additional : Deploy API

Ricky Khairul Faza

Ricky Khairul Faza mengerjakan beberapa hal berikut :

  • Endpoint : POST /categories
  • Endpoint : GET /categories
  • Endpoint : PATCH /categories/:categoryId
  • Endpoint : DELETE /categories/:categoryId
  • Endpoint : POST /tasks
  • Endpoint : GET /tasks
  • Endpoint : PUT /tasks/:taskId
  • Endpoint : PATCH /tasks/update-status/:taskId
  • Endpoint : PATCH /tasks/update-category/:taskId
  • Endpoint : DELETE /tasks/:taskId
  • Additional : Postman Collection, README.md, dan db_test.go

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •