From 249fd63405270698a1c95d66dbbca8edfd45de1f Mon Sep 17 00:00:00 2001 From: javayhu Date: Tue, 24 Jun 2025 22:53:40 +0800 Subject: [PATCH] chore: inngest explore --- src/app/api/inngest/route.ts | 10 ++++++++++ src/inngest/client.ts | 4 ++++ src/inngest/functions.ts | 10 ++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/app/api/inngest/route.ts create mode 100644 src/inngest/client.ts create mode 100644 src/inngest/functions.ts diff --git a/src/app/api/inngest/route.ts b/src/app/api/inngest/route.ts new file mode 100644 index 0000000..db915a9 --- /dev/null +++ b/src/app/api/inngest/route.ts @@ -0,0 +1,10 @@ +import { serve } from 'inngest/next'; +import { inngest } from '../../../inngest/client'; +import { helloWorld } from '../../../inngest/functions'; + +export const { GET, POST, PUT } = serve({ + client: inngest, + functions: [ + helloWorld, // <-- This is where you'll always add all your functions + ], +}); diff --git a/src/inngest/client.ts b/src/inngest/client.ts new file mode 100644 index 0000000..904a97b --- /dev/null +++ b/src/inngest/client.ts @@ -0,0 +1,4 @@ +import { Inngest } from 'inngest'; + +// Create a client to send and receive events +export const inngest = new Inngest({ id: 'my-app' }); diff --git a/src/inngest/functions.ts b/src/inngest/functions.ts new file mode 100644 index 0000000..c8fb847 --- /dev/null +++ b/src/inngest/functions.ts @@ -0,0 +1,10 @@ +import { inngest } from './client'; + +export const helloWorld = inngest.createFunction( + { id: 'hello-world' }, + { event: 'test/hello.world' }, + async ({ event, step }) => { + await step.sleep('wait-a-moment', '1s'); + return { message: `Hello ${event.data.email}!` }; + } +);