perf: Enable Prisma Optimize (#44)
* Enable Prisma Optimize * Added Environment variable to toggle on and off the Prisma Optimize --------- Co-authored-by: harshsbhat <icybhat@gmail.com>
This commit is contained in:
committed by
GitHub
parent
75afd339ea
commit
0c072579b9
@@ -1,12 +1,18 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
import { withOptimize } from "@prisma/extension-optimize";
|
||||
import { env } from "~/env";
|
||||
|
||||
const createPrismaClient = () =>
|
||||
new PrismaClient({
|
||||
const createPrismaClient = () => {
|
||||
const client = new PrismaClient({
|
||||
log:
|
||||
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
|
||||
});
|
||||
if (env.ENABLE_PRISMA_CLIENT) {
|
||||
return client.$extends(withOptimize());
|
||||
}
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
|
Reference in New Issue
Block a user