Skip to content

cahyowhy/go-basic-rest-api-revisit

Repository files navigation

GO BASIC REST API REVISIT

WIP

Basic Rest API Golang

Package Description
Fiber Fast router based on golang/fasthttp
Gorm ORM
GoDotEnv .env lib
Faker faker (for seeding)
Uuid generate uuid
JWT GO json web token
Validator json validator

How to run on your local

  1. copy example.env into .env, Fill with yours value
  2. create your database name from .env DB value
  3. add type user_role on your db
      CREATE TYPE user_role AS ENUM ( 'ADMIN', 'USER');
  4. install air to achieve live reload
  5. or if you won't use air. you can run with go run .

How to test

  1. run
    ./run_test.sh
    this will run test and generate code coverage

How to db:?

  1. run seeder
    go run cmd/seeder/main.go 
  2. run migrate
    go run cmd/migrate/main.go 
  3. run delete all data from table
    go run cmd/delete_all_row/main.go

Folder Structure

.
└── go-basic-rest-api-revisit/
    ├── cmd/
    │   └── seeder   #db seeder
    │   └── migrate  #drop current existing db then create new
    ├── config       #.env var value, json validator
    ├── fake         #data faker
    ├── database     #get database instance
    ├── handler      #rest api handler / controller
    ├── service      #rest api service [for bussiness logic]
    ├── middleware   #rest api middleware, before visiting controller
    ├── app          #app instance (init -> apply routes -> run)
    ├── model        #rest api model
    └── util         #buch off helper function

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published