Stripe handlers debugging

debugging-stripe-api-handlers
zomars 2022-05-31 12:45:24 -06:00
parent 7c34be272f
commit 5d01a1907f
3 changed files with 8 additions and 8 deletions

View File

@ -20,7 +20,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
/* Absolute path didn't work */
const handlerMap = (await import("@calcom/app-store/apiHandlers")).default;
const handlers = await handlerMap[appName as keyof typeof handlerMap];
const handler = handlers[apiEndpoint as keyof typeof handlers] as NextApiHandler;
const handler: NextApiHandler = handlers[apiEndpoint as keyof typeof handlers];
if (typeof handler !== "function")
throw new HttpError({ statusCode: 404, message: `API handler not found` });
@ -33,7 +33,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (error instanceof HttpError) {
return res.status(error.statusCode).json({ message: error.message });
}
return res.status(404).json({ message: `API handler not found` });
return res.status(500).json({ message: `Unkown error in apiHandlers` });
}
};

View File

@ -1 +1 @@
export { default, config } from "@ee/pages/api/integrations/stripepayment/webhook";
export { config, default } from "@calcom/app-store/stripepayment/api/webhook";

View File

@ -5,16 +5,16 @@ import Stripe from "stripe";
import EventManager from "@calcom/core/EventManager";
import { isPrismaObjOrUndefined } from "@calcom/lib";
import { IS_PRODUCTION } from "@calcom/lib/constants";
import { getErrorFromUnknown } from "@calcom/lib/errors";
import { HttpError as HttpCode } from "@calcom/lib/http-error";
import { getTranslation } from "@calcom/lib/server/i18n";
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
import stripe from "@calcom/stripe/server";
import { CalendarEvent, RecurringEvent } from "@calcom/types/Calendar";
import { IS_PRODUCTION } from "@lib/config/constants";
import { HttpError as HttpCode } from "@lib/core/http/error";
import { sendScheduledEmails } from "@lib/emails/email-manager";
import { getTranslation } from "@server/lib/i18n";
// TODO: Figure an optimal way to share this code to app store (🤞 for circular dependencies)
import { sendScheduledEmails } from "../../../../apps/web/lib/emails/email-manager";
export const config = {
api: {