/**
 * GET /api/analyzer/itglue/applications/:id/xrefs
 *
 * Returns the xref rows for this flexible asset — "tickets that referenced
 * me" + "tickets that updated me" — for the asset detail page.
 */

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

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