feat: Add built dist files with EU compliance routes
Some checks failed
Deploy to Production / Deploy to Server (push) Failing after 20s
Some checks failed
Deploy to Production / Deploy to Server (push) Failing after 20s
- Include compiled TypeScript with new /impressum, /privacy, /terms routes - Temporary commit of dist files for Docker deployment
This commit is contained in:
parent
5ef8f34133
commit
1ef8f5743c
21 changed files with 2179 additions and 0 deletions
23
dist/middleware/auth.js
vendored
Normal file
23
dist/middleware/auth.js
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { isValidKey, getKeyInfo } from "../services/keys.js";
|
||||
export function authMiddleware(req, res, next) {
|
||||
const header = req.headers.authorization;
|
||||
const xApiKey = req.headers["x-api-key"];
|
||||
let key;
|
||||
if (header?.startsWith("Bearer ")) {
|
||||
key = header.slice(7);
|
||||
}
|
||||
else if (xApiKey) {
|
||||
key = xApiKey;
|
||||
}
|
||||
if (!key) {
|
||||
res.status(401).json({ error: "Missing API key. Use: Authorization: Bearer <key> or X-API-Key: <key>" });
|
||||
return;
|
||||
}
|
||||
if (!isValidKey(key)) {
|
||||
res.status(403).json({ error: "Invalid API key" });
|
||||
return;
|
||||
}
|
||||
// Attach key info to request for downstream use
|
||||
req.apiKeyInfo = getKeyInfo(key);
|
||||
next();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue