added Callback and custon notification Toast, client notification event handler

This commit is contained in:
PxlLoewe
2025-05-22 00:43:03 -07:00
parent 0f04174516
commit 8a4b42f02b
38 changed files with 715 additions and 339 deletions

View File

@@ -0,0 +1,24 @@
import { prisma, User } from "@repo/db";
import { NextFunction } from "express";
interface AttachUserRequest extends Request {
user?: User | null;
}
interface AttachUserMiddleware {
(req: AttachUserRequest, res: Response, next: NextFunction): Promise<void>;
}
export const authMiddleware: AttachUserMiddleware = async (req, res, next) => {
const authHeader = (req.headers as any).authorization;
if (authHeader && authHeader.startsWith("User ")) {
const userId = authHeader.split(" ")[1];
const user = await prisma.user.findFirst({
where: {
id: userId,
},
});
req.user = user;
}
next();
};