Enforce Pro plan limit of 5,000 PDFs/month
Some checks failed
Deploy to Production / Deploy to Server (push) Has been cancelled

This commit is contained in:
DocFast Bot 2026-02-16 18:41:57 +00:00
parent b98e8bc253
commit c903860917
5 changed files with 31 additions and 5 deletions

View file

@ -17,7 +17,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"DocFast","url":"https://docfast.dev","applicationCategory":"DeveloperApplication","operatingSystem":"Web","description":"Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.","offers":[{"@type":"Offer","price":"0","priceCurrency":"EUR","name":"Free","description":"100 PDFs/month"},{"@type":"Offer","price":"9","priceCurrency":"EUR","name":"Pro","description":"Unlimited PDF conversions","billingIncrement":"P1M"}]}
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"DocFast","url":"https://docfast.dev","applicationCategory":"DeveloperApplication","operatingSystem":"Web","description":"Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.","offers":[{"@type":"Offer","price":"0","priceCurrency":"EUR","name":"Free","description":"100 PDFs/month"},{"@type":"Offer","price":"9","priceCurrency":"EUR","name":"Pro","description":"5,000 PDFs / month","billingIncrement":"P1M"}]}
</script>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
<style>
@ -404,7 +404,7 @@ html, body {
<div class="price-amount">€9<span> /mo</span></div>
<div class="price-desc">For production apps and businesses</div>
<ul class="price-features">
<li>Unlimited PDF conversions</li>
<li>5,000 PDFs / month</li>
<li>All conversion endpoints</li>
<li>All templates included</li>
<li>Priority support</li>

View file

@ -3,6 +3,7 @@ import logger from "../services/logger.js";
import pool from "../services/db.js";
const FREE_TIER_LIMIT = 100;
const PRO_TIER_LIMIT = 2500;
// In-memory cache, periodically synced to PostgreSQL
let usage = new Map<string, { count: number; monthKey: string }>();
@ -44,6 +45,15 @@ export function usageMiddleware(req: any, res: any, next: any): void {
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 (2,500/month). Contact support for higher limits.",
limit: PRO_TIER_LIMIT,
used: record.count,
});
return;
}
trackUsage(key, monthKey);
next();
return;
@ -55,7 +65,7 @@ export function usageMiddleware(req: any, res: any, next: any): void {
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 2,500 PDFs/month: https://docfast.dev/pricing",
});
return;
}

View file

@ -76,7 +76,7 @@ a { color: #4f9; }
<p>Your API key:</p>
<div class="key" style="position:relative">${escapeHtml(keyInfo.key)}<button onclick="navigator.clipboard.writeText('${escapeHtml(keyInfo.key)}');this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)" style="position:absolute;top:8px;right:8px;background:#4f9;color:#0a0a0a;border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;font-family:system-ui">Copy</button></div>
<p><strong>Save this key!</strong> It won't be shown again.</p>
<p>10,000 PDFs/month All endpoints Priority support</p>
<p>5,000 PDFs/month All endpoints Priority support</p>
<p><a href="/docs">View API docs </a></p>
</div></body></html>`);
} catch (err: any) {
@ -184,7 +184,7 @@ async function getOrCreateProPrice(): Promise<string> {
} else {
const product = await getStripe().products.create({
name: "DocFast Pro",
description: "Unlimited PDF conversions via API. HTML, Markdown, and URL to PDF.",
description: "5,000 PDFs / month via API. HTML, Markdown, and URL to PDF.",
});
productId = product.id;
}

View file

@ -0,0 +1,6 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">

View file

@ -0,0 +1,10 @@
<nav aria-label="Main navigation">
<div class="container">
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
<div class="nav-links">
<a href="/#features">Features</a>
<a href="/#pricing">Pricing</a>
<a href="/docs">Docs</a>
</div>
</div>
</nav>