Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inngest example for latest version #68600

Merged
merged 7 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/cms-contentful/.env.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONTENTFUL_SPACE_ID=
CONTENTFUL_ACCESS_TOKEN=
CONTENTFUL_PREVIEW_ACCESS_TOKEN=
CONTENTFUL_PREVIEW_SECRET=
CONTENTFUL_REVALIDATE_SECRET=
24 changes: 2 additions & 22 deletions examples/cms-contentful/app/api/draft/route.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
import { draftMode } from "next/headers";
import { redirect } from "next/navigation";
import { getPreviewPostBySlug } from "../../../lib/api";

export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const secret = searchParams.get("secret");
const slug = searchParams.get("slug");

if (secret !== process.env.CONTENTFUL_PREVIEW_SECRET) {
return new Response("Invalid token", { status: 401 });
}

const post = await getPreviewPostBySlug(slug);

if (!post) {
return new Response("Invalid slug", { status: 401 });
}

draftMode().enable();
redirect(`/posts/${post.slug}`);
}
//@ts-ignore
export { enableDraftHandler as GET } from "@contentful/vercel-nextjs-toolkit/app-router";
1 change: 1 addition & 0 deletions examples/cms-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"@contentful/rich-text-react-renderer": "^15.17.1",
"@contentful/rich-text-types": "^16.2.1",
"@contentful/vercel-nextjs-toolkit": "latest",
"@tailwindcss/typography": "0.5.9",
"@types/node": "^20.5.0",
"@types/react": "^18.2.20",
Expand Down
9 changes: 5 additions & 4 deletions examples/inngest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"private": true,
"scripts": {
"dev": "concurrently \"npm:dev:*\"",
"dev:next": "next dev",
"dev:inngest": "npx inngest-cli@latest dev",
"dev:next": "next dev --turbo",
"dev:inngest": "inngest-cli dev --no-discovery -u http://localhost:3000/api/inngest",
"build": "next build",
"start": "next start"
},
"dependencies": {
"inngest": "latest",
"inngest": "3.x",
"next": "latest",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand All @@ -19,6 +19,7 @@
"@types/react-dom": "18.2.7",
"concurrently": "^8.2.1",
"encoding": "^0.1.13",
"typescript": "5.2.2"
"inngest-cli": "latest",
leerob marked this conversation as resolved.
Show resolved Hide resolved
"typescript": "5.5.4"
}
}
5 changes: 2 additions & 3 deletions examples/inngest/src/app/api/inngest/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inngestConfig } from "@/inngest/inngest.config";
import { serve } from "inngest/next";
import { inngest } from "@/inngest/inngest.client";
import { helloWorld } from "@/inngest/functions/hello-world";

export const { GET, POST, PUT } = serve(inngest, [helloWorld]);
export const { GET, POST, PUT } = serve(inngestConfig);
2 changes: 1 addition & 1 deletion examples/inngest/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inngest } from "@/inngest/inngest.client";
import { inngest } from "@/inngest/inngest.config";
import { redirect } from "next/navigation";

export default function Home() {
Expand Down
10 changes: 0 additions & 10 deletions examples/inngest/src/inngest/functions/hello-world.ts

This file was deleted.

4 changes: 0 additions & 4 deletions examples/inngest/src/inngest/inngest.client.ts

This file was deleted.

33 changes: 33 additions & 0 deletions examples/inngest/src/inngest/inngest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { EventSchemas, Inngest } from "inngest";

// TypeScript schema for the events
export type Events = {
"test/hello.world": {
name: "test/hello.world";
data: {
message: string;
};
};
};

// Inngest client to send and receive events
export const inngest = new Inngest({
id: "demo-app",
schemas: new EventSchemas().fromRecord<Events>(),
});

// a function to execute, typically in its own file
const helloWorld = inngest.createFunction(
{ id: "hello-world", name: "Hello World" },
{ event: "test/hello.world" },
async ({ event, step }) => {
await step.sleep("sleep for a second", "1s");
return { event, body: event.data.message };
},
);

// configuration for the Inngest api router
export const inngestConfig = {
client: inngest,
functions: [helloWorld],
};
Loading