refactor(routes): extract traceroutes, route-segments, neighbor-info, ignored-nodes, announce (Phase 2 Batch 1)#3519
Conversation
… ignored-nodes, announce into dedicated modules (Phase 2 Batch 1) Part of #3502 — continues the server.ts decomposition. Extracts 11 inline apiRouter handlers (~270 lines) into 5 route modules with 36 tests covering happy paths, error paths, and source-scoping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review — Phase 2 Route Extraction
SummaryThis is a well-executed refactoring PR. The decomposition is clean, tests are solid, and the logic faithfully mirrors the original inline handlers. A few observations worth reviewing: Issues Found1. Missing
|
…ix hoisting error vi.mock factories are hoisted before top-level variable declarations; wrap the manager object in vi.hoisted() so it's initialized in time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review — Phase 2 Route Extraction
SummaryThis is a clean, faithful refactor. The 5 new route modules mirror the original server.ts inline handlers accurately and the 36 tests provide solid coverage. A few items are worth addressing before merge: Issues Found1.
|
… & status route groups (Refs #3502) (#3525) Continues the server.ts route-extraction effort (#3502) by moving 21 inline apiRouter handlers into five cohesive routes/ modules, matching the established Router-per-module pattern (PRs #3519, #3523). Extracted (behaviour-preserving, middleware order identical): - meshRequestRoutes.ts — /traceroute, /position/request, /nodeinfo/request, /neighborinfo/request, /telemetry/request (carries the neighbor-info rate-limit map) - telemetryRoutes.ts — /direct-neighbors and the /telemetry/* query endpoints (:nodeId, /rates, /smarthops, /linkquality, DELETE :nodeId/:type, /available/nodes) - connectionRoutes.ts — /connection (GET, /disconnect, /reconnect, /info, /configure) - deviceStatusRoutes.ts — /device/tx-status, /device/security-keys - statusRoutes.ts — /virtual-node/status, /automation/airtime-status Mounted connectionRoutes at /connection; the mixed-prefix routers mount at / to keep full paths verbatim. server.ts inline handler count drops from 130 to 109. All handler dependencies were already imported from utils/ modules, so no server.ts-local helpers needed exporting. Added a *.test.ts per new module (33 new tests). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Continues the server.ts decomposition started in #3509. Extracts 11 inline
apiRouterhandlers (~270 lines) from the monolithic server.ts into 5 dedicated route modules, each with a companion test file.Changes
src/server/routes/tracerouteRoutes.ts—GET /traceroutes/recent,GET /traceroutes/history/:fromNodeNum/:toNodeNumsrc/server/routes/routeSegmentRoutes.ts—GET /route-segments/longest-active,GET /route-segments/record-holder,DELETE /route-segments/record-holdersrc/server/routes/neighborInfoRoutes.ts—GET /neighbor-info,GET /neighbor-info/:nodeNum(usesgetEffectiveDbNodePositiondirectly, removing the local wrapper)src/server/routes/ignoredNodeRoutes.ts—GET /ignored-nodes,DELETE /ignored-nodes/:nodeIdsrc/server/routes/announceRoutes.ts—POST /announce/send,GET /announce/last,GET /announce/previewsrc/server/server.ts— mounts the 5 new modules viaapiRouter.use(...)and removes all corresponding inline handlersIssues Resolved
Relates to #3502
Documentation Updates
No documentation changes needed.
Testing
🤖 Generated with Claude Code