/simple-go

Simple API using hex architecture and domain pattern written in Go ๐Ÿน

Primary LanguageGo

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 ./...