24 lines
704 B
TypeScript
24 lines
704 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { auth } from "@/auth";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
// DELETE /api/mappings/[id] — delete a mapping
|
|
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
const session = await auth();
|
|
const { id } = await params;
|
|
|
|
if (!session || session.user.role !== "SUPER_ADMIN") {
|
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
|
}
|
|
|
|
try {
|
|
await prisma.mailboxMapping.delete({
|
|
where: { id },
|
|
});
|
|
|
|
return NextResponse.json({ status: "ok" });
|
|
} catch (error: any) {
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
}
|
|
}
|