myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

commit 93e931caaad261f54db81e9128e3c1c7540801e3
parent b63132b724741b2baef51ab2a676ffc472e7b2a8
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun, 20 Oct 2024 09:49:04 +0200

doc: improve developer doc

Diffstat:
MREADME.md | 2++
Ddev/README.md | 23-----------------------
Adocs/DEBUGGING.md | 19+++++++++++++++++++
Adocs/DEVELOPMENT_SETUP.md | 23+++++++++++++++++++++++
Ddocs/debugging.txt | 14--------------
5 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/README.md b/README.md @@ -23,6 +23,8 @@ npm run api npm run dev ``` +See `./docs` for more detailed developer documentation. + ## Scoring and ranking logic The scoring and ranking logic is defined in `utils.js` inside the `rankByHeat` function. Following ranking options can be selected. Rank by: diff --git a/dev/README.md b/dev/README.md @@ -1,23 +0,0 @@ -# Development setup - -## Nix development environment -You can create a nix-shell for development purposes: -``` -nix-shell nix/shell.nix -``` - -## Docker environment -The docker-compose environment in this folder configures a PostgreSQL database -with Adminer interface: -* https://hub.docker.com/_/postgres -* https://github.com/docker-library/docs/blob/master/postgres/README.md - -The Adminer can be accessed at http://127.0.0.1:8080 with the default -username/password `postgres`/`example`. - -The database is automatically initialized at start. To re-initialize the -database tables manually, source the sql files from `../schema`: -``` -# use "example" default password to apply -cat ../schema/*.sql | psql -h 127.0.0.1 -U postgres -p 5432 -``` diff --git a/docs/DEBUGGING.md b/docs/DEBUGGING.md @@ -0,0 +1,18 @@ +# Debugging documentation + +## GET/POST requests +```bash +curl http://127.0.0.1:8000/v1/healthz +curl http://127.0.0.1:8000/v1/leaderboard/allHeats +curl -XPOST -d '{"data":"hi"}' http://127.0.0.1:8000/v1/echo + +token="eyJ..." +curl -d '{"name":"style","value":"App-red.css"}' -H "Authorization: Bearer $token" http://127.0.0.1:8000/v1/leaderboard/updateSetting +curl -H "Authorization: Bearer $token" http://127.0.0.1:8000/v1/leaderboard/getSetting?name=style +``` + +## Websocket +```bash +echo "egg fried rice" | websocat ws://127.0.0.1:8000/v1/leaderboard +echo '{"method":"watchScores"}' | websocat ws://127.0.0.1:8000/v1/leaderboard +``` +\ No newline at end of file diff --git a/docs/DEVELOPMENT_SETUP.md b/docs/DEVELOPMENT_SETUP.md @@ -0,0 +1,23 @@ +# Development setup + +## Nix development environment +You can create a nix-shell for development purposes: +``` +nix-shell nix/shell.nix +``` + +## Docker environment +The docker-compose environment in the `./dev` folder configures a PostgreSQL database +with Adminer interface: +* https://hub.docker.com/_/postgres +* https://github.com/docker-library/docs/blob/master/postgres/README.md + +The Adminer can be accessed at http://127.0.0.1:8080 with the default +username/password `postgres`/`example`. + +The database is automatically initialized at start. To re-initialize the +database tables manually, source the sql files from `../schema`: +``` +# use "example" default password to apply +cat ../schema/*.sql | psql -h 127.0.0.1 -U postgres -p 5432 +``` diff --git a/docs/debugging.txt b/docs/debugging.txt @@ -1,14 +0,0 @@ -GET/POST --------- -curl http://127.0.0.1:8000/v1/healthz -curl http://127.0.0.1:8000/v1/leaderboard/allHeats -curl -XPOST -d '{"data":"hi"}' http://127.0.0.1:8000/v1/echo - -token="eyJ..." -curl -d '{"name":"style","value":"App-red.css"}' -H "Authorization: Bearer $token" http://127.0.0.1:8000/v1/leaderboard/updateSetting -curl -H "Authorization: Bearer $token" http://127.0.0.1:8000/v1/leaderboard/getSetting?name=style - -WEBSOCKET ---------- -echo "egg fried rice" | websocat ws://127.0.0.1:8000/v1/leaderboard -echo '{"method":"watchScores"}' | websocat ws://127.0.0.1:8000/v1/leaderboard