Files
TSSBOT-web/backend
2026-06-18 02:38:44 -07:00
..
2026-06-18 02:38:44 -07:00
2026-05-29 18:55:56 +01:00

tssbot backend

Rust backend API service for Toothless' TSS Bot.

It reads two SQLite databases:

  • TSS_BATTLES_DB for tss_battles.db (matches, players, and the match_logs table)
  • TSS_TEAMS_DB for tss_teams.db
  • BACKEND_HOST bind host, default 127.0.0.1
  • 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.

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_JSONvehicle_translations.json ({ cdk: { en, ru, ... } }). The /api/tss/games/:id endpoint honors ?lang= (default en), falling back lang → en → raw cdk.
  • VEHICLE_DATA_CACHE_JSONvehicle_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:

  • GET /health
  • 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/search?q=...&limit=10
  • GET /api/tss/teams/:team
  • GET /api/tss/teams/:team/history
  • GET /api/tss/teams/:team/games

Local development

npm run dev:backend

The backend listens on http://127.0.0.1:6000 by default. Override with BACKEND_PORT and BACKEND_HOST.

Production build

npm run build:backend