Enables strict mode in nextjs apps (#2354)

- We need this so zod works correctly

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
Omar López
2022-04-04 20:26:14 +00:00
committed by GitHub
co-authored by Peer Richelsen
parent 4ff21deb89
commit a7f5250b4a
25 changed files with 178 additions and 68 deletions
+7 -2
View File
@@ -1,4 +1,4 @@
import { NextApiRequest, NextApiResponse } from "next";
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
import appStore from "@calcom/app-store";
@@ -26,7 +26,12 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try {
// TODO: Find a way to dynamically import these modules
// const app = (await import(`@calcom/${appName}`)).default;
const handler = appStore[appName].api[apiEndpoint];
const app = appStore[appName as keyof typeof appStore];
if (!(app && "api" in app && apiEndpoint in app.api))
throw new HttpError({ statusCode: 404, message: `API handler not found` });
const handler = app.api[apiEndpoint as keyof typeof app.api] as NextApiHandler;
if (typeof handler !== "function")
throw new HttpError({ statusCode: 404, message: `API handler not found` });