/**
 * GET /api/analyzer/tickets/:ticketNumber/analyses
 *
 * Lists all analysis versions for a ticket, newest first.
 */

import { NextResponse } from 'next/server';
import { requireAuth } from '@/lib/auth-utils';
import { listAnalysesByTicketNumber } from '@/lib/services/analyzer/persistence';

export async function GET(
  _request: Request,
  { params }: { params: Promise<{ ticketNumber: string }> }
) {
  const { error } = await requireAuth();
  if (error) return error;

  const { ticketNumber } = await params;
  const analyses = await listAnalysesByTicketNumber(ticketNumber);
  return NextResponse.json({ analyses });
}
