This app is intended to track users statistics of valid/invalid API calls.
API build on top of the Go, Echo, sqlx and Postgres. All infra tasks (start API, install deps, etc.) are managed by Task cli. The easiest way to start API is by using docker.
- Initiliaze
.env
file with development defaults by:
cp env.example.docker .env
2.Start database (on Linux, you may need to use sudo for the following commands):
docker-compose --env-file .env up -d postgres
- Apply migrations:
docker-compose --env-file .env up --build migrate
- Start API server
docker-compose --env-file .env up --build api
- Check API is alive
curl localhost:6000/api/v1/health/
Examples of API calls can be found in the examples directory. Some of them are:
# Valid collector requst
curl --request POST \
--url http://localhost:6000/api/v1/collect/ \
--header 'content-type: application/json' \
--data '{"customerID": 1,"tagID": 2,"userID": "aaaaaaaa-bbbb-cccc-1111-222222222222","remoteIP": "123.234.56.78","timestamp": 1500000000}'
# Return all stats
curl --request GET \
--url http://localhost:6000/api/v1/stats/
Files in the examples directory with an extenstion .http
are intended to use with the REST Client extension for vscode.
Files in the examples directory with an extenstion .md
contains curl examples.
Setup for the development guide can be found in the docs directory.