WIP extracting zoom to package

pull/2022/head
zomars 2022-02-16 13:45:46 -07:00
parent 9fcb82cc80
commit 467d9ad9fd
7 changed files with 38 additions and 26 deletions

5
appStore/tsconfig.json Normal file
View File

@ -0,0 +1,5 @@
{
"extends": "@calcom/tsconfig/base.json",
"include": ["", "@calcom/types"],
"exclude": ["dist", "build", "node_modules"]
}

View File

@ -0,0 +1,21 @@
{
"name": "@calcom/zoomvideo",
"version": "0.0.0",
"main": "./index.ts",
"label": "Zoom",
"⬇️ needs to be the same as the folder name": 1,
"slug": "zoom",
"category": "Video Conferencing",
"description": "Zoom is the most popular video conferencing platform, joinable on the web or via desktop/mobile apps.",
"logo": "/apps/zoom.svg",
"publisher": "Cal.com",
"url": "https://zoom.us/",
"verified": true,
"⬇️ TODO: placeholder for now, pull this from TrustPilot or G2": 1,
"rating": 4.3,
"⬇️ TODO 2: placeholder for now, pull this from TrustPilot or G2": 1,
"reviews": 69,
"dependencies": {
"@calcom/types": "*"
}
}

View File

@ -1,27 +1,20 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { stringify } from "querystring";
import { getSession } from "@lib/auth";
import { BASE_URL } from "@lib/config/constants";
import prisma from "@lib/prisma";
import prisma from "@calcom/prisma";
import "@calcom/types/next";
const BASE_URL = process.env.BASE_URL || `https://${process.env.VERCEL_URL}`;
const client_id = process.env.ZOOM_CLIENT_ID;
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "GET") {
// Check that user is authenticated
const session = await getSession({ req });
if (!session?.user?.id) {
res.status(401).json({ message: "You must be logged in to do this" });
return;
}
// Get user
await prisma.user.findFirst({
rejectOnNotFound: true,
where: {
id: session?.user?.id,
id: req.session?.user?.id,
},
select: {
id: true,

View File

@ -1,9 +1,9 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { getSession } from "@lib/auth";
import { BASE_URL } from "@lib/config/constants";
import prisma from "@calcom/prisma";
import "@calcom/types/next";
import prisma from "../../../../lib/prisma";
const BASE_URL = process.env.BASE_URL || `https://${process.env.VERCEL_URL}`;
const client_id = process.env.ZOOM_CLIENT_ID;
const client_secret = process.env.ZOOM_CLIENT_SECRET;
@ -11,14 +11,6 @@ const client_secret = process.env.ZOOM_CLIENT_SECRET;
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { code } = req.query;
// Check that user is authenticated
const session = await getSession({ req });
if (!session?.user?.id) {
res.status(401).json({ message: "You must be logged in to do this" });
return;
}
const redirectUri = encodeURI(BASE_URL + "/api/integrations/zoomvideo/callback");
const authHeader = "Basic " + Buffer.from(client_id + ":" + client_secret).toString("base64");
const result = await fetch(
@ -38,7 +30,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await prisma.user.update({
where: {
id: session.user.id,
id: req.session?.user.id,
},
data: {
credentials: {
@ -50,5 +42,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
});
res.redirect("/integrations");
res.redirect("/apps/installed");
}

View File

View File

View File

@ -4,7 +4,8 @@
"private": true,
"workspaces": [
"apps/*",
"packages/*"
"packages/*",
"appStore/*"
],
"scripts": {
"build": "turbo run build --scope=\"@calcom/web\" --include-dependencies",