2023-06-06 11:59:57 +00:00
|
|
|
import type { NextApiRequest } from "next";
|
2022-08-08 05:57:09 +00:00
|
|
|
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
|
|
|
|
import checkSession from "../../_utils/auth";
|
2022-09-15 19:53:09 +00:00
|
|
|
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
|
2022-08-08 05:57:09 +00:00
|
|
|
import { checkInstalled, createDefaultInstallation } from "../../_utils/installation";
|
|
|
|
import appConfig from "../config.json";
|
|
|
|
|
2023-06-06 11:59:57 +00:00
|
|
|
export async function getHandler(req: NextApiRequest) {
|
2022-08-08 05:57:09 +00:00
|
|
|
const session = checkSession(req);
|
|
|
|
const slug = appConfig.slug;
|
|
|
|
const appType = appConfig.type;
|
|
|
|
|
|
|
|
await checkInstalled(slug, session.user.id);
|
|
|
|
await createDefaultInstallation({
|
|
|
|
appType,
|
|
|
|
userId: session.user.id,
|
|
|
|
slug,
|
|
|
|
key: {},
|
|
|
|
});
|
|
|
|
|
2023-05-19 00:22:07 +00:00
|
|
|
return { url: getInstalledAppPath({ variant: appConfig.variant, slug: "ping" }) };
|
2022-08-08 05:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default defaultResponder(getHandler);
|