Compare commits

...

3 Commits

Author SHA1 Message Date
javayhu
09545c4b6e chore: invoke function from code in inngest 2025-06-25 00:29:28 +08:00
javayhu
249fd63405 chore: inngest explore 2025-06-24 22:53:40 +08:00
javayhu
9d6841e7fc chore: add inngest 2025-06-23 23:37:20 +08:00
6 changed files with 1739 additions and 14 deletions

View File

@ -91,6 +91,7 @@
"fumadocs-core": "^15.5.3", "fumadocs-core": "^15.5.3",
"fumadocs-mdx": "^11.6.8", "fumadocs-mdx": "^11.6.8",
"fumadocs-ui": "^15.5.3", "fumadocs-ui": "^15.5.3",
"inngest": "^3.39.2",
"input-otp": "^1.4.2", "input-otp": "^1.4.2",
"lucide-react": "^0.483.0", "lucide-react": "^0.483.0",
"motion": "^12.4.3", "motion": "^12.4.3",

1706
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View 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!' });
}

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