Compare commits
3 Commits
cloudflare
...
dev/innges
Author | SHA1 | Date | |
---|---|---|---|
|
09545c4b6e | ||
|
249fd63405 | ||
|
9d6841e7fc |
@ -91,6 +91,7 @@
|
||||
"fumadocs-core": "^15.5.3",
|
||||
"fumadocs-mdx": "^11.6.8",
|
||||
"fumadocs-ui": "^15.5.3",
|
||||
"inngest": "^3.39.2",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^0.483.0",
|
||||
"motion": "^12.4.3",
|
||||
|
1706
pnpm-lock.yaml
generated
1706
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
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!' });
|
||||
}
|
10
src/app/api/inngest/route.ts
Normal file
10
src/app/api/inngest/route.ts
Normal file
@ -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
|
||||
],
|
||||
});
|
4
src/inngest/client.ts
Normal file
4
src/inngest/client.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { Inngest } from 'inngest';
|
||||
|
||||
// Create a client to send and receive events
|
||||
export const inngest = new Inngest({ id: 'my-app' });
|
12
src/inngest/functions.ts
Normal file
12
src/inngest/functions.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { inngest } from './client';
|
||||
|
||||
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}!` };
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user