refactor: migrate users.list endpoint to ajv schema
ย
KR
7mo ago+134+134+012345678901234567890123456789-146-146-012345678901234567890123456789
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.compileon all query params (offset,count,sort,fields,query). - Added a strict
responseschema 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).
Issue(s)
N/A
Steps to test or reproduce
- Spin up the local development environment using
yarn dsv. - Log in and click the "Directory" (globe icon) on the left sidebar.
- Switch to the "Users" tab.
- 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.