15 lines
475 B
TypeScript
15 lines
475 B
TypeScript
import type { z } from "zod";
|
|
import type { RealtimeChannelDescriptor } from "./realtime-channel";
|
|
|
|
export type RealtimeContext = {
|
|
userId: string | null;
|
|
roles: string[];
|
|
};
|
|
|
|
export type IRealtimeHandler<T> = (input: T, ctx: RealtimeContext) => Promise<void>;
|
|
|
|
export type IInboundDescriptor<TName extends string, TSchema extends z.ZodType> = {
|
|
readonly descriptor: RealtimeChannelDescriptor<TName, TSchema>;
|
|
readonly handler: IRealtimeHandler<z.infer<TSchema>>;
|
|
};
|