docs: vehicle cache env vars and logs endpoint

This commit is contained in:
FURRO404
2026-06-18 00:33:48 -07:00
parent 18a45f664b
commit 49e75cc8f0
3 changed files with 35 additions and 1 deletions
+6
View File
@@ -73,11 +73,17 @@ The server serves `/health`
locally and only proxies the API routes used by the app: locally and only proxies the API routes used by the app:
- `GET /api/tss/leaderboard/teams?limit=1..100` - `GET /api/tss/leaderboard/teams?limit=1..100`
- `GET /api/tss/games/recent?limit=1..100`
- `GET /api/tss/games/:session_id?lang=...`
- `GET /api/tss/games/:session_id/logs`
- `GET /api/tss/teams/resolve?name=...` - `GET /api/tss/teams/resolve?name=...`
- `GET /api/tss/teams/:team` - `GET /api/tss/teams/:team`
- `GET /api/tss/teams/:team/history` - `GET /api/tss/teams/:team/history`
- `GET /api/tss/teams/:team/games` - `GET /api/tss/teams/:team/games`
Vehicle icon PNGs are served statically at `/vehicle-icons` from `VEHICLE_ICONS_DIR`
(populated at deploy from `SHARED/ICONS/VEHICLES`).
The proxy blocks cross-origin/API-navigation requests, strips CORS headers from The proxy blocks cross-origin/API-navigation requests, strips CORS headers from
the upstream response, rate limits callers, and caches successful GET responses the upstream response, rate limits callers, and caches successful GET responses
briefly so public page traffic does not hammer the upstream API. All responses briefly so public page traffic does not hammer the upstream API. All responses
+19 -1
View File
@@ -4,17 +4,35 @@ Rust backend API service for Toothless' TSS Bot.
It reads two SQLite databases: It reads two SQLite databases:
- `TSS_BATTLES_DB` for `tss_battles.db` - `TSS_BATTLES_DB` for `tss_battles.db` (matches, players, and the `match_logs` table)
- `TSS_TEAMS_DB` for `tss_teams.db` - `TSS_TEAMS_DB` for `tss_teams.db`
- `BACKEND_HOST` bind host, default `127.0.0.1` - `BACKEND_HOST` bind host, default `127.0.0.1`
- `BACKEND_ALLOWED_ORIGINS` comma-separated browser origins allowed by CORS - `BACKEND_ALLOWED_ORIGINS` comma-separated browser origins allowed by CORS
Both paths can be absolute or relative to the repo root when run through the root scripts/PM2. Both paths can be absolute or relative to the repo root when run through the root scripts/PM2.
## Vehicle translation + icons
At startup the backend loads two cache files (built by the bots, shared under
`STORAGE/CACHE`) into memory to translate `player_games_hist.vehicle_internal`
(the WT cdk) into localized vehicle names and icon filenames for the game scoreboard:
- `VEHICLE_TRANSLATIONS_JSON``vehicle_translations.json` (`{ cdk: { en, ru, ... } }`).
The `/api/tss/games/:id` endpoint honors `?lang=` (default `en`), falling back
`lang → en → raw cdk`.
- `VEHICLE_DATA_CACHE_JSON``vehicle_data_cache_all.json` (`[cdk, name, icon, tags]`),
used for icon filenames (fallback `<cdk>.png`).
The icon PNGs themselves are served statically by the frontend at `/vehicle-icons`
(deploy-time copy/symlink of `SHARED/ICONS/VEHICLES`).
It currently exposes: It currently exposes:
- `GET /health` - `GET /health`
- `GET /api/tss/leaderboard/teams?limit=100` - `GET /api/tss/leaderboard/teams?limit=100`
- `GET /api/tss/games/recent?limit=50`
- `GET /api/tss/games/:session_id?lang=en` — scoreboard (teams, players, vehicle lineup)
- `GET /api/tss/games/:session_id/logs` — chat + battle logs from `match_logs`
- `GET /api/tss/teams/resolve?name=...` - `GET /api/tss/teams/resolve?name=...`
- `GET /api/tss/teams/search?q=...&limit=10` - `GET /api/tss/teams/search?q=...&limit=10`
- `GET /api/tss/teams/:team` - `GET /api/tss/teams/:team`
+10
View File
@@ -11,6 +11,16 @@ BACKEND_ALLOWED_ORIGINS=https://example.com
TSS_BATTLES_DB=./tss_battles.db TSS_BATTLES_DB=./tss_battles.db
TSS_TEAMS_DB=./tss_teams.db TSS_TEAMS_DB=./tss_teams.db
# Vehicle name translation + icon caches (shared STORAGE/CACHE, built by the bots).
# The backend loads these at startup to translate vehicle_internal (cdk) -> name
# and resolve icon filenames for the game scoreboard.
VEHICLE_TRANSLATIONS_JSON=/mnt/HC_Volume_105581488/STORAGE/CACHE/vehicle_translations.json
VEHICLE_DATA_CACHE_JSON=/mnt/HC_Volume_105581488/STORAGE/CACHE/vehicle_data_cache_all.json
# Directory of vehicle icon PNGs served at /vehicle-icons (deploy-time copy/symlink
# of SHARED/ICONS/VEHICLES). VEHICLE_ICONS_SRC is the deploy source.
VEHICLE_ICONS_DIR=./dist/vehicle-icons
VEHICLE_ICONS_SRC=/home/deploy/BOTS/SHARED/ICONS/VEHICLES
UPTIME_STORAGE_DIR=~/tsswebstorage UPTIME_STORAGE_DIR=~/tsswebstorage
UPTIME_DATABASE_FILE=uptime.sqlite UPTIME_DATABASE_FILE=uptime.sqlite
UPTIME_SAMPLE_INTERVAL_MS=1800000 UPTIME_SAMPLE_INTERVAL_MS=1800000