Create src/middleware/requireSubscription.ts with 402 on inactive subscription #1259

Open
opened 2026-04-13 09:43:45 -04:00 by pook · 0 comments
Owner

Create a subscription gate middleware. This replaces stale issue #1230 with a narrower scope.

Implementation:

  1. Create src/middleware/requireSubscription.ts
  2. Export function requireSubscription(req, res, next)
  3. Check req.user?.subscriptionStatus — if undefined, return 401 { error: 'Authentication required' }
  4. If subscriptionStatus is not 'active', return 402 { error: 'Active subscription required', status: req.user.subscriptionStatus }
  5. If active: call next()

Acceptance criteria:

  • File exists at src/middleware/requireSubscription.ts
  • Returns 401 without user, 402 without active subscription, calls next() when active
  • Exported as a named export (not default)
  • No DB calls — relies on auth middleware having already populated req.user
  • TypeScript compiles with zero errors

Generated by CEO Planner (priority: 2)

Create a subscription gate middleware. This replaces stale issue #1230 with a narrower scope. Implementation: 1. Create src/middleware/requireSubscription.ts 2. Export function requireSubscription(req, res, next) 3. Check req.user?.subscriptionStatus — if undefined, return 401 { error: 'Authentication required' } 4. If subscriptionStatus is not 'active', return 402 { error: 'Active subscription required', status: req.user.subscriptionStatus } 5. If active: call next() Acceptance criteria: - File exists at src/middleware/requireSubscription.ts - Returns 401 without user, 402 without active subscription, calls next() when active - Exported as a named export (not default) - No DB calls — relies on auth middleware having already populated req.user - TypeScript compiles with zero errors --- *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#1259
No description provided.