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:
co-authored by
Peer Richelsen
parent
4ff21deb89
commit
a7f5250b4a
@@ -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` });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user