From e2fd4df2212530efc6025aa9f3410272f9401f67 Mon Sep 17 00:00:00 2001 From: Citali Date: Sun, 28 Dec 2025 00:36:49 +0100 Subject: [PATCH] Fixes for build ready --- src/actions/tags/isDescendant.ts | 15 +++++++---- src/app/api/artworks/page/route.ts | 26 ++++++++++--------- src/app/api/image/[...key]/route.ts | 6 ++--- .../api/public/v1/commissions/create/route.ts | 0 .../api/public/v1/commissions/upload/route.ts | 0 5 files changed, 27 insertions(+), 20 deletions(-) delete mode 100644 src/app/api/public/v1/commissions/create/route.ts delete mode 100644 src/app/api/public/v1/commissions/upload/route.ts diff --git a/src/actions/tags/isDescendant.ts b/src/actions/tags/isDescendant.ts index 8c0ff43..34cb1bf 100644 --- a/src/actions/tags/isDescendant.ts +++ b/src/actions/tags/isDescendant.ts @@ -2,16 +2,21 @@ import { prisma } from "@/lib/prisma"; -export async function isDescendant(tagId: string, possibleAncestorId: string) { +export async function isDescendant(tagId: string, possibleAncestorId: string): Promise { // Walk upwards from possibleAncestorId; if we hit tagId, it's a cycle. let current: string | null = possibleAncestorId; + while (current) { if (current === tagId) return true; - const t = await prisma.artTag.findUnique({ - where: { id: current }, - select: { parentId: true }, - }); + + const t: { parentId: string | null } | null = + await prisma.artTag.findUnique({ + where: { id: current }, + select: { parentId: true }, + }); + current = t?.parentId ?? null; } + return false; } \ No newline at end of file diff --git a/src/app/api/artworks/page/route.ts b/src/app/api/artworks/page/route.ts index d449051..1742463 100644 --- a/src/app/api/artworks/page/route.ts +++ b/src/app/api/artworks/page/route.ts @@ -1,19 +1,21 @@ -// app/api/artworks/page/route.ts import { getArtworksPage } from "@/lib/queryArtworks"; -import { NextResponse } from "next/server"; -// import { getArtworksPage } from "@/lib/artworks/query"; +import { NextResponse, type NextRequest } from "next/server"; -export async function GET(req: Request) { - const { searchParams } = new URL(req.url); +export async function GET(req: NextRequest) { + const publishedParam = req.nextUrl.searchParams.get("published") ?? "all"; - const published = (searchParams.get("published") ?? "all") as - | "all" - | "published" - | "unpublished" - | "needsWork"; + const published = + publishedParam === "published" || + publishedParam === "unpublished" || + publishedParam === "needsWork" + ? publishedParam + : "all"; - const cursor = searchParams.get("cursor") ?? undefined; - const take = Number(searchParams.get("take") ?? "48"); + const cursor = req.nextUrl.searchParams.get("cursor") ?? undefined; + + const takeRaw = req.nextUrl.searchParams.get("take") ?? "48"; + const takeNum = Number(takeRaw); + const take = Number.isFinite(takeNum) && takeNum > 0 ? takeNum : 48; const data = await getArtworksPage({ published, cursor, take }); diff --git a/src/app/api/image/[...key]/route.ts b/src/app/api/image/[...key]/route.ts index eeb8f1e..f4d4d68 100644 --- a/src/app/api/image/[...key]/route.ts +++ b/src/app/api/image/[...key]/route.ts @@ -1,9 +1,9 @@ import { s3 } from "@/lib/s3"; import { GetObjectCommand } from "@aws-sdk/client-s3"; -import "dotenv/config"; +import type { NextRequest } from "next/server"; -export async function GET(req: Request, { params }: { params: { key: string[] } }) { - const { key } = await params; +export async function GET(_req: NextRequest, context: { params: Promise<{ key: string[] }> }) { + const { key } = await context.params; const s3Key = key.join("/"); try { diff --git a/src/app/api/public/v1/commissions/create/route.ts b/src/app/api/public/v1/commissions/create/route.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/api/public/v1/commissions/upload/route.ts b/src/app/api/public/v1/commissions/upload/route.ts deleted file mode 100644 index e69de29..0000000