Path: blob/master/src/packages/next/pages/api/v2/licenses/get-projects.ts
1452 views
/*1Get all projects signed in user collaborates on2that have at least one license applied to them.34See docs in @cocalc/server/licenses/get-projects.ts56Returns [Project1, Project2, ...] on success or {error:'a message'} on failure.7For the fields in the projects, see @cocalc/server/licenses/get-projects.ts8*/910import getLicensedProjects, {11Project,12} from "@cocalc/server/licenses/get-projects";13import getAccountId from "lib/account/get-account";1415export default async function handle(req, res) {16try {17res.json(await get(req));18} catch (err) {19res.json({ error: `${err.message}` });20return;21}22}2324async function get(req): Promise<Project[]> {25const account_id = await getAccountId(req);26if (account_id == null) {27return [];28}29return await getLicensedProjects(account_id);30}313233