Skip to content

refactor: extract route middleware helpers (ARC-5)#1705

Merged
OneStepAt4time merged 1 commit intodevelopfrom
refactor/1698-route-middleware
Apr 12, 2026
Merged

refactor: extract route middleware helpers (ARC-5)#1705
OneStepAt4time merged 1 commit intodevelopfrom
refactor/1698-route-middleware

Conversation

@OneStepAt4time
Copy link
Copy Markdown
Owner

Summary

Extracts three route middleware helpers into \src/routes/context.ts\ and applies them across route modules, eliminating boilerplate from dual-registration and inline ownership checks.

Changes

  1. *
    egisterWithLegacy()*
    β€” registers both /v1/...\ and legacy /...\ paths in one call
  2. *\withOwnership()* β€” wraps ownership check, passes resolved \SessionInfo\ to handler
  3. *\withValidation()* β€” wraps Zod body parsing (available for future use)
  4. Dead code cleanup β€” removes unused \RATE_LIMITS, \createRateLimitPreHandler(), and 8 unused preHandler variables from \server.ts\

Impact

  • 20 dual-registration sites consolidated (session-actions, session-data, sessions, health)
  • 15 inline
    equireOwnership\ checks replaced with \withOwnership\ wrapper
  • Net reduction: 49 lines of boilerplate
  • 6 files changed, 146 insertions, 195 deletions

Quality Gate


  • px tsc --noEmit\ βœ…

  • pm run build\ βœ…

  • pm test\ βœ… (159 files, 2814 tests pass)

Aegis version

Developed with: v0.3.2-alpha

Closes #1698

- Add registerWithLegacy() to register both /v1/ and legacy paths in one call
- Add withOwnership() wrapper to eliminate inline requireOwnership checks
- Add withValidation() wrapper for Zod body parsing (available for future use)
- Apply to 20 dual-registration sites across session-actions, session-data,
  sessions, and health route modules
- Convert 15 inline ownership checks to withOwnership wrapper
- Remove dead rate limit code from server.ts (RATE_LIMITS, createRateLimitPreHandler,
  8 unused preHandler variables)
- Net reduction: 49 lines of boilerplate

Closes #1698
@OneStepAt4time OneStepAt4time merged commit 9528e21 into develop Apr 12, 2026
11 checks passed
@OneStepAt4time OneStepAt4time deleted the refactor/1698-route-middleware branch April 12, 2026 14:37
@OneStepAt4time OneStepAt4time self-assigned this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant