* WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Update CalendarService.ts * Type fixes * WIP * fix: improve cache hits * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Feedback * Update CalendarService.ts * Update CalendarService.ts * Update _router.ts * feedback * WIP * WIP * Update schema.prisma * feedback * typefixes * Update Calendar.d.ts * fix: watches when adding a calendar * Discard changes to packages/app-store/googlecalendar/api/add.ts * WIP Signed-off-by: Omar López <zomars@me.com> * WIP Signed-off-by: Omar López <zomars@me.com> * WP Signed-off-by: Omar López <zomars@me.com> * Update calendar.ts * Update calendar.ts * Update callback.ts * Update callback.ts * Conflicts * WIP * WIP * Update CalendarService.ts * Cleanup * Discard changes to packages/features/settings/layouts/SettingsLayout.tsx * Update calendar-cache.repository.ts * WIP * Update getSelectedCalendarsToWatch.sql * WIP * Update CalendarService.ts * Cleanup * Discard changes to packages/app-store/googlecalendar/lib/CalendarService.ts * Create CalendarService.wip.ts * WIP * Update CalendarService.ts * Update getSelectedCalendarsToWatch.sql * Delete CalendarService.wip.ts * test updates * cleanup Signed-off-by: Omar López <zomars@me.com> * Update CalendarService.test.ts * Update CalendarService.ts * type fixes * Update OAuthManager.ts * Update CalendarService.ts * Almost there * Update CalendarService.test.ts * Update calendar.ts * Update callback.ts * Update toggleFeatureFlag.handler.ts * fix: feedback * Update getSelectedCalendarsToWatch.sql * Fix unit tests --------- Signed-off-by: Omar López <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import type { NextRequest } from "next/server";
|
|
import { NextResponse } from "next/server";
|
|
|
|
import monitorCallbackAsync from "@calcom/core/sentryWrapper";
|
|
|
|
import { getServerErrorFromUnknown } from "./getServerErrorFromUnknown";
|
|
|
|
type Handle<T> = (req: NextRequest) => Promise<T>;
|
|
|
|
/** Variant to use in App Router API routes. Allows us to get type inference from API handler responses */
|
|
export const defaultResponder =
|
|
<T>(f: Handle<T>) =>
|
|
async (req: NextRequest) => {
|
|
try {
|
|
const result = await monitorCallbackAsync(f, req);
|
|
if (result) {
|
|
return NextResponse.json(result);
|
|
}
|
|
} catch (err) {
|
|
const error = getServerErrorFromUnknown(err);
|
|
// we don't want to report Bad Request errors to Sentry / console
|
|
if (!(error.statusCode >= 400 && error.statusCode < 500)) {
|
|
console.error(err);
|
|
const captureException = (await import("@sentry/nextjs")).captureException;
|
|
captureException(err);
|
|
}
|
|
return NextResponse.json({ message: error.message, url: error.url, method: error.method });
|
|
}
|
|
};
|