Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/api/v2/compute/create-server.ts
Views: 687
/*1Create a compute server2*/34import getAccountId from "lib/account/get-account";5import createServer from "@cocalc/server/compute/create-server";6import getParams from "lib/api/get-params";78import { apiRoute, apiRouteOperation } from "lib/api";9import {10CreateServerInputSchema,11CreateServerOutputSchema12} from "lib/api/schema/compute/create-server";131415async 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) {25const account_id = await getAccountId(req);26if (!account_id) {27throw Error("must be signed in");28}29const {30project_id,31title,32color,33idle_timeout,34autorestart,35cloud,36configuration,37notes,38} = getParams(req);39return await createServer({40account_id,41project_id,42title,43color,44idle_timeout,45autorestart,46cloud,47configuration,48notes,49});50}5152export default apiRoute({53createServer: apiRouteOperation({54method: "POST",55openApiOperation: {56tags: ["Compute"]57},58})59.input({60contentType: "application/json",61body: CreateServerInputSchema,62})63.outputs([64{65status: 200,66contentType: "application/json",67body: CreateServerOutputSchema,68},69])70.handler(handle),71});727374