Skip to content
This repository has been archived by the owner. It is now read-only.

Latest commit

 

History

History
61 lines (40 loc) · 1.61 KB

File metadata and controls

61 lines (40 loc) · 1.61 KB

Tracker app

This app is intended to track users statistics of valid/invalid API calls.

Install

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.

  1. 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
  1. Apply migrations:
docker-compose --env-file .env up --build migrate
  1. Start API server
docker-compose --env-file .env up --build api
  1. Check API is alive
curl localhost:6000/api/v1/health/

API Methods

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.

Development

Setup for the development guide can be found in the docs directory.