Path: blob/master/src/packages/next/pages/api/v2/compute/get-servers-by-id.ts
1452 views
/*1Get multiple compute servers by their list of global ids.2*/34import getAccountId from "lib/account/get-account";5import { getServersById } from "@cocalc/server/compute/get-servers";6import getParams from "lib/api/get-params";7import throttle from "@cocalc/util/api/throttle";89export default async function handle(req, res) {10try {11res.json(await get(req));12} catch (err) {13res.json({ error: `${err.message}` });14return;15}16}1718async function get(req) {19const account_id = await getAccountId(req);20if (!account_id) {21throw Error("must be signed in");22}23throttle({24account_id,25endpoint: "compute/get-servers-by-id",26});27const { ids, fields } = getParams(req);28let servers = await getServersById({29account_id,30ids,31fields,32});33return servers;34}353637