Context
apps/api/src/rateLimit.ts returns Retry-After and meta.retryAfter on 429, and nothing before that. A client — including our own frontend — cannot tell it is approaching a limit until it is refused, and an API-key holder has no way to pace themselves.
Proposal
- Emit
X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset on successful responses for the bucket the request was charged to.
- Include the bucket name (
general / heavy / trace) so a caller can tell which budget the numbers describe.
- Document the headers in the OpenAPI document and in the README's rate-limit section.
Acceptance criteria
- A successful
/api/run carries the three headers for the heavy bucket.
- Values are consistent with the 429 the next request would receive.
- Covered in
app.test.ts via app.inject().
Context
apps/api/src/rateLimit.tsreturnsRetry-Afterandmeta.retryAfteron 429, and nothing before that. A client — including our own frontend — cannot tell it is approaching a limit until it is refused, and an API-key holder has no way to pace themselves.Proposal
X-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Reseton successful responses for the bucket the request was charged to.general/heavy/trace) so a caller can tell which budget the numbers describe.Acceptance criteria
/api/runcarries the three headers for theheavybucket.app.test.tsviaapp.inject().