Path: blob/master/src/packages/next/pages/api/v2/projects/create.ts
1451 views
/*1API endpoint to create a new project.23This requires the user to be signed in so they are allowed to create a project.4*/5import getAccountId from "lib/account/get-account";6import create from "@cocalc/server/projects/create";7import getParams from "lib/api/get-params";89export default async function handle(req, res) {10const { title, description, image, license, public_path_id } = getParams(req);11const account_id = await getAccountId(req);12try {13const project_id = await createProject(14account_id,15title,16description,17image,18license,19public_path_id20);21res.json({ project_id });22} catch (err) {23res.json({ error: err.message });24}25}2627async function createProject(28account_id,29title,30description,31image,32license,33public_path_id?: string34): Promise<string> {35if (!account_id) {36throw Error("user must be signed in");37}38return await create({39account_id,40title,41description,42image,43license,44public_path_id,45});46}474849