Files
webmailserver/app/api/logs/route.ts

25 lines
797 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 });
}
}