(req: NextRequest)
| 56 | | { traceId: string; status: 'error'; model: string; error: string } |
| 57 | |
| 58 | export async function GET(req: NextRequest) { |
| 59 | const authResult = await checkAdminAuth() |
| 60 | if (authResult instanceof NextResponse) { |
| 61 | return authResult |
| 62 | } |
| 63 | |
| 64 | const userId = req.nextUrl.searchParams.get('userId') |
| 65 | if (!userId) { |
| 66 | return NextResponse.json( |
| 67 | { error: 'Missing required parameter: userId' }, |
| 68 | { status: 400 }, |
| 69 | ) |
| 70 | } |
| 71 | |
| 72 | try { |
| 73 | await ensureBigQuery() |
| 74 | const traceBundles = await getTracesAndAllDataForUser(userId) |
| 75 | const data = formatTraceResults(traceBundles) |
| 76 | |
| 77 | return NextResponse.json({ data }) |
| 78 | } catch (error) { |
| 79 | logger.error( |
| 80 | { |
| 81 | error, |
| 82 | userId, |
| 83 | }, |
| 84 | 'Error fetching traces and relabels', |
| 85 | ) |
| 86 | return NextResponse.json( |
| 87 | { error: 'Failed to fetch traces and relabels' }, |
| 88 | { status: 500 }, |
| 89 | ) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | export async function POST(req: NextRequest) { |
| 94 | const authResult = await checkAdminAuth() |
nothing calls this directly
no test coverage detected