backup page done

This commit is contained in:
2025-08-25 23:59:16 +05:30
parent 37a83fecd2
commit d859362c40
16 changed files with 619 additions and 40 deletions

View File

@@ -0,0 +1,34 @@
import { Router, Request, Response } from "express";
import { prisma } from "@repo/db/client";
const router = Router();
router.get("/", async (req, res) => {
const userId = (req as any).user?.id;
const notifications = await prisma.notification.findMany({
where: { userId },
orderBy: { createdAt: "desc" },
take: 20,
});
res.json(notifications);
});
router.post("/:id/read", async (req, res) => {
const userId = (req as any).user?.id;
await prisma.notification.updateMany({
where: { id: Number(req.params.id), userId },
data: { read: true },
});
res.json({ success: true });
});
router.post("/read-all", async (req, res) => {
const userId = (req as any).user?.id;
await prisma.notification.updateMany({
where: { userId },
data: { read: true },
});
res.json({ success: true });
});
export default router;