Add Stripe billing integration + update free tier to 100 PDFs/mo

This commit is contained in:
DocFast Bot 2026-02-14 13:53:19 +00:00
parent facb8df8f4
commit c12c1176b0
7 changed files with 238 additions and 12 deletions

View file

@ -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;