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:
parent
c12c1176b0
commit
467a97ae1c
9 changed files with 361 additions and 126 deletions
33
src/routes/signup.ts
Normal file
33
src/routes/signup.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { Router, Request, Response } from "express";
|
||||
import { createFreeKey } from "../services/keys.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
// Self-service free API key signup
|
||||
router.post("/free", (req: Request, res: Response) => {
|
||||
const { email } = req.body;
|
||||
|
||||
if (!email || typeof email !== "string") {
|
||||
res.status(400).json({ error: "Email is required" });
|
||||
return;
|
||||
}
|
||||
|
||||
// Basic email validation
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
res.status(400).json({ error: "Invalid email address" });
|
||||
return;
|
||||
}
|
||||
|
||||
const keyInfo = createFreeKey(email.trim().toLowerCase());
|
||||
|
||||
res.json({
|
||||
message: "Welcome to DocFast! 🚀",
|
||||
apiKey: keyInfo.key,
|
||||
tier: "free",
|
||||
limit: "100 PDFs/month",
|
||||
docs: "https://docfast.dev/#endpoints",
|
||||
note: "Save this API key — it won't be shown again.",
|
||||
});
|
||||
});
|
||||
|
||||
export { router as signupRouter };
|
||||
Loading…
Add table
Add a link
Reference in a new issue