8000 Add GET /api routes for player names and draw history by noahm · Pull Request #688 · noahm/DDRCardDraw · GitHub
[go: up one dir, main page]

Skip to content

Add GET /api routes for player names and draw history - #688

Merged
noahm merged 3 commits into
partykitfrom
party-api-routes
Nov 11, 2026
Merged

noahm merged 3 commits into
partykitfrom
party-api-routes

Conversation

@noahm
@noahm noahm commented Nov 11, 2026 •
Copy link
Copy Markdown
Owner

Replaces the two ddr-tools-api vals on Val Town, which is shutting down, with official routes on the party Worker (live.ddr.tools). User-facing docs are in docs/api.md, linked from the OBS guide.

Old (Val Town) New
ddr-tools-raw-player-name.val.run/e/:eventId/cab/:cabId/player/:n live.ddr.tools/api/e/:eventId/cab/:cabId/player/:n
ddr-tools-full-draw-history.val.run/e/:eventId live.ddr.tools/api/e/:eventId/draws (also /api/e/:eventId)

Both val.run addresses will redirect to https://live.ddr.tools/api with the path kept. Every old URL then lands on a matching route with no extra mapping. That's why draw history also answers at the bare /api/e/:eventId.

  • The player-name route returns the raw name as text/plain. If there's no cab, no active drawing, or no player at that index, it returns 204 with the same x-empty-reason header the val sent, so existing OBS text sources behave the same.
  • The draws route returns Object.values(drawings.entities) as JSON. The val's delete c.song.charts step is gone: drawn charts no longer carry a song object, so it was a no-op at best.
  • Both routes read the room's Durable Object (via getServerByName) instead of making an HTTP round trip to /parties/main/<room>. They send Access-Control-Allow-Origin: *. Any non-GET request to /api/* gets a 405, and an unknown /api/* path gets a 404.
  • src/party/api.ts is Worker-only code, so it's excluded from the root (DOM) tsconfig.json, the same as worker.ts and server.ts.

Testing

  • yarn validate:types:ts (both configs), oxlint, and oxfmt --check pass.
  • I ran it under wrangler dev and checked:
    • the 204 reasons (no cab / no drawing);
    • draws returning [] at both /api/e/:id and /api/e/:id/draws;
    • 404s for unknown paths and 405 for non-GET requests;
    • /parties/main/<room> still working.
  • For an empty room, the output matched the live vals.

🤖 Generated with Claude Code

Replaces the ddr-tools-api proxies on Val Town (which is shutting down)
with official routes on the party Worker:

- /api/e/:eventId/cab/:cabId/player/:playerIndex — plain-text name of the
  player at that position in the cab's active match, or 204 with an
  x-empty-reason header
- /api/e/:eventId/draws — every drawing in the event as JSON

Both read the room's Durable Object state directly instead of fetching
/parties/main/<room> over HTTP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel
vercel Bot commented Nov 11, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ddr-tools Ready Ready Preview Nov 11, 2026 5:40pm UTC

It uses the workers-runtime Env global, so like worker.ts and server.ts it's
only checked by tsconfig.worker.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… API

The old full-draw-history proxy answered at /e/:eventId, so with its
val.run redirect pointed at live.ddr.tools/api the path lands here
unchanged. docs/api.md covers both routes for users, linked from the
OBS guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@noahm
noahm merged commit 3e6162e into partykit Nov 11, 2026
7 checks passed
@noahm
noahm deleted the party-api-routes branch November 11, 2026 17:43

This branch was successfully deployed

1 active deployment
Preview — ff6fb027 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0