mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-02 03:15:05 -05:00
refactor: Add caching to the sync endpoint (#819)
* test: caching strategies * feat: caching * remove hotfix code * remove unused import * fix: adds revalidation to action services * add environments to product service & type * fix: fixes caching * fix: fixes product cache * add person revalidation to person js endpoints * update surveys cache rule * add new caching policy for surveys in sync --------- Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { withAccelerate } from "@prisma/extension-accelerate";
|
||||
|
||||
function makePrisma() {
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient({
|
||||
datasources: { db: { url: process.env.DATABASE_URL } },
|
||||
/* log: ["query", "info"], */
|
||||
}).$extends(withAccelerate());
|
||||
}
|
||||
|
||||
const globalForPrisma = global as unknown as {
|
||||
prisma: ReturnType<typeof makePrisma>;
|
||||
};
|
||||
|
||||
export const prisma = globalForPrisma.prisma ?? makePrisma();
|
||||
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = makePrisma();
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClientSingleton | undefined;
|
||||
};
|
||||
|
||||
export const prisma = globalForPrisma.prisma ?? prismaClientSingleton();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||
|
||||
Reference in New Issue
Block a user