feat: add /api/admin/users/:addr/notes admin endpoint#453
Open
ValJnr-dev1 wants to merge 1 commit into
Open
Conversation
Add GET/POST/DELETE /api/admin/users/:addr/notes endpoint. - New admin_user_notes table (migration 0023) with index on (target_address, created_at DESC) for efficient listing - Route: src/routes/admin/users/notes.ts — factory pattern, requireAdmin guard, zod param+body validation, 60 rpm rate limit - POST returns 201 with the created note; DELETE is scoped to both note ID and target address to prevent cross-user deletion - Both mutating operations write to admin_audit_log - Structured pino logging with correlation IDs on every handler - 30 focused tests covering auth guard, happy paths, validation, audit trail, 404, 500 error propagation, and rate limiting - Lint: clean; all 30 new tests pass; pre-existing suite failures unchanged (confirmed on main before this change) Closes Predictify-org#289
|
@ValJnr-dev1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #289 — per-user admin notes on user accounts.
Adds three endpoints under
/api/admin/users/:addr/notes:GET/api/admin/users/:addr/notesPOST/api/admin/users/:addr/notes{ note: string, 1–2000 chars }) → 201DELETE/api/admin/users/:addr/notes/:idChanges
src/routes/admin/users/notes.ts— new route, factory patterncreateAdminNotesRouter(opts)matching the freeze/impersonate conventionssrc/db/schema.ts—adminUserNotestable with index on(target_address, created_at DESC)drizzle/migrations/0023_admin_user_notes.sql— migration SQLsrc/index.ts— mounts the router at/api/admin/userstests/adminUserNotes.test.ts— 30 focused testsSecurity
requireAdminmiddleware)AuthorizationheaderDELETEis scoped to bothidANDtarget_address— prevents cross-user note deletion by ID guessingPOSTandDELETEboth write toadmin_audit_logfor full traceabilityreqIdon every handlerTests
Lint: ✅ clean (
eslint src/**/*.tsexit 0)Closes #289