-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathroute.ts
More file actions
26 lines (23 loc) · 899 Bytes
/
route.ts
File metadata and controls
26 lines (23 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use server';
import { fetchAuditRecords } from "@/ee/features/audit/actions";
import { apiHandler } from "@/lib/apiHandler";
import { ErrorCode } from "@/lib/errorCodes";
import { serviceErrorResponse } from "@/lib/serviceError";
import { isServiceError } from "@/lib/utils";
import { getEntitlements } from "@sourcebot/shared";
import { StatusCodes } from "http-status-codes";
export const GET = apiHandler(async () => {
const entitlements = getEntitlements();
if (!entitlements.includes('audit')) {
return serviceErrorResponse({
statusCode: StatusCodes.FORBIDDEN,
errorCode: ErrorCode.NOT_FOUND,
message: "Audit logging is not enabled for your license",
});
}
const result = await fetchAuditRecords();
if (isServiceError(result)) {
return serviceErrorResponse(result);
}
return Response.json(result);
});