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}!` }; + } +);