lbw-go

module
v0.0.0-...-ec4765f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: MIT

README

LBW-GO, GIN Restful-api Project starter

Golang restful-api project starter-kit with Gin and Postgresql (using pgx library). This starter project build using DDD model architect.

# NOTE: PROJECT is NOT READY yet.

Table of Content

  1. Quick Review
  2. Directory Structure
  3. Getting started
  4. TODO
1. Quick Review

The package used in this project:

  • Gin, most stared Go web framework on Github
  • pgx, the best PostgreSQL driver for Go
  • jwt, Jwt Authentication and Authorization
  • logrus, logger for access log, database log, and server log
  • viper, complete configuration solution
  • Air, Hot reload support for fast development
2. Directory Structure
|-- root/
|-- |-- cmd/
|-- |-- |-- app/
|-- |-- |-- |-- server/
|-- |-- |-- main.go
|-- |-- config/
|-- |-- |-- .config.yaml
|-- |-- dist/
|-- |-- internal/
|-- |-- |-- app/
|-- |-- |-- |-- account/
|-- |-- |-- |-- |-- datastore/
|-- |-- |-- |-- |-- handler/
|-- |-- |-- |-- |-- service/
|-- |-- |-- |-- |-- README.md
|-- |-- |-- |-- |-- router.go
|-- |-- |-- |-- mail/
|-- |-- |-- config/
|-- |-- |-- database/
|-- |-- |-- |-- sql/
|-- |-- |-- domain/
|-- |-- |-- pkg/
|-- |-- |-- |-- auth/
|-- |-- |-- |-- errors/
|-- |-- |-- |-- helper/
|-- |-- |-- |-- logger/
|-- |-- log/
|-- |-- vendor/
|-- |-- go.mod
|-- |-- go.sum
|-- |-- LICENSE
|-- |-- Makefile
|-- |-- README.md
3. Getting Started
copy config file

Before we run the app, make sure the config has been set. from the root directory, run

cp config/example.config.yaml .config.yaml
run app

to test application (with hot reload), run:

air

OR

run without hot reload:

make run
build app

To build the app, run:

make build
run test

To run the test, run:

make test

Show test coverage result on browser:

# make sure file 'proof.out already exist/ generated'
make show-test

Generate new test coverage and show result on browser:

make test-proof
4. TODO
  • Jwt Authentication and Authorization
  • Add Test
  • Add blog app

Directories

Path Synopsis
cmd
app
app/server
Package server
Package server
internal
app/account/datastore
datastore package auth.go - datastore layer for authentification
datastore package auth.go - datastore layer for authentification
app/account/handler
handler package auth.go - interaction/ handler layer for authentification
handler package auth.go - interaction/ handler layer for authentification
app/account/service
service package auth.go - service/ business layer for authentification
service package auth.go - service/ business layer for authentification
config
Package config - main configuration routine
Package config - main configuration routine
database
package database db.go - contain database pool connection preparation and validation for the established pool connection
package database db.go - contain database pool connection preparation and validation for the established pool connection
middleware
Middleware to prevent unauthorized access
Middleware to prevent unauthorized access
pkg/auth
Authentication routine with jwt
Authentication routine with jwt
pkg/errors
Package errors for authentication containing custom error for our app
Package errors for authentication containing custom error for our app
pkg/helper
Package helper for handling response to client
Package helper for handling response to client
pkg/logger
Logger module - It will create logfile for the server
Logger module - It will create logfile for the server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL