integrated audit log into pretty everything hopefully
All checks were successful
Pull Request CI / Update Deployment (pull_request) Successful in 3m28s

This commit is contained in:
2026-02-12 22:04:14 -05:00
parent 5106b72e24
commit c7d79ae586
9 changed files with 67 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
import pool from "../../db";
import { logger } from "./logger";
export type AuditArea = 'member' | 'calendar' | 'unit' | 'auth' | 'admin' | 'application';
export type AuditArea = 'member' | 'calendar' | 'roles' | 'auth' | 'leave_of_absence' | 'application' | 'course';
export interface AuditContext {
actorId: number; // The person doing the action (created_by)
@@ -33,18 +33,29 @@ class AuditLogger {
}
}
// Making data optional using '?' and default parameter
member(action: 'update_rank' | 'status_change' | 'create', context: AuditContext, data: any = {}) {
member(action: 'update_rank' | 'suspension_added' | 'suspension_removed' | 'discharged', context: AuditContext, data: any = {}) {
return this.record('member', action, context, data);
}
calendar(action: 'event_signup' | 'event_create' | 'attendance', context: AuditContext, data: any = {}) {
roles(action: 'add_member' | 'remove_member' | 'create' | 'delete', context: AuditContext, data: any = {}) {
return this.record('roles', action, context, data);
}
leaveOfAbsence(action: 'created' | 'admin_created' | 'ended' | 'admin_ended' | 'extended', context: AuditContext, data: any = {}) {
return this.record('leave_of_absence', action, context, data);
}
calendar(action: 'event_created' | 'event_updated' | 'attendance_set' | 'cancelled' | 'un-cancelled', context: AuditContext, data: any = {}) {
return this.record('calendar', action, context, data);
}
application(action: 'created' | 'approved' | 'denied' | 'restarted', context: AuditContext, data: any = {}) {
return this.record('application', action, context, data);
}
course(action: 'report_created' | 'report_edited', context: AuditContext, data: any = {}) {
return this.record('course', action, context, data);
}
}
export const audit = new AuditLogger();