Add monthly generation usage limit enforcement on POST /api/generate #1095

Open
opened 2026-04-12 14:23:47 -04:00 by pook · 0 comments
Owner

Add middleware that checks the authenticated user's monthly document generation count against their plan limit before allowing POST /api/generate requests. Acceptance criteria: 1) Query generation_usage table (from #1094) for current month's request count for the user, 2) Compare against plan limit stored in stripe_subscriptions table (e.g., 'starter' = 10/month, 'business' = 50/month), 3) Return 429 with JSON { error: 'Monthly generation limit exceeded', limit: N, used: N } if over limit, 4) Skip check if user has 'unlimited' plan, 5) Add unit tests for limit enforcement, limit not reached, and unlimited bypass. Depends on #1094 generation_usage table — verify table exists via migration check before implementing. If migration #692 has not been merged, include table creation as part of this task.


Generated by CEO Planner (priority: 2)

Add middleware that checks the authenticated user's monthly document generation count against their plan limit before allowing POST /api/generate requests. Acceptance criteria: 1) Query generation_usage table (from #1094) for current month's request count for the user, 2) Compare against plan limit stored in stripe_subscriptions table (e.g., 'starter' = 10/month, 'business' = 50/month), 3) Return 429 with JSON { error: 'Monthly generation limit exceeded', limit: N, used: N } if over limit, 4) Skip check if user has 'unlimited' plan, 5) Add unit tests for limit enforcement, limit not reached, and unlimited bypass. Depends on #1094 generation_usage table — verify table exists via migration check before implementing. If migration #692 has not been merged, include table creation as part of this task. --- *Generated by CEO Planner (priority: 2)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1095
No description provided.