Initial commit

This commit is contained in:
twotalesanimation
2026-06-11 10:46:09 +02:00
commit 81ad7e4ea9
223 changed files with 39530 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth-options';
import { prisma } from '@/lib/prisma';
import { NextRequest, NextResponse } from 'next/server';
export async function DELETE(
request: NextRequest,
{ params }: { params: Promise<{ commentId: string }> }
) {
const { commentId } = await params;
const session = await getServerSession(authOptions);
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const role = (session.user as any).role;
if (role !== 'admin' && role !== 'superadmin') {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
}
try {
// Delete the comment and its replies (cascade via Prisma)
const comment = await prisma.comment.delete({
where: { id: commentId },
});
return NextResponse.json({ success: true });
} catch (error) {
console.error('Failed to delete comment:', error);
return NextResponse.json(
{ error: 'Failed to delete comment' },
{ status: 500 }
);
}
}