TanZng / simple-go

Simple API using hex architecture and domain pattern written in Go 🐹

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pet API

You need:

🐹 Go v1.18+

πŸ‹ Docker v20.10.14+

πŸ¦‘ docker-compose v1.28.2+

πŸ“¦ Used packages

Package Version Type
gofiber/fiber v2.31.0 Core
go-gorm/gorm v1.23.3 Database
stretchr/testify v1.7.0 Test
uber-go/zap v1.21.0 Logs
google/uuid v1.3.0 Utils
joho/godotenv v1.4.0 Config

πŸƒ Execute

Run using:

docker-compose up

or run locally using:

go mod download -x && go mod verify
go run main.go

In order to run it locally is necessary to have a PostgreSQL instance running in your machine.

‴ Routes

GET /hello-world

curl -X GET http://127.0.0.1:8080/hello-world

POST pet/

curl -X POST http://127.0.0.1:8080/pet \
   -H 'Content-Type: application/json' \
   -d '{"name":"Megan","kind":"Dog"}'

Example Output:

{"id":"56a7b854-1dca-415a-9259-9432c993b363","name":"Megan","kind":"Dog","created-at":"0001-01-01T00:00:00Z","updated-at":"2022-04-07T16:53:59.461711837Z","deleted-at":null}

GET pet/:id

curl -X GET http://127.0.0.1:8080/pet/7c7c62c67-473e-48f2-a7da-60f0c24f2b6b

Example Output:

{"id":"c7c62c67-473e-48f2-a7da-60f0c24f2b6b","name":"Onix","kind":"Cat","created-at":"0001-01-01T00:00:00Z","updated-at":"2022-04-07T16:51:25.01315Z","deleted-at":null}  

πŸ§ͺ Test

Run test suite:

go test ./...

About

Simple API using hex architecture and domain pattern written in Go 🐹


Languages

Language:Go 98.5%Language:Dockerfile 1.1%Language:Shell 0.5%