/**
 * GET /api/analyzer/tickets/:ticketNumber/itglue-xrefs
 *
 * Returns the xrefs for one ticket — "every IT Glue asset this ticket
 * touched" — for use on the analysis page or future ticket views.
 */

import { NextRequest, NextResponse } from 'next/server';
import { requireAuth } from '@/lib/auth-utils';
import { listXrefsForTicket } from '@/lib/services/analyzer/asset-audit/xrefs';

export async function GET(
  _request: NextRequest,
  { params }: { params: Promise<{ ticketNumber: string }> }
) {
  const { error } = await requireAuth();
  if (error) return error;
  const { ticketNumber } = await params;
  const xrefs = await listXrefsForTicket(ticketNumber, 100);
  return NextResponse.json({ xrefs });
}
