function · Node only
startRelay
Opens a SQLite-backed WebSocket mailbox at /v1 and starts listening for authenticated clients.
Messages remain stored until acknowledged or expired; the relay sees routing metadata, not plaintext.
@toip-tools/relayView sourceimport { startRelay } from "@toip-tools/relay";
Declaration
startRelay(opts: RelayOptions): Promise<Relay>;
Parameters
optsrequiredRelayOptionsBind address, database path, public authentication URL, queue limits, and optional observers. Use
port: 0for an assigned port.publicUrlmust exactly match the URL clients sign during authentication.
Returns
Promise<Relay>A listening relay with its actual port, advertised URL, queue counter, and asynchronous close method.
The caller must await close() during shutdown to terminate sockets, stop expiry sweeps, and close SQLite.
Throws
If opening or initializing SQLite fails, or the WebSocket server cannot start listening.