Path: blob/master/src/packages/next/pages/api/v2/compute/google-cloud/get-pricing-data.ts
1452 views
/*1Get pricing data.23This gets a json object that can be used to efficiently browse and get pricing data4about almost everything related to Google Cloud VM's. The idea is that this5is useful in itself, and also the module6@cocalc/util/compute/cloud/google-cloud/compute-cost7can run on the frontend, and takes this data to quickly compute total cost per hour8of a configuration.910We only allow api requests for signed in users to avoid abuse.11*/1213import getAccountId from "lib/account/get-account";14import getPricingData from "@cocalc/server/compute/cloud/google-cloud/pricing-data";1516export default async function handle(req, res) {17try {18res.json(await get(req));19} catch (err) {20res.json({ error: `${err.message}` });21return;22}23}2425async function get(req) {26const account_id = await getAccountId(req);27if (!account_id) {28throw Error("must be signed in");29}3031return await getPricingData();32}333435