scaler updates

This commit is contained in:
2026-02-20 11:05:03 -06:00
parent 2d1f613d39
commit 5469a0dc5c
7 changed files with 152 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
import { fromNodeHeaders } from "better-auth/node";
import type { NextFunction, Request, Response } from "express";
import { auth } from "../utils/auth.utils.js";
export const requireAuth = async (
req: Request,
res: Response,
next: NextFunction,
) => {
// TODO: add the real auth stuff in later.
try {
const session = await auth.api.getSession({
headers: fromNodeHeaders(req.headers),
});
if (!session) {
//return res.status(401).json({ error: "Unauthorized" });
console.info("not auth of course");
}
// attach session to request for later use
(req as any).session = session;
console.info(
"Just passing the middleware and reminder that we need to add the real stuff in.",
);
next();
} catch {
return res.status(401).json({ error: "Unauthorized" });
}
};