WS message router: dispatch by type #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
WebSocket messages are JSON with a
typefield. The router parses, validates, and dispatches to handlers.What to do
Build a message router with Zod validation.
Files to create
apps/api/src/ws/router.ts— parse JSON, validate with Zod discriminated union, dispatch.apps/api/src/ws/handlers/— directory for handler functions.Implementation outline
Acceptance criteria
Notes
Zod schemas for WS messages belong in
packages/shared(see separate issue). Pattern:z.discriminatedUnion('type', [...]). Reference:packages/shared/src/schemas/game.ts.