import { PLANS } from '$lib/plans';
import { usageByDataset, usageByKey, usageCountThisMonth } from '$lib/server/usage';
import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async ({ locals }) => {
  const account = locals.account!;
  return {
    plan: PLANS[account.plan],
    total: usageCountThisMonth(account.id),
    byDataset: usageByDataset(account.id),
    byKey: usageByKey(account.id)
  };
};
