mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-01 03:09:34 +00:00
Initial Commit
This commit is contained in:
commit
f3e2f01bd7
150 changed files with 13612 additions and 0 deletions
35
app/api/cards/[cardId]/logs/route.ts
Normal file
35
app/api/cards/[cardId]/logs/route.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
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 });
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue