Opens the WebSocket that WSProvider keeps for each tab, and handles what the client sends over it. Voting, comment likes and every chat write go through here, not through HTTP. The messages are typed in shared/ws.ts, and services/ws-service.ts sends the broadcasts.

  • GET /ws?token=, public. A valid session token signs the socket in, and an invalid one leaves it anonymous. Answers 403 to an origin not in ALLOWED_ORIGINS, and 426 to a request that isn't an upgrade.

Variables

v
default: Router

Mounted by api/main.ts behind the error, Open Graph and CORS middleware. An APIException thrown by a handler becomes the JSON error response there.