VIBN Frontend for Coolify deployment
This commit is contained in:
37
app/api/ai/conversation/reset/route.ts
Normal file
37
app/api/ai/conversation/reset/route.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getAdminDb } from '@/lib/firebase/admin';
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const url = new URL(request.url);
|
||||
const body = await request
|
||||
.json()
|
||||
.catch(() => ({ projectId: url.searchParams.get('projectId') }));
|
||||
|
||||
const projectId = (body?.projectId ?? url.searchParams.get('projectId') ?? '').trim();
|
||||
|
||||
if (!projectId) {
|
||||
return NextResponse.json(
|
||||
{ error: 'projectId is required' },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
const adminDb = getAdminDb();
|
||||
const docRef = adminDb.collection('chat_conversations').doc(projectId);
|
||||
await docRef.delete();
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('[ai/conversation/reset] Failed to reset conversation', error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Failed to reset conversation',
|
||||
details: error instanceof Error ? error.message : String(error),
|
||||
},
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user