refactor(db): migrate app pages and APIs from Prisma facade to Drizzle

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-08-01 14:15:12 +02:00
1 parent 53b350057d
commit 7c39aef5d9
40 files changed
+1124 -692

No files matched your search

+18 -10
View File
@@ -1,8 +1,9 @@
import { and, desc, eq, gt, or } from "drizzle-orm";
import { getTranslations } from "next-intl/server";
import { ContentCard } from "@/components/public/ui";
import { auth } from "@/lib/auth";
import { activeBanWhere, unixNow } from "@/lib/bans";
import { prisma } from "@/lib/prisma";
import { unixNow } from "@/lib/bans";
import { Ban, db } from "@/lib/db";
export const dynamic = "force-dynamic";
@@ -16,14 +17,21 @@ export default async function BannedPage() {
let hasBan = false;
if (session?.user?.id) {
try {
const ban = await prisma.ban.findFirst({
where: {
userId: Number(session.user.id),
...activeBanWhere(unixNow()),
},
orderBy: { timestamp: "desc" },
select: { banReason: true, banExpire: true },
});
const now = unixNow();
const [ban] = await db
.select({
banReason: Ban.banReason,
banExpire: Ban.banExpire,
})
.from(Ban)
.where(
and(
eq(Ban.userId, Number(session.user.id)),
or(eq(Ban.banExpire, 0), gt(Ban.banExpire, now)),
),
)
.orderBy(desc(Ban.timestamp))
.limit(1);
if (ban) {
hasBan = true;
reason = ban.banReason;