import { NextRequest, NextResponse } from 'next/server';
import { cachedBackendJson } from '@/services/odds-cache';

export const dynamic = 'force-dynamic';
export const revalidate = 300;

export async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  if (!id) return NextResponse.json({ props: [] });

  try {
    const data = await cachedBackendJson<{ props: unknown[] }>(
      `game:props:${id}`,
      'mixed',
      'game_props',
      `/api/games/${encodeURIComponent(id)}/props`,
      300,
    );
    return NextResponse.json({ props: Array.isArray(data?.props) ? data.props : [] });
  } catch {
    return NextResponse.json({ props: [] });
  }
}
