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

31 view post #33

Merged
merged 10 commits into from
Mar 6, 2025
Prev Previous commit
fix: update prisma client instantiation
danielvanc committed Mar 6, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7104250b0e362992b1f7086532283f39faa8c1cd
16 changes: 11 additions & 5 deletions utils/db.ts
Original file line number Diff line number Diff line change
@@ -5,11 +5,17 @@ import { withOptimize } from "@prisma/extension-optimize";
import { PrismaAdapter } from "@auth/prisma-adapter";
import { notFound, redirect } from "next/navigation";

export const prisma = remember("prisma", () =>
new PrismaClient()
.$extends(withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY! }))
.$extends(withAccelerate())
);
const isProd = process.env.NODE_ENV === "production";

const generateClient = () => {
return isProd
? new PrismaClient().$extends(withAccelerate())
: new PrismaClient()
.$extends(withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY! }))
.$extends(withAccelerate());
};

export const prisma = remember("prisma", generateClient);

export const authAdapter = PrismaAdapter(prisma);