diff --git a/src/app/api/hello/route.ts b/src/app/api/hello/route.ts new file mode 100644 index 0000000..557479c --- /dev/null +++ b/src/app/api/hello/route.ts @@ -0,0 +1,20 @@ +import { inngest } from '@/inngest/client'; +import { NextResponse } from 'next/server'; + +// Opt out of caching; every request should send a new event +export const dynamic = 'force-dynamic'; + +// Create a simple async Next.js API route handler +export async function GET() { + console.log('Send event to Inngest start'); + // Send your event payload to Inngest + await inngest.send({ + name: 'test/hello.world', + data: { + email: 'testUser@example.com', + }, + }); + + console.log('Send event to Inngest end'); + return NextResponse.json({ message: 'Event sent!' }); +} diff --git a/src/inngest/functions.ts b/src/inngest/functions.ts index c8fb847..8b61b95 100644 --- a/src/inngest/functions.ts +++ b/src/inngest/functions.ts @@ -4,7 +4,9 @@ export const helloWorld = inngest.createFunction( { id: 'hello-world' }, { event: 'test/hello.world' }, async ({ event, step }) => { + console.log('Hello World function start'); await step.sleep('wait-a-moment', '1s'); + console.log('Hello World function end'); return { message: `Hello ${event.data.email}!` }; } );