Fixes for build ready

This commit is contained in:
2025-12-28 00:36:49 +01:00
parent d366dd4e18
commit e2fd4df221
5 changed files with 27 additions and 20 deletions

View File

@ -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<boolean> {
// 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;
}

View File

@ -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 });

View File

@ -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 {