- Analytics: <Analytics /> in root layout loads umami when NEXT_PUBLIC_UMAMI_* env are set - Subscription: free/pro tiers in Postgres, daily quotas (10msg/5tool free, 1000/500 pro) - Chat route: checkAndConsume(chat_message) gate before streamText, 429 when exhausted - Tool metering: getWeather wrapped with withLimit decorator that deducts tool_call quota - Pricing page at /pricing with upgrade button - /api/billing/checkout posts to EGBE payment gateway, /api/billing/webhook verifies HMAC and upgrades user on checkout.session.completed - UsageBadge in chat header polls /api/usage every 15s - Dropped now-unused entitlements.ts
16 lines
460 B
TypeScript
16 lines
460 B
TypeScript
import { auth } from "@/app/(auth)/auth";
|
|
import { ChatbotError } from "@/lib/errors";
|
|
import { getQuotaSummary } from "@/lib/subscription/service";
|
|
|
|
export async function GET() {
|
|
const session = await auth();
|
|
if (!session?.user) {
|
|
return new ChatbotError("unauthorized:chat").toResponse();
|
|
}
|
|
const summary = await getQuotaSummary(session.user.id);
|
|
return Response.json(summary, {
|
|
headers: {
|
|
"Cache-Control": "no-store",
|
|
},
|
|
});
|
|
}
|