Description
When request limits are exceeded the API should return a standards-compliant 429 with a Retry-After header rather than a generic error. Align the rateLimit middleware with the safe-error policy in src/errors/errorMessagePolicy.
Requirements and context
- Emit
429 Too Many Requests with Retry-After and X-RateLimit-* headers reflecting remaining budget.
- Use
src/errors/safeErrors.ts so no internal limiter state leaks to clients.
- Document headers and client backoff guidance in
docs/request-limits-implementation.md.
- Acceptance: integration test asserts header values and that the body matches the safe-error contract.
Suggested execution
- Fork the repo and create a branch:
git checkout -b enhancement/rate-limit-429-headers
- Implement changes:
src/rateLimit.ts
- Tests:
src/rateLimit.integration.test.ts
- Docs:
docs/request-limits-implementation.md
- Include TSDoc/NatSpec-style doc comments
- Validate security assumptions (input validation, auth, signature verification, secret redaction, idempotency)
Test and commit
- Run tests:
npm test (coverage: npm run test:ci)
- Cover edge cases
- Include test output and security notes in the PR
Example commit message
feat(rate-limit): return 429 with Retry-After headers
Guidelines
- Minimum 95% line coverage on new/changed code
- No secrets in repo; use
.env + deployment secrets only
- Clear documentation
- Timeframe: 96 hours from assignment
Description
When request limits are exceeded the API should return a standards-compliant 429 with a
Retry-Afterheader rather than a generic error. Align therateLimitmiddleware with the safe-error policy insrc/errors/errorMessagePolicy.Requirements and context
429 Too Many RequestswithRetry-AfterandX-RateLimit-*headers reflecting remaining budget.src/errors/safeErrors.tsso no internal limiter state leaks to clients.docs/request-limits-implementation.md.Suggested execution
git checkout -b enhancement/rate-limit-429-headerssrc/rateLimit.tssrc/rateLimit.integration.test.tsdocs/request-limits-implementation.mdTest and commit
npm test(coverage:npm run test:ci)Example commit message
Guidelines
.env+ deployment secrets only