refactor: remove inngest
This commit is contained in:
parent
2b72570784
commit
7985769871
@ -167,12 +167,6 @@ TURNSTILE_SECRET_KEY=""
|
||||
# -----------------------------------------------------------------------------
|
||||
NEXT_PUBLIC_CRISP_WEBSITE_ID=""
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Inngest
|
||||
# https://mksaas.com/docs/jobs#setup
|
||||
# -----------------------------------------------------------------------------
|
||||
INNGEST_SIGNING_KEY=""
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# AI
|
||||
# https://mksaas.com/docs/ai
|
||||
|
@ -100,7 +100,6 @@
|
||||
"fumadocs-core": "^15.6.7",
|
||||
"fumadocs-mdx": "^11.7.3",
|
||||
"fumadocs-ui": "^15.6.7",
|
||||
"inngest": "^3.40.1",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^0.483.0",
|
||||
"motion": "^12.4.3",
|
||||
|
1708
pnpm-lock.yaml
generated
1708
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,20 +0,0 @@
|
||||
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!' });
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import { serve } from 'inngest/next';
|
||||
import { inngest } from '../../../inngest/client';
|
||||
import { distributeCreditsDaily, helloWorld } from '../../../inngest/functions';
|
||||
|
||||
/**
|
||||
* Inngest route
|
||||
*
|
||||
* https://www.inngest.com/docs/getting-started/nextjs-quick-start
|
||||
*
|
||||
* Next.js Edge Functions hosted on Vercel can also stream responses back to Inngest,
|
||||
* giving you a much higher request timeout of 15 minutes (up from 10 seconds on the Vercel Hobby plan!).
|
||||
* To enable this, set your runtime to "edge" (see Quickstart for Using Edge Functions | Vercel Docs)
|
||||
* and add the streaming: "allow" option to your serve handler:
|
||||
* https://www.inngest.com/docs/learn/serving-inngest-functions#framework-next-js
|
||||
*/
|
||||
export const { GET, POST, PUT } = serve({
|
||||
client: inngest,
|
||||
functions: [helloWorld, distributeCreditsDaily],
|
||||
});
|
@ -1,8 +0,0 @@
|
||||
import { Inngest } from 'inngest';
|
||||
|
||||
/**
|
||||
* Create a client to send and receive events
|
||||
*
|
||||
* https://www.inngest.com/docs/getting-started/nextjs-quick-start
|
||||
*/
|
||||
export const inngest = new Inngest({ id: 'mksaas-template' });
|
@ -1,46 +0,0 @@
|
||||
import { distributeCreditsToAllUsers } from '@/credits/credits';
|
||||
import { inngest } from './client';
|
||||
|
||||
/**
|
||||
* Distribute credits to all users daily
|
||||
*
|
||||
* https://www.inngest.com/docs/guides/scheduled-functions
|
||||
*/
|
||||
export const distributeCreditsDaily = inngest.createFunction(
|
||||
{ id: 'distribute-credits-daily' },
|
||||
{ cron: 'TZ=Asia/Shanghai 0 1 * * *' },
|
||||
async ({ step }) => {
|
||||
// You should use step.run for any async or long-running logic.
|
||||
// This allows Inngest to track, retry, and visualize each step in your workflow.
|
||||
await step.run('distribute-credits-to-all-users', async () => {
|
||||
console.log('distributing credits to all users start');
|
||||
const { processedCount, errorCount } =
|
||||
await distributeCreditsToAllUsers();
|
||||
console.log(
|
||||
`distributing credits to all users end, processed: ${processedCount}, errors: ${errorCount}`
|
||||
);
|
||||
return {
|
||||
message: `credits distributed, processed: ${processedCount}, errors: ${errorCount}`,
|
||||
processedCount,
|
||||
errorCount,
|
||||
};
|
||||
});
|
||||
// you can add new steps here, for example, send email to admin
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Hello World function, for testing inngest
|
||||
*
|
||||
* https://www.inngest.com/docs/guides/scheduled-functions
|
||||
*/
|
||||
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