Path: blob/master/src/packages/next/pages/api/v2/compute/cloud-filesystem/create.ts
1452 views
/*1Create a cloud file system2*/34import getAccountId from "lib/account/get-account";5import { createCloudFilesystem, Options } from "@cocalc/server/compute/cloud-filesystem/create";6import { FIELDS } from "@cocalc/server/compute/cloud-filesystem/get";7import type { CloudFilesystem } from "@cocalc/util/db-schema/cloud-filesystems";89import getParams from "lib/api/get-params";1011export default async function handle(req, res) {12try {13res.json(await get(req));14} catch (err) {15res.json({ error: `${err.message}` });16return;17}18}1920async function get(req) {21const account_id = await getAccountId(req);22if (!account_id) {23throw Error("must be signed in");24}2526const params = getParams(req);27const opts: Partial<CloudFilesystem> = {};28for (const field of FIELDS) {29const x = params[field];30if (x !== undefined) {31opts[field] = x;32}33}34return await createCloudFilesystem({35...opts,36account_id,37} as Options);38}394041