go-template

This project is an example of a REST API project using the Go language and the implementation of other tools

MIT License

Stars
1
Committers
1

go-template

This project is an example of a REST API project using the Go language and the implementation of other tools, such as Auth with JWT, Basic Auth, Logger API, Cache, ORM SQL, Message Broker, Export Excel File, OTP Mechanism, Deploy with Docker, Clean Code (smell code checker by CodeScene), Unit Test, and so on.

Technology Used

  • Versioning using Git (See Git Installation)
  • Programming Language using Go 1.22 or later. (See Golang Installation)
  • DB using PostgreSQL 14 or later. (See PostgreSQL Installation)
  • Migration using ORM GORM. (See Documentation)
  • Cache Using Redis. (See Redis Installation)
  • Routing Using Gin (See Gin Framework Doc)
  • ORM Library using GORM. (See GORM Guides)
  • Auth using Golang-JWT. (See Golang-JWT Guides)
  • Message Broker using RabbitMQ. (See RabbitMQ Installation)
  • Clean Code check using CodeScene. (See CodeScene)
  • Deploy using Docker. (See Docker Installation)

Feature

Method Auth Endpoint Dec
GET no / Welcome API
POST no /api/v1/auth/sign-up Register user with role USER
POST yes /api/v1/root/auth/sign-up Register user with role USER or ADMIN, auth with super admin (root)
POST no /api/v1/auth/sign-in Login
PATCH yes /api/v1/users/:id Update User
GET yes /api/v1/users/:id Detail User
GET yes /api/v1/users List User, auth only admin or super admin (root)
PATCH yes /api/v1/users/change-password/:id Change Password
GET yes /api/v1/users/send-email-verify Send OTP Email verified
POST yes /api/v1/users/verified-email Verified email with otp
GET no /api/v1/users/request-reset-password/:id Send OTP Email forgot password
PATCH no /api/v1/users/validate-reset-password/:id Verified Reset password
GET yes /api/v1/logs List log activity history
GET yes /api/v1/logs/download Download xlx List log activity history
GET yes /api/v1/message/translate/id Translate text to language id (indonesia)
GET yes /api/v1/message/consumer Trigger manual consume queue rabbitMQ

Role

  • ROOT (role super admin) = create a user the first time the project is run, check here
  • ADMIN (role admin)
  • USER (role user)

Development Guide

Documentations

Postman API Documentation

Collection Using Postman

  • ./go-template.postman_collection.json

Installation

  • Clone this repo

        git clone https://github.com/adamnasrudin03/go-template.git
    
  • Copy .env.example to .env

        cp .env.example .env
    
  • Setup local database

  • If you using RabbitMQ, Please check or create queue for ./app/models/queue.go

  • Start service API

        go run main.go
    

Build project by docker

  • check ip address in terminal

        ipconfig
    
  • change data environment in file ./docker-compose.yml

  • build with docker compose

        docker-compose -f "docker-compose.yml" up -d --build 
    
    • with make file
        make docker
    

Coverage Unit Test

  • with make file
    make cover

Connect with me

Package Rankings
Top 6.83% on Proxy.golang.org