fix: self-service signup, unified key store, persistent data volume

- Added /v1/signup/free endpoint for instant API key provisioning
- Built unified key store (services/keys.ts) with file-based persistence
- Refactored auth middleware to use key store (no more hardcoded env keys)
- Refactored usage middleware to check key tier from store
- Updated billing to use key store for Pro key provisioning
- Landing page: replaced mailto: link with signup modal
- Landing page: Pro checkout button now properly calls /v1/billing/checkout
- Added Docker volume for persistent key storage
- Success page now renders HTML instead of raw JSON
- Tested: signup → key → PDF generation works end-to-end
This commit is contained in:
DocFast Bot 2026-02-14 14:20:05 +00:00
parent c12c1176b0
commit 467a97ae1c
9 changed files with 361 additions and 126 deletions

View file

@ -1,19 +1,13 @@
import { Request, Response, NextFunction } from "express";
import { isProKey } from "../services/keys.js";
interface UsageRecord {
count: number;
monthKey: string;
}
// In-memory usage tracking (replace with Redis/DB for production)
const usage = new Map<string, UsageRecord>();
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)
);
const FREE_TIER_LIMIT = 100;
function getMonthKey(): string {
const d = new Date();
@ -28,8 +22,8 @@ export function usageMiddleware(
const key = req.headers.authorization?.slice(7) || "unknown";
const monthKey = getMonthKey();
// Pro keys have no limit (env-configured or runtime-provisioned via Stripe)
if (PRO_KEYS.has(key) || isRuntimeProKey(key)) {
// Pro keys have no limit
if (isProKey(key)) {
trackUsage(key, monthKey);
next();
return;