Implement database migration, notification logs, and one-click Mailcow setup
This commit is contained in:
24
app/api/logs/route.ts
Normal file
24
app/api/logs/route.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
// GET /api/logs — list notification logs
|
||||
export async function GET() {
|
||||
const session = await auth();
|
||||
if (!session || session.user.role !== "SUPER_ADMIN") {
|
||||
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
}
|
||||
|
||||
try {
|
||||
const logs = await prisma.notificationLog.findMany({
|
||||
include: { user: true },
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 100, // Last 100 logs
|
||||
});
|
||||
|
||||
return NextResponse.json(logs);
|
||||
} catch (error: any) {
|
||||
console.error("[API Logs] Error:", error.message);
|
||||
return NextResponse.json({ error: "Tablo bulunamadı veya veritabanı hatası. Migration yapıldığından emin olun." }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user