Skip to content

feat(api): add send payload limits and per-tenant rate limiting - #91

Open
patoperpetua wants to merge 1 commit into
mainfrom
feat/38-rate-limits
Open

feat(api): add send payload limits and per-tenant rate limiting#91
patoperpetua wants to merge 1 commit into
mainfrom
feat/38-rate-limits

Conversation

@patoperpetua

Copy link
Copy Markdown
Contributor

Summary

  • Reject oversized POST /emails/send bodies and variables before template load with stable PAYLOAD_TOO_LARGE errors and configurable byte limits.
  • Add per-tenant sliding-window rate limiting keyed on {tenantId}:{environment}, returning 429 with Retry-After and RATE_LIMITED.
  • Generalise the existing in-memory SlidingWindowRateLimiter for send traffic; document the best-effort / scale-out limitation and new env defaults in .env.example.

Test plan

  • pnpm test in apps/api (send-limits unit tests, send handler size/rate-limit tests, security boundary updates)
  • Oversized body rejected before template store access
  • Oversized variable values rejected with limit named in message
  • Per-tenant rate limit isolation verified
  • 429 response includes Retry-After and RATE_LIMITED code

Closes #38

Made with Cursor

Protect POST /emails/send from oversized bodies and abusive traffic by
rejecting payloads before template load, throttling per authenticated
tenant, and documenting the in-memory limiter limitation.

Closes #38

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 7 minutes.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f9892986-07c7-4ad7-b1b9-9cc314751425

📥 Commits

Reviewing files that changed from the base of the PR and between a2dfa4e and db0fbf0.

📒 Files selected for processing (10)
  • .env.example
  • apps/api/src/config/app-configuration.ts
  • apps/api/src/contact-rate-limit.ts
  • apps/api/src/functions/send.security.spec.ts
  • apps/api/src/functions/send.spec.ts
  • apps/api/src/functions/send.ts
  • apps/api/src/send-limits.spec.ts
  • apps/api/src/send-limits.ts
  • packages/post-kit-types/src/index.spec.ts
  • packages/post-kit-types/src/send.ts

Comment @coderabbitai help to get the list of available commands.

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.

Add request size limits and per-tenant rate limiting to POST /emails/send

1 participant