Skip to content

Add Paginated Group Audit Log API Endpoint with Filtering #283

Description

@Cjay-Cyber-2

Description

Group state changes, membership updates, and settlement executions produce audit logs. Administrators and members need a dedicated API endpoint to retrieve group audit records with cursor-based pagination and filtering by action type or date range.

Context & Requirements

  • Endpoint path: GET /groups/:groupId/audit-logs.
  • Access control: Require active membership in the specified group.
  • Query parameters must be validated using Zod: limit (1-100, default 20), cursor (string/ID), action (optional string filter), startDate and endDate (ISO dates).
  • Response must return audit items along with a nextCursor for pagination.

Acceptance Criteria

  • Define Zod schema for query parameter validation in route file.
  • Implement group membership authorization check prior to executing audit query.
  • Create getGroupAuditLogs method in src/services/auditLogService.ts supporting cursor pagination and filters.
  • Register GET /groups/:groupId/audit-logs endpoint in src/routes/auditLogs.ts.
  • Return 403 Forbidden if user is not a member of the requested group.
  • Write Vitest unit and integration tests covering parameter validation, membership checks, and paginated output.

Implementation Guidance

  • Reference existing group route handlers in src/routes/ for authentication and membership validation patterns.
  • Ensure Prisma queries filter by groupId, optional action, and date range constraints.
  • Format responses consistently with established API output contracts.

Testing & Validation

  • Execute unit and integration tests via npm test.
  • Verify response schema matches mirrored web types in mergepay-web/src/lib/types.ts.

Submission Guidelines

  • Open a PR that includes "Closes #".
  • Request task assignment on the issue before beginning work.
  • Follow standard code conventions and pass npm run lint.

Wave complexity: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programapicomplexity: mediumDrips Wave — moderate scope, some designdrips-waveTracked in a Drips Wave programfeature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions