20 lines
522 B
TypeScript
20 lines
522 B
TypeScript
import type { AuditLogEntry } from '../models/audit';
|
|
|
|
const MAX_AUDIT = 1000;
|
|
|
|
export class AuditStore {
|
|
private logs: AuditLogEntry[] = [];
|
|
|
|
append(entry: AuditLogEntry): AuditLogEntry {
|
|
this.logs.push(entry);
|
|
if (this.logs.length > MAX_AUDIT) this.logs.shift();
|
|
return entry;
|
|
}
|
|
|
|
list(limit = 100, offset = 0): AuditLogEntry[] {
|
|
const safeLimit = Math.min(Math.max(1, limit), 500);
|
|
const safeOffset = Math.max(0, offset);
|
|
return this.logs.slice(safeOffset, safeOffset + safeLimit);
|
|
}
|
|
}
|