UNPKG

@ws-kit/zod

Version:

Zod validator adapter for WS-Kit with runtime schema validation and full TypeScript inference

37 lines 1.44 kB
/** * @ws-kit/zod - Zod validator adapter for WS-Kit * * Canonical import source for Zod-based WebSocket routing. * * @example * ```typescript * import { z, message, rpc, withZod, createRouter } from "@ws-kit/zod"; * * const Join = message("JOIN", { roomId: z.string() }); * const GetUser = rpc("GET_USER", { id: z.string() }, "USER", { * id: z.string(), * name: z.string(), * }); * * const router = createRouter<{ userId?: string }>() * .plugin(withZod()) * .on(Join, (ctx) => { * // ctx.payload: { roomId: string } (inferred + validated) * }) * .rpc(GetUser, async (ctx) => { * // ctx.reply({ id: "u1", name: "Alice" }); * }); * ``` */ export { z } from "zod"; export { message, rpc } from "./runtime.js"; export { withZod } from "./plugin.js"; export type { WithZodOptions } from "./plugin.js"; export type { AnySchema, InferMessage, InferMeta, InferPayload, InferResponse, InferType, MessageSchema, RpcSchema, } from "./types.js"; export { withMessaging, withRpc } from "@ws-kit/plugins"; export type { ProgressOptions, ReplyOptions, SendOptions, WithMessagingCapability, WithRpcCapability, } from "@ws-kit/plugins"; export { withPubSub } from "@ws-kit/pubsub"; export type { WithPubSubCapability } from "@ws-kit/pubsub"; export { createRouter } from "@ws-kit/core"; export type { EventContext as MessageContext, Router, RpcContext, } from "@ws-kit/core"; //# sourceMappingURL=index.d.ts.map