-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DC-4755 Fix Example Projects #8278
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
Conversation
WalkthroughIntroduces a new Clerk webhook API route under app/, migrates Prisma client setup from src/ to lib/, updates Prisma schema (IDs to Int, generator/provider/output path), adjusts tsconfig alias, modifies .gitignore scope, updates dependencies and removes ESLint config, and makes minor formatting and README setup changes. Changes
Sequence Diagram(s)sequenceDiagram
participant Clerk as Clerk
participant Route as Next.js Route (/api/webhooks/clerk)
participant Verify as Clerk SDK (verifyWebhook)
participant DB as Prisma
Clerk->>Route: POST webhook (headers + body)
Route->>Verify: verifyWebhook(headers, body)
alt verification ok
Verify-->>Route: event (type, data)
alt event.type == "user.created"
Route->>DB: upsert User by clerkId (email, name)
DB-->>Route: upsert result
Route-->>Clerk: 200 "Webhook received"
else other event
Route-->>Clerk: 200
end
else verification fails
Route-->>Clerk: 400 "Error verifying webhook"
end
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
🔭 Outside diff range comments (2)
orm/clerk-nextjs/package.json (2)
5-10: Lint script likely fails in CI without eslint installedYou removed ESLint deps but kept "lint": "next lint". In CI, Next will prompt to install ESLint and exit non‑zero. Either re-add ESLint deps or drop the script.
Option A: Re-add ESLint packages (recommended if you intend to lint):
"scripts": { "dev": "next dev --turbopack", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint" },Add these devDependencies (outside this hunk):
{ "devDependencies": { "eslint": "^9", "eslint-config-next": "15.4.6" } }Option B: Remove the lint script:
"scripts": { "dev": "next dev --turbopack", "build": "next build", - "start": "next start", - "lint": "next lint" + "start": "next start" },
5-10: Guarantee Prisma client generation in local and CI via a postinstall hookWith the custom generator/output and no @prisma/client dependency, generation must run before build/tests. Add a postinstall (or prepare) script.
Apply this diff:
"scripts": { "dev": "next dev --turbopack", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "postinstall": "prisma generate" },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
orm/clerk-nextjs/app/favicon.icois excluded by!**/*.ico
📒 Files selected for processing (13)
orm/clerk-nextjs/.gitignore(1 hunks)orm/clerk-nextjs/README.md(1 hunks)orm/clerk-nextjs/app/api/webhooks/clerk/route.ts(1 hunks)orm/clerk-nextjs/app/components/PostInputs.tsx(2 hunks)orm/clerk-nextjs/app/layout.tsx(2 hunks)orm/clerk-nextjs/app/page.tsx(2 hunks)orm/clerk-nextjs/eslint.config.mjs(0 hunks)orm/clerk-nextjs/lib/prisma.ts(1 hunks)orm/clerk-nextjs/package.json(2 hunks)orm/clerk-nextjs/prisma/schema.prisma(2 hunks)orm/clerk-nextjs/src/app/api/webhooks/clerk/route.ts(0 hunks)orm/clerk-nextjs/src/lib/prisma.ts(0 hunks)orm/clerk-nextjs/tsconfig.json(1 hunks)
💤 Files with no reviewable changes (3)
- orm/clerk-nextjs/src/app/api/webhooks/clerk/route.ts
- orm/clerk-nextjs/src/lib/prisma.ts
- orm/clerk-nextjs/eslint.config.mjs
🧰 Additional context used
🧬 Code Graph Analysis (2)
orm/clerk-nextjs/app/api/webhooks/clerk/route.ts (1)
orm/clerk-nextjs/app/api/posts/route.ts (1)
POST(4-25)
orm/clerk-nextjs/app/components/PostInputs.tsx (1)
accelerate/accelerate-hacker-news/app/submit/actions/addPost.ts (1)
createPost(5-25)
🔇 Additional comments (15)
orm/clerk-nextjs/tsconfig.json (1)
22-22: LGTM: Path mapping updated to support root-level imports.The change from
"./src/*"to"./*"properly aligns with the project structure migration fromsrc/to root-level directories, enabling imports like@/lib/prismaand@/app/components/*.orm/clerk-nextjs/README.md (1)
46-46: Essential step added for Prisma setup.The added migration step is crucial for setting up the database schema after adding the connection URL. This ensures the database is properly initialized before running the application.
orm/clerk-nextjs/.gitignore (1)
44-44: LGTM: Gitignore updated for new Prisma client location.The ignore rule correctly targets the new generated Prisma client location at
/app/generated/prisma, which aligns with the schema output path change.orm/clerk-nextjs/lib/prisma.ts (4)
4-6: LGTM: Proper global singleton pattern implementation.The global type extension correctly types the
globalForPrismaobject for storing the Prisma client instance across module reloads in development.
8-9: LGTM: Singleton with Accelerate extension.The implementation correctly creates a singleton Prisma client with the Accelerate extension applied, following Next.js best practices for database connections.
11-11: LGTM: Development-only caching.Properly caches the Prisma instance on the global object only in non-production environments to prevent connection exhaustion during development hot reloads.
13-13: LGTM: Clean default export.The default export provides a clean interface for importing the configured Prisma client throughout the application.
orm/clerk-nextjs/app/layout.tsx (4)
1-11: Minor formatting improvements applied.The changes improve code consistency with proper quote usage and import formatting. All changes are stylistic and don't affect functionality.
13-26: LGTM: Font configuration updated with consistent formatting.The Geist font configurations maintain the same functionality while applying consistent formatting with proper quotes and spacing.
28-32: Minor type formatting improvement.The addition of a semicolon after
React.ReactNodein the type definition improves consistency with TypeScript formatting conventions.
37-37: LGTM: Template literal and formatting improvements.The changes improve code readability with proper template literal formatting and consistent semicolon usage.
Also applies to: 43-43, 57-58
orm/clerk-nextjs/app/api/webhooks/clerk/route.ts (1)
1-1: Import path for verifyWebhook is correct
Verified that@clerk/nextjs@6.30.1exportsverifyWebhookfrom the@clerk/nextjs/webhookssubpath (see Clerk docs¹). No changes needed.Citations:
orm/clerk-nextjs/prisma/schema.prisma (1)
12-12: Breaking change to ID type: ensure migrations and dependent code are updatedChanging your Prisma model’s
idfield fromStringtoIntis a breaking change. Before merging, please:
- Verify your Prisma migration either transforms existing string IDs into integers or resets them cleanly.
- Confirm all API routes consume numeric IDs (e.g. in
app/api/posts/route.ts,authorId = user.idshould be anInt).- Audit client-side code, auth callbacks/sessions, URL parameters, and any tests or fixtures that reference
.idto ensure they expect numbers, not strings.- Check seed scripts or custom SQL to maintain referential integrity after the change.
Let me know if you’d like a sample Prisma migration script for resetting vs. transforming your existing data.
orm/clerk-nextjs/package.json (1)
12-17: Clerk webhook verification supported via@clerk/nextjs/webhooksThe
webhookssubpath is exported in@clerk/nextjs@6.30.1, so you can safely import from
"@clerk/nextjs/webhooks"for your route.ts verification helper. No need to reintroducesvixor adjust the current setup.orm/clerk-nextjs/app/page.tsx (1)
1-12: LGTM: Path alias usage and query look consistent with the new Prisma/User shapeImports resolve to the new prisma client wrapper, and the relation filter on author.clerkId aligns with the schema changes.
Summary by CodeRabbit