method WebSocketService.prototype.route
WebSocketService.prototype.route(
path: string,
): void

Registers a WebSocket route. Paths match exactly; the query string is ignored for matching and exposed to onOpen instead.

Parameters

path: string

The exact URL path to accept upgrades on (e.g. /ws/chat)

The lifecycle callbacks

optional
options: WebSocketRouteOptions

Per-route configuration

Return Type

void

Throws

Error

If the HTTP adapter provides no upgrade seam, or if the path is already registered

Usage

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