Refactor main.ts: extract routes and server logic into modules#84
Open
jancurn wants to merge 1 commit into
Open
Refactor main.ts: extract routes and server logic into modules#84jancurn wants to merge 1 commit into
jancurn wants to merge 1 commit into
Conversation
- main.ts (1360 lines) is now startup sequence + wiring (~325 lines): ttyd supervision and the /shell proxy live in shell-server.ts, bridge reverse proxies in bridge-proxy.ts, HTTP handlers in routes/*, idle shutdown in idle.ts - fix Express 5 wildcard params: String(req.params.path) comma-joined the segment array, corrupting every nested /fs path and DELETE /bridges/<path>; added wildcardPath() with regression tests - dedupe the /fs root vs wildcard handlers, the bridge URL rewrite (HTTP vs WebSocket copies), and language normalization (main.ts vs mcp.ts) - HEAD /fs no longer reads whole files for the MIME type; archiver errors no longer throw from an event handler (process-crash risk); unmatched WebSocket upgrades are now destroyed instead of left hanging - fix pre-existing lint failures, normalize formatting, update AGENTS.md project structure https://claude.ai/code/session_018RzDtc14x6oxeZtVARn4fD
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.
Split the monolithic main.ts into focused modules for better maintainability and testability. Routes are now organized under
routes/(fs, exec, mcp, bridges), shell/bridge/idle logic moved to dedicated modules, and the main file reduced to startup sequence and server wiring./fs/*) intoroutes/fs.tswith shared path-parameter helpers/exec) and MCP (/mcp) endpoints intoroutes/exec.tsandroutes/mcp.tsshell-server.tsbridge-proxy.ts; bridge config stays inbridges.tsidle.tsmodule with public APIoperations.tsfor reusehttps://claude.ai/code/session_018RzDtc14x6oxeZtVARn4fD