refactor: migrate users.list endpoint to ajv schema

KR
7mo ago
+134-146

Proposed changes (including screenshots)

This PR updates the legacy users.list REST API endpoint to use strict AJV schema validation.

  • Swapped out the old manual query validation for ajv.compile on all query params (offset, count, sort, fields, query).
  • Added a strict response schema to enforce that the endpoint always returns the required shape (users, count, offset, total).
  • The underlying MongoDB aggregation and permission checks remain untouched to prevent regressions.

(Note: Tested the UI after the migration, attaching screenshot below showing the Directory still loading users correctly).
image

Issue(s)

N/A

Steps to test or reproduce

  1. Spin up the local development environment using yarn dsv.
  2. Log in and click the "Directory" (globe icon) on the left sidebar.
  3. Switch to the "Users" tab.
  4. Verify the user list loads properly, pagination works, and no 400/500 errors appear in the server terminal or browser console.

Further comments

Kept the scope strictly to adding the validation layer to avoid breaking any existing client integrations.

Summary by CodeRabbit

  • New Features
    • Restored an authenticated users.list endpoint with permissions, enhanced query validation, filtering, sorting and pagination.
    • Listing responses now return users plus pagination metadata (users, count, offset, total) and include a success flag.
    • Avatar suggestion responses now follow the unified listing response format and include the success flag.