A REST API for Slay the Web to post and store highscores.
It is deployed and live on https://api.slaytheweb.cards with three endpoints:
GET /api/runs - returns all runs (but not all data per run)
GET /api/runs/{id} - returns a single run
POST /api/runs - stores a run
A Node.js API (built with Next.js) which connects to a remote libsql (fork of sqlite) database running on a sqld server, hosted by https://turso.tech.
Copy .env.example to .env and add your Turso token. Or pull from Vercel:
vercel link && vercel env pull .envRun the dev server:
npm run devTwo tables: players and runs. No authentication, player names are not protected.
players(name TEXT PRIMARY KEY, created_at INTEGER)
runs(id INTEGER PRIMARY KEY, created_at INTEGER, player TEXT, won INTEGER, game_state BLOB, game_past BLOB)Note: game_state is minimized via minimizeGameState(), not the full state.
Run SQL directly against Turso (requires .env with TURSO_URL and TURSO_TOKEN):
bun query.js "SELECT * FROM runs ORDER BY id DESC LIMIT 5"
bun query.js "SELECT count(*) FROM players"Local analytics (synced subset without blobs):
bun runs.js sync # fetch latest from API
bun runs.js stats # show stats
bun runs.js top # top players
bun runs.js daily # runs per day
bun runs.js query "SELECT ..."turso db shell rare-neoncurl -X POST -H 'Content-Type: application/json' -d '{"player": "XX", "won": 1}' http://localhost:3000/api/runs