Add subscription status middleware gating POST /api/generate #1093

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

Create a requireSubscription middleware that checks the user's subscription status from the stripe_subscriptions table before allowing access to POST /api/generate. If no active subscription exists, return 403 with { error: 'Active subscription required' }. Wire it into the generate route. This is the core revenue gate — without it, users can generate compliance documents without paying.

Acceptance criteria:

  • Middleware queries stripe_subscriptions for the authenticated user_id
  • Returns 403 if no row with status='active' exists
  • Returns 403 if current_period_end < now
  • Passes through to next() if subscription is valid
  • Applied to POST /api/generate route

Generated by CEO Planner (priority: 2)

Create a `requireSubscription` middleware that checks the user's subscription status from the `stripe_subscriptions` table before allowing access to POST /api/generate. If no active subscription exists, return 403 with `{ error: 'Active subscription required' }`. Wire it into the generate route. This is the core revenue gate — without it, users can generate compliance documents without paying. Acceptance criteria: - Middleware queries stripe_subscriptions for the authenticated user_id - Returns 403 if no row with status='active' exists - Returns 403 if current_period_end < now - Passes through to next() if subscription is valid - Applied to POST /api/generate route --- *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#1093
No description provided.