Prevents hanging connections when the upstream response stream errors
after headers have already been sent to the client.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements api-gateway.cjs — a standalone HTTP server that authenticates
API keys, enforces rate/token limits, records usage events, and proxies
requests to an internal upstream (pre or post route). Adds integration
tests covering auth failures, rate limiting, non-streaming, SSE streaming,
and upstream connection errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>