perf: streamline billing panel bootstrap
Remove the redundant billing account read, cache packages for one minute, prefetch the billing chunk, and parallelize independent package reads. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -38,20 +38,22 @@ export async function GET() {
|
||||
if (!availability.enabled)
|
||||
return NextResponse.json({ enabled: false, packages: [] });
|
||||
|
||||
const flags = await loadRuntimeFeatureFlags(["billing.subscriptions"]);
|
||||
const admin = createAdminSupabaseClient();
|
||||
const [flags, productsResult] = await Promise.all([
|
||||
loadRuntimeFeatureFlags(["billing.subscriptions"]),
|
||||
admin
|
||||
.from("billing_products")
|
||||
.select(
|
||||
"id,code,version,name,description,product_type,billing_period,interval_count,price_cents,currency,sort_order,effective_from,effective_to",
|
||||
)
|
||||
.eq("enabled", true)
|
||||
.eq("status", "published")
|
||||
.order("sort_order")
|
||||
.order("created_at"),
|
||||
]);
|
||||
const subscriptionsEnabled =
|
||||
flags.get("billing.subscriptions")?.enabled ?? false;
|
||||
|
||||
const admin = createAdminSupabaseClient();
|
||||
const { data, error } = await admin
|
||||
.from("billing_products")
|
||||
.select(
|
||||
"id,code,version,name,description,product_type,billing_period,interval_count,price_cents,currency,sort_order,effective_from,effective_to",
|
||||
)
|
||||
.eq("enabled", true)
|
||||
.eq("status", "published")
|
||||
.order("sort_order")
|
||||
.order("created_at");
|
||||
const { data, error } = productsResult;
|
||||
if (error) return NextResponse.json({ enabled: false, packages: [] });
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user