diff --git a/turbo/generators/templates/realtime/channel/channel.test.ts.hbs b/turbo/generators/templates/realtime/channel/channel.test.ts.hbs new file mode 100644 index 0000000..872d21e --- /dev/null +++ b/turbo/generators/templates/realtime/channel/channel.test.ts.hbs @@ -0,0 +1,18 @@ +// packages/{{kebabCase feature}}/src/realtime/{{kebabCase channelSlug}}.channel.test.ts +import { describe, it, expect } from "vitest"; +import { + {{camelCase channelSlug}}Channel, + {{camelCase channelSlug}}Schema, +} from "@/realtime/{{kebabCase channelSlug}}.channel"; + +describe("{{camelCase channelSlug}}Channel", () => { + it("has the expected wire name", () => { + expect({{camelCase channelSlug}}Channel.name).toBe( + "{{kebabCase feature}}.{{kebabCase channelSlug}}", + ); + }); + + it("validates an empty payload (stub schema)", () => { + expect(() => {{camelCase channelSlug}}Schema.parse({})).not.toThrow(); + }); +}); diff --git a/turbo/generators/templates/realtime/channel/channel.ts.hbs b/turbo/generators/templates/realtime/channel/channel.ts.hbs new file mode 100644 index 0000000..054addb --- /dev/null +++ b/turbo/generators/templates/realtime/channel/channel.ts.hbs @@ -0,0 +1,13 @@ +// packages/{{kebabCase feature}}/src/realtime/{{kebabCase channelSlug}}.channel.ts +import { z } from "zod"; +import { defineRealtimeChannel } from "@repo/core-realtime"; + +export const {{camelCase channelSlug}}Schema = z.object({}).strict(); + +export type {{pascalCase channelSlug}}Payload = z.infer; + +export const {{camelCase channelSlug}}Channel = defineRealtimeChannel( + "{{kebabCase feature}}.{{kebabCase channelSlug}}", + {{camelCase channelSlug}}Schema, + { scope: {{{scopeLiteral}}} }, +);