Initial MVP: DocFast PDF API

- HTML/Markdown to PDF conversion via Puppeteer
- Invoice and receipt templates
- API key auth + rate limiting
- Dockerfile for deployment
This commit is contained in:
DocFast Bot 2026-02-14 12:38:06 +00:00
commit feee0317ae
14 changed files with 4529 additions and 0 deletions

23
src/middleware/auth.ts Normal file
View file

@ -0,0 +1,23 @@
import { Request, Response, NextFunction } from "express";
const API_KEYS = new Set(
(process.env.API_KEYS || "test-key-123").split(",").map((k) => k.trim())
);
export function authMiddleware(
req: Request,
res: Response,
next: NextFunction
): void {
const header = req.headers.authorization;
if (!header?.startsWith("Bearer ")) {
res.status(401).json({ error: "Missing API key. Use: Authorization: Bearer <key>" });
return;
}
const key = header.slice(7);
if (!API_KEYS.has(key)) {
res.status(403).json({ error: "Invalid API key" });
return;
}
next();
}