Skip to content
Adam Chalkley edited this page Dec 1, 2020 · 8 revisions

Makefile

A makefile has been provided to allow for building, running, and testing the project. It is accessible from the root of the project.

$ cd $HOME/code/service

Commands

make all

This command will build the sales-api and metrics images.

$ make all

make run

This command will leverage Docker Compose to run all the services, including the 3rd party services. The first time you run this command, Docker will download the required images for the 3rd party services. The command will also create a schema in the database and seed the database with test data.

$ make run

That is equivalent to running.

$ make up
$ make seed

docker-compose -f z/compose/docker-compose.yaml up --detach --remove-orphans
go run app/sales-admin/main.go --db-disable-tls=1 migrate
go run app/sales-admin/main.go --db-disable-tls=1 seed

make down

This command will shutdown the running Docker Compose environment.

$ make down

docker-compose -f z/compose/docker-compose.yaml down --remove-orphans

make logs

This command will tail the logs from the running Docker Compose environment.

$ make logs

docker-compose -f z/compose/docker-compose.yaml logs -f

Authenticated Requests

Before any requests can be made you must acquire an auth token. Make a request using HTTP Basic auth with the test user email and password to get the token.

$ curl --user "admin@example.com:gophers" http://localhost:3000/v1/users/token/54bb2165-71e1-41a6-af3e-7da4a0e1e2c1

I suggest putting the resulting token in an environment variable like $TOKEN.

$ export TOKEN="COPY TOKEN STRING FROM LAST CALL"

To make authenticated requests put the token in the Authorization header with the Bearer prefix.

$ curl -H "Authorization: Bearer ${TOKEN}" http://localhost:3000/v1/users/1/2