refactor: extract route modules from server.ts monolith (ARC-2)#1703
Merged
OneStepAt4time merged 8 commits intodevelopfrom Apr 12, 2026
Merged
refactor: extract route modules from server.ts monolith (ARC-2)#1703OneStepAt4time merged 8 commits intodevelopfrom
OneStepAt4time merged 8 commits intodevelopfrom
Conversation
Extract 11 route module files from the 2,720-line server.ts monolith: - routes/context.ts: RouteContext interface, guards, helpers - routes/health.ts: health, prometheus, alerts, handshake, swarm - routes/auth.ts: auth verify, API keys CRUD, SSE token - routes/audit.ts: audit log, global metrics, diagnostics - routes/sessions.ts: session CRUD, listing, batch delete - routes/session-actions.ts: send, read, answer, interrupt, kill, etc. - routes/session-data.ts: transcript, summary, screenshot, tools, SSE - routes/events.ts: global SSE stream - routes/templates.ts: template CRUD - routes/pipelines.ts: batch create, pipeline CRUD - routes/index.ts: barrel export server.ts reduced from 2,720 to 1,130 lines (58% reduction). Guards and helpers parameterized instead of closing over module vars. Closes #1695
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…assignment' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…limit - health.ts: remove isRateLimited() manual Map-based tracker (memory leak, redundant with @fastify/rate-limit config.rateLimit per-route override) - sessions.ts: restore session create rate limit from 20 to 120 req/min to match server.ts RATE_LIMITS.sessionCreate value
All template routes now use config.rateLimit (60 req/min) via @fastify/rate-limit per-route override, replacing the conditional preHandler approach that CodeQL flagged as missing rate limiting.
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
Extracts 84+ inline route handlers from the 2,720-line server.ts monolith into 11 focused route module files under src/routes/.
Changes
New files (src/routes/)
Refactored files
Approach
Quality gate
px tsc --noEmit\ — passes
pm run build\ — passes
pm test\ — 159 passed, 2 skipped (2,814 tests)
Known gap
Per-route rate limit preHandlers are defined in server.ts but not yet wired to route modules (except templates.ts). This is intentionally deferred to ARC-5 (#1698 — Route middleware extraction).
Aegis version
Developed with: v0.5.0-alpha
Closes #1695