import { NextResponse } from 'next/server';
import { withErrorHandler } from '@server/middleware/withErrorHandler';
import { withAuth, AuthedRequest } from '@server/middleware/withAuth';
import { getApiUsageChart } from '@server/services/billing.service';

export const GET = withErrorHandler(
  withAuth(async (req: AuthedRequest) => {
    const chart = await getApiUsageChart(req.session.restaurantId!);
    return NextResponse.json({ chart });
  })
);
