All files / web/src/app/api/billing/prices route.ts

0% Statements 0/40
0% Branches 0/1
0% Functions 0/1
0% Lines 0/40

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import { NextResponse } from 'next/server'
import { getActivePricing } from '@/lib/stripe'

/**
 * GET /api/billing/prices
 *
 * Returns current display pricing for the public pricing page.
 * No auth required — this is public information.
 */
export async function GET() {
  try {
    const pricing = await getActivePricing()

    const monthlyAmount = pricing.family.monthly.amount
    const annualAmount = pricing.family.annual.amount

    return NextResponse.json({
      family: {
        monthly: {
          amount: monthlyAmount,
          display: monthlyAmount / 100,
        },
        annual: {
          amount: annualAmount,
          display: annualAmount / 100,
          monthlyEquivalent: Math.round((annualAmount / 12) * 100) / 10000,
        },
      },
    })
  } catch (error) {
    console.error('[billing/prices] Error fetching prices:', error)
    // Fall back to static pricing.json values
    return NextResponse.json({
      family: {
        monthly: { amount: 600, display: 6 },
        annual: { amount: 3768, display: 37.68, monthlyEquivalent: 3.14 },
      },
    })
  }
}