Spaces:
Sleeping
Sleeping
| import { NextResponse } from 'next/server' | |
| import { createServerSupabaseClient } from '@/lib/supabase-server' | |
| export async function GET(request: Request) { | |
| try { | |
| const { searchParams } = new URL(request.url) | |
| const limit = parseInt(searchParams.get('limit') || '10') | |
| const model = searchParams.get('model') | |
| const supabase = await createServerSupabaseClient() | |
| let query = supabase | |
| .from('model_interactions') | |
| .select('*') | |
| .order('created_at', { ascending: false }) | |
| .limit(limit) | |
| if (model) { | |
| query = query.eq('model_name', model) | |
| } | |
| const { data, error } = await query | |
| if (error) { | |
| throw error | |
| } | |
| return NextResponse.json({ data }, { status: 200 }) | |
| } catch (error: any) { | |
| console.error('Data API Error:', error) | |
| return NextResponse.json( | |
| { error: error.message || 'Internal server error' }, | |
| { status: 500 } | |
| ) | |
| } | |
| } | |