🚧 wip: export limits

This commit is contained in:
Fred KISSIE
2025-12-10 03:24:32 +01:00
parent d490cab48c
commit df4b9de334
5 changed files with 57 additions and 13 deletions

View File

@@ -22,9 +22,11 @@ import logger from "@server/logger";
import {
queryAccessAuditLogsParams,
queryAccessAuditLogsQuery,
queryAccess
queryAccess,
countAccessQuery
} from "./queryAccessAuditLog";
import { generateCSV } from "@server/routers/auditLogs/generateCSV";
import { MAX_EXPORT_LIMIT } from "@server/routers/auditLogs";
registry.registerPath({
method: "get",
@@ -65,6 +67,15 @@ export async function exportAccessAuditLogs(
}
const data = { ...parsedQuery.data, ...parsedParams.data };
const [{ count }] = await countAccessQuery(data);
if (count > MAX_EXPORT_LIMIT) {
return next(
createHttpError(
HttpCode.BAD_REQUEST,
`Export limit exceeded. Your selection contains ${count} rows, but the maximum is [${MAX_EXPORT_LIMIT}] rows. Please select a shorter time range to reduce the data.`
)
);
}
const baseQuery = queryAccess(data);