games_app/backend/dist/middleware/audit.d.ts
2026-06-29 15:01:23 +02:00

16 lines
926 B
TypeScript

/**
* Express audit-logging middleware.
* Records user actions to the audit_logs table after the HTTP response completes.
*/
import { Response, NextFunction } from 'express';
import { AuthRequest } from './auth';
/**
* Returns middleware that writes an audit log entry when the response finishes.
* Logging is fire-and-forget; failures do not affect the HTTP response.
* @param action Human-readable action name (e.g. 'withdraw', 'login')
* @param resourceType Optional entity type being acted on (e.g. 'user', 'wallet')
* @param getResourceId Optional callback to derive the resource ID from the request
* @returns Express middleware that schedules audit persistence on res 'finish'
*/
export declare function auditAction(action: string, resourceType?: string, getResourceId?: (req: AuthRequest) => string): (req: AuthRequest, res: Response, next: NextFunction) => Promise<void>;
//# sourceMappingURL=audit.d.ts.map