add first files

This commit is contained in:
root
2026-04-30 14:59:57 -04:00
parent 2b97c1a04a
commit 695a7f7cc7
92 changed files with 4873 additions and 0 deletions
@@ -0,0 +1,24 @@
import { Request, Response, NextFunction } from 'express'
const BLOCKED_STATUSES = ['SUSPENDED', 'PENDING']
export function requireSubscription(req: Request, res: Response, next: NextFunction) {
const company = req.company
if (!company) {
return res.status(401).json({ error: 'unauthenticated', message: 'No company context', statusCode: 401 })
}
if (BLOCKED_STATUSES.includes(company.status)) {
return res.status(402).json({
error: 'subscription_' + company.status.toLowerCase(),
message:
company.status === 'SUSPENDED'
? 'Your account has been suspended. Please contact support or renew your subscription.'
: 'Your account is pending activation. Please complete your subscription setup.',
statusCode: 402,
billingUrl: `${process.env.NEXT_PUBLIC_DASHBOARD_URL}/billing`,
})
}
next()
}