opencode icon indicating copy to clipboard operation
opencode copied to clipboard

refactor: split up routes from `server.ts` into individual files

Open Leka74 opened this issue 1 week ago • 1 comments

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)

Leka74 avatar Jan 08 '26 14:01 Leka74