DocFast MVP: HTML/Markdown to PDF API with invoice templates
This commit is contained in:
parent
789b3bfeeb
commit
77ec1c5524
24 changed files with 5010 additions and 22 deletions
17
projects/business/src/pdf-api/dist/middleware/auth.js
vendored
Normal file
17
projects/business/src/pdf-api/dist/middleware/auth.js
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.authMiddleware = authMiddleware;
|
||||
const API_KEYS = new Set((process.env.API_KEYS || "test-key-123").split(",").map((k) => k.trim()));
|
||||
function authMiddleware(req, res, next) {
|
||||
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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue