Generator-emitted scaffold (pnpm turbo gen core-package realtime) plus the story-00-precedent coverage repairs (coverage provider devDep, symbols.ts exclude + tested allowlist mirror) and three minimal tests covering generator-emitted realtime code the template suite misses. Squash of 31d85e0 + review-fix cf11b38. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
18 lines
646 B
TypeScript
18 lines
646 B
TypeScript
import type { Server as IOServer } from "socket.io";
|
|
import type { z } from "zod";
|
|
import { channelRoom } from "./channel-room";
|
|
import type { IRealtimeBroadcaster } from "./realtime-broadcaster.interface";
|
|
import type { RealtimeChannelDescriptor } from "./realtime-channel";
|
|
|
|
export class SocketIORealtimeBroadcaster implements IRealtimeBroadcaster {
|
|
constructor(private readonly io: IOServer) {}
|
|
|
|
async broadcast<T>(
|
|
descriptor: RealtimeChannelDescriptor<string, z.ZodType<T>>,
|
|
payload: T,
|
|
): Promise<void> {
|
|
descriptor.schema.parse(payload);
|
|
this.io.to(channelRoom(descriptor.name)).emit(descriptor.name, payload);
|
|
}
|
|
}
|