[PR #7343] refactor: split up routes from server.ts into individual files #12360

Closed
opened 2026-02-16 18:17:16 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7343

State: closed
Merged: No


I wanted to add 2 new endpoints to server.ts but started getting Type instantiation is excessively deep error. The server.ts file was huge, over 2k lines so decided to simplify it a bit by grouping endpoints together and splitting them in individual files to make it more manageable to add new endpoints.

There are still some endpoints that still live within server.ts but it's a bit harder to group them.

New structure:

server/
├── error.ts          (36 lines)
├── mdns.ts           (57 lines)
├── server.ts        (567 lines)
└── routes/
    ├── config.ts         (92 lines)
    ├── experimental.ts  (156 lines)
    ├── file.ts          (196 lines)
    ├── global.ts        (134 lines)
    ├── mcp.ts           (224 lines)
    ├── permission.ts     (67 lines)
    ├── project.ts        (81 lines)
    ├── provider.ts      (164 lines)
    ├── pty.ts           (168 lines)
    ├── question.ts       (97 lines)
    ├── session.ts       (930 lines)
    └── tui.ts           (375 lines)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7343 **State:** closed **Merged:** No --- I wanted to add 2 new endpoints to `server.ts` but started getting `Type instantiation is excessively deep` error. The `server.ts` file was huge, over 2k lines so decided to simplify it a bit by grouping endpoints together and splitting them in individual files to make it more manageable to add new endpoints. There are still some endpoints that still live within `server.ts` but it's a bit harder to group them. New structure: ``` server/ ├── error.ts (36 lines) ├── mdns.ts (57 lines) ├── server.ts (567 lines) └── routes/ ├── config.ts (92 lines) ├── experimental.ts (156 lines) ├── file.ts (196 lines) ├── global.ts (134 lines) ├── mcp.ts (224 lines) ├── permission.ts (67 lines) ├── project.ts (81 lines) ├── provider.ts (164 lines) ├── pty.ts (168 lines) ├── question.ts (97 lines) ├── session.ts (930 lines) └── tui.ts (375 lines) ```
yindo added the pull-request label 2026-02-16 18:17:16 -05:00
yindo closed this issue 2026-02-16 18:17:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12360