mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-09 08:09:46 -06:00
feat: fix prisma accelerate types (#812)
* Fix prisma client types; * Undo ungraceful changes to the sync route with a more graceful cloud-only fix. * update prisma runtime
This commit is contained in:
@@ -1,28 +1,33 @@
|
||||
/* import { getSurveys } from "@/app/api/v1/js/surveys"; */
|
||||
import { getSurveys } from "@/app/api/v1/js/surveys";
|
||||
import { responses } from "@/lib/api/response";
|
||||
/* import { transformErrorToDetails } from "@/lib/api/validator";
|
||||
import { IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
|
||||
import { transformErrorToDetails } from "@/lib/api/validator";
|
||||
import { getActionClasses } from "@formbricks/lib/services/actionClass";
|
||||
import { getEnvironment } from "@formbricks/lib/services/environment";
|
||||
import { createPerson, getPerson } from "@formbricks/lib/services/person";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/services/product";
|
||||
import { createSession, extendSession, getSession } from "@formbricks/lib/services/session"; */
|
||||
/* import { captureTelemetry } from "@formbricks/lib/telemetry"; */
|
||||
/* import { TJsState, ZJsSyncInput } from "@formbricks/types/v1/js";
|
||||
import { createSession, extendSession, getSession } from "@formbricks/lib/services/session";
|
||||
import { captureTelemetry } from "@formbricks/lib/telemetry";
|
||||
import { TJsState, ZJsSyncInput } from "@formbricks/types/v1/js";
|
||||
import { TPerson } from "@formbricks/types/v1/people";
|
||||
import { TSession } from "@formbricks/types/v1/sessions"; */
|
||||
import { TSession } from "@formbricks/types/v1/sessions";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
/* const captureNewSessionTelemetry = async (jsVersion?: string): Promise<void> => {
|
||||
const captureNewSessionTelemetry = async (jsVersion?: string): Promise<void> => {
|
||||
await captureTelemetry("session created", { jsVersion: jsVersion ?? "unknown" });
|
||||
}; */
|
||||
};
|
||||
|
||||
export async function OPTIONS(): Promise<NextResponse> {
|
||||
return responses.successResponse({}, true);
|
||||
}
|
||||
|
||||
export async function POST(/* req: Request */): Promise<NextResponse> {
|
||||
return responses.notFoundResponse("Sync", "Temporarily deactivated", true);
|
||||
/* try {
|
||||
export async function POST(req: Request): Promise<NextResponse> {
|
||||
if (IS_FORMBRICKS_CLOUD) {
|
||||
// hotfix for cloud
|
||||
// TODO: remove this when we have a proper fix
|
||||
return responses.notFoundResponse("Sync", "Temporarily deactivated", true);
|
||||
}
|
||||
try {
|
||||
const jsonInput = await req.json();
|
||||
|
||||
// validate using zod
|
||||
@@ -172,5 +177,5 @@ export async function POST(/* req: Request */): Promise<NextResponse> {
|
||||
"Unable to complete response. See server logs for details.",
|
||||
true
|
||||
);
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { withAccelerate } from "@prisma/extension-accelerate";
|
||||
|
||||
declare global {
|
||||
var prisma: any | undefined; // use any type for now. TODO: add support for Accelerate
|
||||
function makePrisma() {
|
||||
return new PrismaClient({
|
||||
datasources: { db: { url: process.env.DATABASE_URL } },
|
||||
}).$extends(withAccelerate());
|
||||
}
|
||||
|
||||
export const prisma =
|
||||
global.prisma ||
|
||||
new PrismaClient({ datasources: { db: { url: process.env.DATABASE_URL } } }).$extends(withAccelerate());
|
||||
const globalForPrisma = global as unknown as {
|
||||
prisma: ReturnType<typeof makePrisma>;
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== "production") global.prisma = prisma;
|
||||
export const prisma = globalForPrisma.prisma ?? makePrisma();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = makePrisma();
|
||||
|
||||
Reference in New Issue
Block a user