UNPKG

bun-ws-router

Version:

Lightweight client/server WebSocket router for Bun with type-safe Zod/Valibot validation.

14 lines 825 B
import type { Server, ServerWebSocket } from "bun"; import type { ValidatorAdapter } from "./router"; import type { MessageSchemaType, WebSocketData } from "./types"; /** * Generic publish function that works with any validator adapter. * * ARCHITECTURE: This shared implementation is used internally by the router. * Public APIs (zod/publish and valibot/publish) provide type-safe wrappers. * * NOTE: Accepts either Server or ServerWebSocket for flexibility in usage. */ export declare function publishWithValidator<T extends WebSocketData<Record<string, unknown>>>(validator: ValidatorAdapter, server: Server | ServerWebSocket<T>, topic: string, schema: MessageSchemaType, messageType: string, // Pre-extracted to avoid adapter-specific logic payload: any, meta?: any): boolean; //# sourceMappingURL=publish.d.ts.map