Skip to content

[BE-68] Implement GET /api/audit — admin-only paginated audit log endpoint #792

Description

@mftee

Overview

Once audit logs are recorded (BE-67), administrators need an endpoint to read them for compliance, investigation, and reporting purposes. Without this endpoint, audit data accumulates in the database with no way to access it through the API.

Background

Files to create:

  • backend/src/audit/audit.controller.ts

Endpoint:
GET /api/audit — admin-only, protected with JwtAuthGuard + RolesGuard

Query params:

  • actorId — filter by actor
  • action — filter by action type
  • targetType — filter by target entity type
  • startDate / endDate — ISO date range filter
  • page, limit — pagination

Response: { data: AuditLog[], total, page, limit }

The endpoint should also support CSV export via ?format=csv for compliance downloads (optional stretch goal).

Acceptance Criteria

  • Endpoint returns 403 for non-admin users
  • All query filters work correctly in combination
  • Date range filter is inclusive on both ends
  • Results ordered newest-first
  • Response includes the actor's email/name via a JOIN with the users table

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions