File uploading

This commit is contained in:
2026-10-29 17:59:34 -03:00
parent ec9bdb8e8e
commit b65d8efad8
18 changed files with 686 additions and 51 deletions
+14
View File
@@ -0,0 +1,14 @@
import { db } from "./db.ts";
// Reads the user's code from an "Authorization: Bearer <code>" header
export async function authenticate(req: Request) {
const code = req.headers.get("Authorization")?.match(/^Bearer (\S+)$/)?.[1];
if (!code) {
return undefined;
}
return await db.get_entry_by_index("users", "code", code);
}
export function unauthorized() {
return Response.json({ error: "Invalid code" }, { status: 401 });
}