import { NextResponse } from 'next/server';
import getDB from '@/lib/prisma';

export const dynamic = 'force-dynamic';

export async function GET() {
    try {
        const prisma = getDB();
        const plans = await prisma.plan.findMany({
            orderBy: { price: 'asc' }
        });
        const response = NextResponse.json(plans);
        response.headers.set('Cache-Control', 'no-store, max-age=0');
        return response;
    } catch (error) {
        console.error('Failed to fetch plans', error);
        return NextResponse.json({ error: 'Failed to fetch plans' }, { status: 500 });
    }
}
