Skip to content

refactor: extract shared route handlers and modularize plan server#214

Merged
backnotprop merged 2 commits intomainfrom
refactor/extract-shared-handlers
Mar 4, 2026
Merged

refactor: extract shared route handlers and modularize plan server#214
backnotprop merged 2 commits intomainfrom
refactor/extract-shared-handlers

Conversation

@backnotprop
Copy link
Owner

Summary

  • Extract duplicated /api/image, /api/upload, /api/agents handlers into packages/server/shared-handlers.ts
  • Extract /api/doc and Obsidian reference endpoints into packages/server/reference-handlers.ts
  • Consolidate 3 identical handleServerReady functions into one shared export
  • index.ts drops from 706 → 454 lines, review.ts 323 → 259, annotate.ts 258 → 207

Closes #210

Test plan

  • bun run build:hook succeeds
  • Compile binary and smoke test plan review
  • Verify image upload, Obsidian vault detection, and doc serving still work

🤖 Generated with Claude Code

Pull duplicated /api/image, /api/upload, /api/agents handlers and
handleServerReady into shared-handlers.ts. Move /api/doc and Obsidian
reference endpoints into reference-handlers.ts. Eliminates ~120 lines
of verbatim duplication across index.ts, review.ts, and annotate.ts.

Closes #210

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@backnotprop
Copy link
Owner Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Export OpencodeClient interface from shared-handlers.ts and import it
in index.ts and review.ts instead of redefining inline. Also corrects
the module doc comment about /api/agents usage scope.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@backnotprop backnotprop merged commit d9c2d46 into main Mar 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Extract shared route handlers and modularize plan server

1 participant