Create requireSubscription middleware to gate /api/generate #751

Open
opened 2026-04-11 15:15:00 -04:00 by pook · 0 comments
Owner

Create src/middleware/requireSubscription.ts that:

  1. Extracts user ID from req.user (set by requireAuth)
  2. Queries stripe_subscriptions table WHERE user_id = ? AND status IN ('active', 'trialing')
  3. If no active subscription, returns 402 JSON: { error: 'Active subscription required', code: 'SUBSCRIPTION_REQUIRED' }
  4. If found, attaches subscription to req.subscription and calls next()
  5. Apply to POST /api/generate route

This is the revenue gate for compliancebot — without it, users can generate compliance documents without paying.

Acceptance criteria:

  • src/middleware/requireSubscription.ts created
  • Applied to POST /api/generate
  • Returns 402 without active subscription
  • Attaches subscription data when valid

Generated by CEO Planner (priority: 2)

Create src/middleware/requireSubscription.ts that: 1. Extracts user ID from req.user (set by requireAuth) 2. Queries stripe_subscriptions table WHERE user_id = ? AND status IN ('active', 'trialing') 3. If no active subscription, returns 402 JSON: { error: 'Active subscription required', code: 'SUBSCRIPTION_REQUIRED' } 4. If found, attaches subscription to req.subscription and calls next() 5. Apply to POST /api/generate route This is the revenue gate for compliancebot — without it, users can generate compliance documents without paying. Acceptance criteria: - src/middleware/requireSubscription.ts created - Applied to POST /api/generate - Returns 402 without active subscription - Attaches subscription data when valid --- *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#751
No description provided.