From 31eedcd62da84d35943f48dbdc1aac76f86ae361 Mon Sep 17 00:00:00 2001 From: malewis5 Date: Thu, 6 Jun 2024 13:51:33 -0400 Subject: [PATCH 1/5] docs: remove preview secret. --- examples/cms-contentful/.env.local.example | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/cms-contentful/.env.local.example b/examples/cms-contentful/.env.local.example index eac50f166461e..4b0e3ac561ee6 100644 --- a/examples/cms-contentful/.env.local.example +++ b/examples/cms-contentful/.env.local.example @@ -1,5 +1,4 @@ CONTENTFUL_SPACE_ID= CONTENTFUL_ACCESS_TOKEN= CONTENTFUL_PREVIEW_ACCESS_TOKEN= -CONTENTFUL_PREVIEW_SECRET= CONTENTFUL_REVALIDATE_SECRET= \ No newline at end of file From 7d3bdf3c18ff0649ec0fc6df2796b1a156be4a7b Mon Sep 17 00:00:00 2001 From: malewis5 Date: Thu, 6 Jun 2024 13:51:50 -0400 Subject: [PATCH 2/5] feat: add contentful sdk --- .../cms-contentful/app/api/draft/route.ts | 23 +------------------ examples/cms-contentful/package.json | 1 + 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/examples/cms-contentful/app/api/draft/route.ts b/examples/cms-contentful/app/api/draft/route.ts index fb0d83fb20838..ba5f454abf582 100644 --- a/examples/cms-contentful/app/api/draft/route.ts +++ b/examples/cms-contentful/app/api/draft/route.ts @@ -1,22 +1 @@ -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}`); -} +export { enableDraftHandler as GET } from "@contentful/vercel-nextjs-toolkit/app-router"; diff --git a/examples/cms-contentful/package.json b/examples/cms-contentful/package.json index 6f8cbac311b23..232212205ed96 100644 --- a/examples/cms-contentful/package.json +++ b/examples/cms-contentful/package.json @@ -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", From 9a1cd356dbafbfcf23d1b9ec05f772f766d05580 Mon Sep 17 00:00:00 2001 From: malewis5 Date: Thu, 6 Jun 2024 14:02:57 -0400 Subject: [PATCH 3/5] fix: ignore to test build --- examples/cms-contentful/app/api/draft/route.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/cms-contentful/app/api/draft/route.ts b/examples/cms-contentful/app/api/draft/route.ts index ba5f454abf582..a89c2f3cd13d6 100644 --- a/examples/cms-contentful/app/api/draft/route.ts +++ b/examples/cms-contentful/app/api/draft/route.ts @@ -1 +1,2 @@ +//@ts-ignore export { enableDraftHandler as GET } from "@contentful/vercel-nextjs-toolkit/app-router"; From ad9e61a8244b22f188d1c15f4558fa2cb7d1273a Mon Sep 17 00:00:00 2001 From: joel Date: Tue, 6 Aug 2024 14:30:14 -0700 Subject: [PATCH 4/5] fix: inngest example for latest version --- examples/inngest/package.json | 7 ++-- examples/inngest/src/app/api/inngest/route.ts | 5 ++- examples/inngest/src/app/page.tsx | 2 +- .../src/inngest/functions/hello-world.ts | 10 ------ .../inngest/src/inngest/inngest.client.ts | 4 --- .../inngest/src/inngest/inngest.config.ts | 33 +++++++++++++++++++ 6 files changed, 40 insertions(+), 21 deletions(-) delete mode 100755 examples/inngest/src/inngest/functions/hello-world.ts delete mode 100755 examples/inngest/src/inngest/inngest.client.ts create mode 100644 examples/inngest/src/inngest/inngest.config.ts diff --git a/examples/inngest/package.json b/examples/inngest/package.json index c86ec816af529..d161eae510afb 100755 --- a/examples/inngest/package.json +++ b/examples/inngest/package.json @@ -2,8 +2,8 @@ "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" }, @@ -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", + "typescript": "5.5.4" } } diff --git a/examples/inngest/src/app/api/inngest/route.ts b/examples/inngest/src/app/api/inngest/route.ts index 1c4353142736f..6b08044ea5ce1 100755 --- a/examples/inngest/src/app/api/inngest/route.ts +++ b/examples/inngest/src/app/api/inngest/route.ts @@ -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); diff --git a/examples/inngest/src/app/page.tsx b/examples/inngest/src/app/page.tsx index 3089b9b43009b..46c1f5fae0fbe 100755 --- a/examples/inngest/src/app/page.tsx +++ b/examples/inngest/src/app/page.tsx @@ -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() { diff --git a/examples/inngest/src/inngest/functions/hello-world.ts b/examples/inngest/src/inngest/functions/hello-world.ts deleted file mode 100755 index a31ddf4d00159..0000000000000 --- a/examples/inngest/src/inngest/functions/hello-world.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { inngest } from "../inngest.client"; - -export 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 }; - }, -); diff --git a/examples/inngest/src/inngest/inngest.client.ts b/examples/inngest/src/inngest/inngest.client.ts deleted file mode 100755 index c11ec011e3140..0000000000000 --- a/examples/inngest/src/inngest/inngest.client.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Inngest } from "inngest"; - -// Create a client to send and receive events -export const inngest = new Inngest({ id: "Basic Inngest Application" }); diff --git a/examples/inngest/src/inngest/inngest.config.ts b/examples/inngest/src/inngest/inngest.config.ts new file mode 100644 index 0000000000000..74617accec9b7 --- /dev/null +++ b/examples/inngest/src/inngest/inngest.config.ts @@ -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(), +}); + +// 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], +}; From 3083b34f71136dcece5931a5d060a5101ef9eb6b Mon Sep 17 00:00:00 2001 From: Joel Hooks Date: Mon, 12 Aug 2024 06:12:16 -0600 Subject: [PATCH 5/5] update inngest package range to 3.x this was requested by Dan --- examples/inngest/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/inngest/package.json b/examples/inngest/package.json index d161eae510afb..d5a93e5b197df 100755 --- a/examples/inngest/package.json +++ b/examples/inngest/package.json @@ -8,7 +8,7 @@ "start": "next start" }, "dependencies": { - "inngest": "latest", + "inngest": "3.x", "next": "latest", "react": "18.2.0", "react-dom": "18.2.0"