interface WebSocketRouteOptions
Since 0.2.0

Per-route configuration supplied alongside the handlers.

Properties

readonly
optional
protocols: readonly string[]

Subprotocols this route accepts. When non-empty, the first client-requested protocol appearing in this list is echoed back and any request whose Sec-WebSocket-Protocol matches none of them is rejected with 400. When omitted, no protocol is negotiated and none is echoed.

Since 0.3.0
readonly
optional
guards: readonly WebSocketUpgradeGuard[]

Guards evaluated before this route's WebSocket handshake is accepted.

They run in declared order. The first guard that returns a refusal object rejects the upgrade; when omitted, the matching route accepts upgrades as it did before route-scoped guards existed.

Since 0.3.0
readonly
optional
heartbeat: boolean

Whether this route participates in the shared heartbeat sweep.

When false, the HeartbeatSweeper skips this route's connections for both the payload send and the idle eviction. Use this when the route speaks its own liveness protocol (e.g. graphql-transport-ws ping/pong) that would be corrupted by a generic text heartbeat.

Defaults to true so existing routes are unaffected.

Usage

import { type WebSocketRouteOptions } from "websocket-plugin/src/index.ts";