Skip to content

Repository files navigation

dreik API

Building

1/ First things first, clone the repo

$ git clone https://github.com/yodreik/api.git && cd ./api

2/ Set up your config files. Use ./config/example.yml as a template


3/ Set up .env file

$ echo CONFIG_PATH=./config/local.yaml > .env
$ cat .env
CONFIG_PATH=./config/local.yaml

4/ Rebuild swagger, coverage report and run tests

Important

Make sure, you have installed: swaggo/swag for rebuilding swagger documentation

$ make all
...
... swagger building logs 
... tests results and coverage report
...

5/ Running

Inside docker compose

$ docker build -t dreik-api:latest .
$ docker compose up

or outside the docker

$ docker compose -f ./docker-compose.dev.yaml up -d
$ go build -o bin/api cmd/api/main.go

Note

For local and dev environments, there are available coverage report (on /coverage endpoint) and SwaggerUI (on /docs/index.html). For production environment, this routes are not configured, like CORS headers.


6/ Install migrate tool

$ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

7/ Apply database migrations

$ migrate -path migrations -database "postgres://postgres:password@localhost:5432/postgres?sslmode=disable" up

8/ Check it out

$ curl -i http://localhost:6969/api/healthcheck
HTTP/1.1 200 OK
...

Other notes

How to explore my database?

$ docker exec -it dreik-api:latest psql -U username

Than you can use SQL queries

select * from users;

Drop database

$ migrate -path migrations -database "postgres://postgres:password@localhost:5432/postgres?sslmode=disable" down

About

Backend server for yodreik

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages