chore: invoke function from code in inngest
This commit is contained in:
parent
249fd63405
commit
09545c4b6e
20
src/app/api/hello/route.ts
Normal file
20
src/app/api/hello/route.ts
Normal file
@ -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!' });
|
||||||
|
}
|
@ -4,7 +4,9 @@ export const helloWorld = inngest.createFunction(
|
|||||||
{ id: 'hello-world' },
|
{ id: 'hello-world' },
|
||||||
{ event: 'test/hello.world' },
|
{ event: 'test/hello.world' },
|
||||||
async ({ event, step }) => {
|
async ({ event, step }) => {
|
||||||
|
console.log('Hello World function start');
|
||||||
await step.sleep('wait-a-moment', '1s');
|
await step.sleep('wait-a-moment', '1s');
|
||||||
|
console.log('Hello World function end');
|
||||||
return { message: `Hello ${event.data.email}!` };
|
return { message: `Hello ${event.data.email}!` };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user