Path: blob/master/src/packages/next/pages/api/v2/billing/get-subscriptions.ts
1451 views
/*1Get subscriptions for the signed in user.2*/34import getSubscriptions from "@cocalc/server/billing/get-subscriptions";5import getAccountId from "lib/account/get-account";6import getParams from "lib/api/get-params";78export default async function handle(req, res) {9try {10res.json(await get(req));11} catch (err) {12res.json({ error: `${err.message}` });13return;14}15}1617async function get(req): Promise<object> {18const account_id = await getAccountId(req);19if (account_id == null) {20return [];21}22// these are defined at https://stripe.com/docs/api/pagination23// limit is between 1 and 10024// starting_after and ending_before are object id's25const { limit, starting_after, ending_before } = getParams(req);26return await getSubscriptions(account_id, {27limit,28starting_after,29ending_before,30});31}323334