import { defineQueue } from "@wrnexus/queue"; export interface WelcomeEmailPayload { userId: number; email: string; } /* * A file under app/queues must default-export defineQueue(...) -- the loader * refuses anything else rather than registering a queue that would never run. * This example used the older defineJob() shape and so failed to load, which * took the whole example app down with it. */ export default defineQueue({ name: "welcome-email", jobs: { send: { validate: (data: unknown): data is WelcomeEmailPayload => typeof data === "object" && data !== null && Number.isInteger((data as { userId?: unknown }).userId) && typeof (data as { email?: unknown }).email === "string", run: async ({ email }: WelcomeEmailPayload) => { console.log(`Welcome email queued for ${email}`); }, }, }, });