refactor(server): Phase 1 — extract /health, /cleanup, /maintenance, /themes, /purge into route modules (#3502)#3509
Conversation
…/themes, /purge handlers from server.ts Moves 17 inline apiRouter handlers (Phase 1 of #3502) into dedicated route modules, leaving server.ts as a thinner composition root: - healthRoutes.ts — GET /health (2 handlers) - cleanupRoutes.ts — POST /cleanup/{messages,nodes,channels} - maintenanceRoutes.ts — GET /maintenance/{status,size}, POST /maintenance/run - themeRoutes.ts — GET|POST|PUT|DELETE /themes and /themes/:slug - purgeRoutes.ts — POST /purge/{nodes,telemetry,messages,traceroutes} Each module imports only what it needs; all auth/permission middleware is applied per-route inside the module matching the original handler behaviour. Test files added for all five modules (35 new tests, all green). Refs: #3502 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: Phase 1 — Extract Server RoutesTasks:
Overall this is a clean, well-executed refactor. The extraction is behaviour-preserving, auth middleware is correctly applied, and the new test files follow the project's established patterns. A few issues worth addressing before merge: Bug: Duplicate
|
Summary
Phase 1 of #3502: moves 17 inline
apiRouterhandlers out of the 11,322-lineserver.tsmonolith into five dedicatedsrc/server/routes/modules, leavingserver.tsresponsible only for wiring them up. This is the low-coupling group from the issue's extraction recipe — each handler touches onlydatabaseService,databaseMaintenanceService, orresolveSourceManagerwith no shared inline helpers, making them safe proof-of-pattern extractions.Changes
healthRoutes.ts— GET/health(both registered handlers, behaviour-preserving)cleanupRoutes.ts— POST/cleanup/{messages,nodes,channels}(3 handlers, allrequireAdmin())maintenanceRoutes.ts— GET/maintenance/{status,size}, POST/maintenance/run(3 handlers,requirePermission('configuration', …))themeRoutes.ts— GET/POST/PUT/DELETE/themesand/themes/:slug(5 handlers, mixedoptionalAuth/requirePermission('themes', 'write'))purgeRoutes.ts— POST/purge/{nodes,telemetry,messages,traceroutes}(4 handlers, allrequireAdmin())server.ts— removed 386 lines of inline handlers; imports and mounts the five new modulesIssues Resolved
Relates to #3502
Documentation Updates
No documentation changes needed — this is a pure internal refactor with no behavior changes.
Testing
/api/health,/api/cleanup/*,/api/maintenance/*,/api/themes*,/api/purge/*endpoints respond identically to pre-PR behaviour🤖 Generated with Claude Code