[Feature] App Store CLI - Make it super easy to add an app. (#2917)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Hariom Balharaandkodiakhq[bot] authored and GitHub committed 2022-06-07 11:43:32 +05:30
1 parent 51b86b1d97
commit 18e0f13605
44 files changed
+1290 -131

No files matched your search

+7 -6
View File
@@ -1,5 +1,7 @@
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType";
import { getSession } from "@lib/auth";
import { HttpError } from "@lib/core/http/error";
@@ -13,15 +15,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
return res.status(404).json({ message: `API route not found` });
}
const [_appName, apiEndpoint] = args;
const appName = _appName.split("_").join(""); // Transform `zoom_video` to `zoomvideo`;
const [appName, apiEndpoint] = args;
try {
/* 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 handlerMap = (await import("@calcom/app-store/apps.server.generated")).apiHandlers;
const handlerKey = deriveAppDictKeyFromType(appName, handlerMap);
const handlers = await handlerMap[handlerKey as keyof typeof handlerMap];
const handler = handlers[apiEndpoint as keyof typeof handlers] as NextApiHandler;
if (typeof handler !== "function")
throw new HttpError({ statusCode: 404, message: `API handler not found` });
+1 -1
View File
@@ -114,7 +114,7 @@ export const getStaticProps = async (ctx: GetStaticPropsContext) => {
let source = "";
try {
/* If the app doesn't have a README we fallback to the packagfe description */
/* If the app doesn't have a README we fallback to the package description */
source = fs.readFileSync(postFilePath).toString();
} catch (error) {
console.log(`No README.mdx provided for: ${appDirname}`);