Skip to content

reizt/rest-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST Go

A simple REST API boilerplate written in Go, including authentication, database, and email.

Stack

  • 🔥 Framework: Echo
  • 🔄 ORM: Ent
  • 🥫 Database: PostgreSQL
  • 📬 Mailing: SendGrid
  • 🔑 Signing: JWT
  • 🥔 Hashing: Bcrypt

Directory structure

  • e2e - E2E test
  • ent - ent schema files
  • entities - Domain models
  • handlers - Echo handlers
  • iservices - Interface of services
  • iusecases - Interface of usecases
  • mservices - Structs for mocking services
  • router - Router
  • services - Implementation of services
  • usecases - Implementation of usecases

Try it

Set environment variables in .env

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
JWT_PRIVATE_KEY="xxx" # ECDSA private key
JWT_PUBLIC_KEY="xxx" # ECDSA public key
SENDGRID_API_KEY="xxx"
MAILER_FROM="xxx"

TEST_CLEAR_DATABASE=on
TEST_GENERATE_CODE_FIXED_VALUE=123456

Generate ent code

go generate ./ent

Launch database & API server

docker compose up

Run tests

go test -v ./...

About

🎉 Go basic REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages