mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-31 17:03:38 +00:00
35 lines
808 B
TypeScript
35 lines
808 B
TypeScript
import { auth } from "@clerk/nextjs";
|
|
import { ENTITY_TYPE } from "@prisma/client";
|
|
import { NextResponse } from "next/server";
|
|
|
|
import { db } from "@/lib/db";
|
|
|
|
export async function GET(
|
|
req: Request,
|
|
{ params }: { params: { cardId: string } }
|
|
) {
|
|
try {
|
|
const { orgId, userId } = auth();
|
|
|
|
if (!orgId || !userId)
|
|
return new NextResponse(JSON.stringify({ error: "Unauthorized" }), {
|
|
status: 401,
|
|
});
|
|
|
|
const auditLogs = await db.auditLog.findMany({
|
|
where: {
|
|
orgId,
|
|
entityId: params.cardId,
|
|
entityType: ENTITY_TYPE.CARD,
|
|
},
|
|
orderBy: {
|
|
createdAt: "desc",
|
|
},
|
|
take: 3,
|
|
});
|
|
|
|
return NextResponse.json(auditLogs);
|
|
} catch (error) {
|
|
return new NextResponse(JSON.stringify(error), { status: 500 });
|
|
}
|
|
}
|