2025-06-18 17:50:36 +00:00
|
|
|
'use server';
|
|
|
|
|
|
|
|
|
|
import { fetchAuditRecords } from "@/ee/features/audit/actions";
|
|
|
|
|
import { ErrorCode } from "@/lib/errorCodes";
|
2025-11-28 00:56:11 +00:00
|
|
|
import { serviceErrorResponse } from "@/lib/serviceError";
|
|
|
|
|
import { isServiceError } from "@/lib/utils";
|
2025-06-18 17:50:36 +00:00
|
|
|
import { getEntitlements } from "@sourcebot/shared";
|
2025-11-28 00:56:11 +00:00
|
|
|
import { StatusCodes } from "http-status-codes";
|
2025-06-18 17:50:36 +00:00
|
|
|
|
2025-11-28 00:56:11 +00:00
|
|
|
export const GET = 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",
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-06-18 17:50:36 +00:00
|
|
|
|
2025-11-28 00:56:11 +00:00
|
|
|
const result = await fetchAuditRecords();
|
|
|
|
|
if (isServiceError(result)) {
|
|
|
|
|
return serviceErrorResponse(result);
|
|
|
|
|
}
|
|
|
|
|
return Response.json(result);
|
2025-06-18 17:50:36 +00:00
|
|
|
};
|