diff --git a/dist/middleware/usage.js b/dist/middleware/usage.js index 180f5a7..7350a40 100644 --- a/dist/middleware/usage.js +++ b/dist/middleware/usage.js @@ -2,6 +2,7 @@ import { isProKey } from "../services/keys.js"; import logger from "../services/logger.js"; import pool from "../services/db.js"; const FREE_TIER_LIMIT = 100; +const PRO_TIER_LIMIT = 5000; // In-memory cache, periodically synced to PostgreSQL let usage = new Map(); function getMonthKey() { @@ -36,6 +37,15 @@ export function usageMiddleware(req, res, next) { const key = keyInfo?.key || "unknown"; const monthKey = getMonthKey(); if (isProKey(key)) { + const record = usage.get(key); + if (record && record.monthKey === monthKey && record.count >= PRO_TIER_LIMIT) { + res.status(429).json({ + error: "Pro tier limit reached (5,000/month). Contact support for higher limits.", + limit: PRO_TIER_LIMIT, + used: record.count, + }); + return; + } trackUsage(key, monthKey); next(); return; @@ -46,7 +56,7 @@ export function usageMiddleware(req, res, next) { error: "Free tier limit reached", limit: FREE_TIER_LIMIT, used: record.count, - upgrade: "Upgrade to Pro for unlimited conversions: https://docfast.dev/pricing", + upgrade: "Upgrade to Pro for 5,000 PDFs/month: https://docfast.dev/pricing", }); return; } diff --git a/dist/routes/billing.js b/dist/routes/billing.js index 647a512..e99f834 100644 --- a/dist/routes/billing.js +++ b/dist/routes/billing.js @@ -67,7 +67,7 @@ a { color: #4f9; }
Your API key:
Save this key! It won't be shown again.
-10,000 PDFs/month • All endpoints • Priority support
+5,000 PDFs/month • All endpoints • Priority support