Skip to content

feat(proxy): write pass-through — POST messages to Discord#10

Merged
bakeb7j0 merged 1 commit into
mainfrom
feature/4-write-passthrough
Apr 2, 2026
Merged

feat(proxy): write pass-through — POST messages to Discord#10
bakeb7j0 merged 1 commit into
mainfrom
feature/4-write-passthrough

Conversation

@bakeb7j0
Copy link
Copy Markdown
Contributor

@bakeb7j0 bakeb7j0 commented Apr 2, 2026

Summary

Adds write pass-through so agents can send Discord messages through scream-hole. POST requests are forwarded to Discord with the response returned verbatim, and successfully sent messages are injected into the cache immediately.

Changes

  • discord.tssendMessage method on DiscordClient, refactored discordFetch for POST support, safe JSON parse for non-JSON errors, 429 body consumed + logged
  • index.ts — POST route with raw body forwarding (JSON + multipart), cache injection with snowflake validation + error boundary, 503 when no client
  • tests/proxy.test.ts (new) — 5 tests for sendMessage via injectable fetch
  • tests/index.test.ts — 5 new POST route tests, existing tests updated to await async handler
  • tests/poller.test.ts — sendMessage stubs on mock clients

Test Plan

  • bun test — 54 pass, 0 fail, 148 assertions
  • bunx tsc --noEmit — clean
  • Code reviewer: 4 findings, all fixed (non-JSON response handling, snowflake validation, 429 body leak, rate limit logging)

Closes #4

🤖 Generated with Claude Code

Adds POST /api/v10/channels/{channelId}/messages that forwards the
request body and Content-Type to Discord, returns the response verbatim,
and injects successfully sent messages into the cache immediately.

- Multipart/form-data bodies forwarded transparently (raw bytes)
- Safe JSON parse on Discord responses (handles non-JSON 502/503)
- Cache injection validates snowflake format before writing
- 429 rate limit: body consumed, warning logged, connection freed
- 503 returned when no DiscordClient configured (read-only mode)

54 tests across 6 files, 148 assertions.

Closes #4

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bakeb7j0 bakeb7j0 merged commit 435d874 into main Apr 2, 2026
4 checks passed
@bakeb7j0 bakeb7j0 deleted the feature/4-write-passthrough branch April 2, 2026 22:07
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.

Write pass-through — proxy POST messages to Discord

1 participant