42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { adminDb } from '@/lib/firebase/admin';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const projectId = request.nextUrl.searchParams.get('projectId');
|
|
|
|
if (!projectId) {
|
|
return NextResponse.json({ error: 'Missing projectId' }, { status: 400 });
|
|
}
|
|
|
|
// Get 10 conversations with their dates
|
|
const conversationsSnapshot = await adminDb
|
|
.collection('projects')
|
|
.doc(projectId)
|
|
.collection('cursorConversations')
|
|
.orderBy('createdAt', 'desc')
|
|
.limit(10)
|
|
.get();
|
|
|
|
const samples = conversationsSnapshot.docs.map(doc => {
|
|
const data = doc.data();
|
|
return {
|
|
name: data.name,
|
|
createdAt: data.createdAt,
|
|
workspacePath: data.workspacePath
|
|
};
|
|
});
|
|
|
|
return NextResponse.json({ samples });
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching samples:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch samples', details: error instanceof Error ? error.message : String(error) },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
|