Add Stripe billing integration + update free tier to 100 PDFs/mo
This commit is contained in:
parent
facb8df8f4
commit
c12c1176b0
7 changed files with 238 additions and 12 deletions
|
|
@ -8,7 +8,9 @@ interface UsageRecord {
|
|||
// In-memory usage tracking (replace with Redis/DB for production)
|
||||
const usage = new Map<string, UsageRecord>();
|
||||
|
||||
const FREE_TIER_LIMIT = 50; // 50 PDFs/month for free tier
|
||||
const FREE_TIER_LIMIT = 100; // 100 PDFs/month for free tier
|
||||
import { isProKey as isRuntimeProKey } from "../routes/billing.js";
|
||||
|
||||
const PRO_KEYS = new Set(
|
||||
(process.env.PRO_KEYS || "").split(",").map((k) => k.trim()).filter(Boolean)
|
||||
);
|
||||
|
|
@ -26,8 +28,8 @@ export function usageMiddleware(
|
|||
const key = req.headers.authorization?.slice(7) || "unknown";
|
||||
const monthKey = getMonthKey();
|
||||
|
||||
// Pro keys have no limit
|
||||
if (PRO_KEYS.has(key)) {
|
||||
// Pro keys have no limit (env-configured or runtime-provisioned via Stripe)
|
||||
if (PRO_KEYS.has(key) || isRuntimeProKey(key)) {
|
||||
trackUsage(key, monthKey);
|
||||
next();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue