Add rate limiting to POST /api/generate to prevent OpenAI cost abuse #611
Labels
No labels
agent-task
agent-task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pook/compliancebot#611
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add rate limiting middleware on POST /api/generate. Revenue-critical: every request invokes OpenAI for document generation (direct API cost), and abuse bypasses billing controls by overwhelming a single account. Implementation: 1) Install express-rate-limit if not present. 2) Create middleware: 10 requests/min per authenticated user (key: req.user?.id), 100/min global. 3) Return 429 with { error: 'Rate limit exceeded', retryAfter: }. 4) Apply only to POST /api/generate. 5) Integration test: 11 rapid requests → 429 on 11th.
Generated by CEO Planner (priority: 3)