
* dotenv refactoring * dotenv fixes * Env variables cleanup * Updates e2e variables * Moves environment file to types * Removes conflicting configs * Readds missing variables * Fixes * More fixes * Update .env.example * Update yarn.lock * Update turbo.json * Fixes e2e * Temp fix * disables cache for lint * Please work * I'm getting desperate here. * Matches node versions * Take 2 * Revert "Take 2" This reverts commit a735f47f2325c2040168e0cd99dea0fc357a791f. * Update .env.example
21 lines
655 B
TypeScript
21 lines
655 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { upgradeTeam } from "@calcom/stripe/team-billing";
|
|
|
|
import { getSession } from "@lib/auth";
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
if (req.method === "GET") {
|
|
const session = await getSession({ req });
|
|
|
|
if (!session) {
|
|
res.status(401).json({ message: "You must be logged in to do this" });
|
|
return;
|
|
}
|
|
|
|
await upgradeTeam(session.user.id, Number(req.query.team));
|
|
|
|
// redirect to team screen
|
|
res.redirect(302, `${process.env.NEXT_PUBLIC_WEBAPP_URL}/settings/teams/${req.query.team}?upgraded=true`);
|
|
}
|
|
}
|