chore: move miscellaneous small api pages to app dir api (#19699)
* version and verify-booking-token * username route * api/me * logo route * render email in dev * link route * future * nope and geo location * referal link and daily * intercom route and dynamic variables * intercom route and dynamic variables * scim 2.0 and helpscout route * app credentials * api/book events * fix daily import path in tests * fix buildLegacyRequest generation * fix type errors * migrate the /teams/ routes * move cron jobs * fix daily import path in tests * fix buildLegacyRequest generation * fix type errors * migrate the /teams/ routes * move cron jobs * Revert "api/book events" This reverts commit 607a32fb5b754cad090c2d0cbf64a68f990e220e. * mock next server NextResponse to fix daily video * add default responder to teams api * fix search params * uses nextUrl.searchParams instead of new url * uses nextUrl.searchParams instead of new url * remove outdated api config * remove app dir version of inbound dynamic variables * restore pages version of inbound variables * fix missing code from stupid cursor --------- Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
1 parent
1f1862e526
commit
d1ce04edc1
41 files changed
+1206
-938
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { cookies, headers } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import { performance } from "@calcom/lib/server/perfObserver";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
let isCold = true;
|
||||
|
||||
export async function GET() {
|
||||
const prePrismaDate = performance.now();
|
||||
const prisma = (await import("@calcom/prisma")).default;
|
||||
const preSessionDate = performance.now();
|
||||
|
||||
// Create a legacy request object for compatibility
|
||||
const legacyReq = buildLegacyRequest(headers(), cookies());
|
||||
|
||||
const session = await getServerSession({ req: legacyReq });
|
||||
if (!session) {
|
||||
return NextResponse.json({ message: "Unauthorized" }, { status: 409 });
|
||||
}
|
||||
|
||||
const preUserDate = performance.now();
|
||||
const user = await prisma.user.findUnique({ where: { id: session.user.id } });
|
||||
if (!user) {
|
||||
return NextResponse.json({ message: "No user found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const lastUpdate = performance.now();
|
||||
|
||||
// Create response with headers
|
||||
const response = NextResponse.json({
|
||||
message: `Hello ${user.name}`,
|
||||
prePrismaDate,
|
||||
prismaDuration: `Prisma took ${preSessionDate - prePrismaDate}ms`,
|
||||
preSessionDate,
|
||||
sessionDuration: `Session took ${preUserDate - preSessionDate}ms`,
|
||||
preUserDate,
|
||||
userDuration: `User took ${lastUpdate - preUserDate}ms`,
|
||||
lastUpdate,
|
||||
wasCold: isCold,
|
||||
});
|
||||
|
||||
// Set custom header
|
||||
response.headers.set("x-is-cold", isCold.toString());
|
||||
isCold = false;
|
||||
|
||||
return response;
|
||||
}
|
||||
Reference in new issue
Block a user