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"; 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. // Walk upwards from possibleAncestorId; if we hit tagId, it's a cycle.
let current: string | null = possibleAncestorId; let current: string | null = possibleAncestorId;
while (current) { while (current) {
if (current === tagId) return true; if (current === tagId) return true;
const t = await prisma.artTag.findUnique({
const t: { parentId: string | null } | null =
await prisma.artTag.findUnique({
where: { id: current }, where: { id: current },
select: { parentId: true }, select: { parentId: true },
}); });
current = t?.parentId ?? null; current = t?.parentId ?? null;
} }
return false; return false;
} }

View File

@ -1,19 +1,21 @@
// app/api/artworks/page/route.ts
import { getArtworksPage } from "@/lib/queryArtworks"; import { getArtworksPage } from "@/lib/queryArtworks";
import { NextResponse } from "next/server"; import { NextResponse, type NextRequest } from "next/server";
// import { getArtworksPage } from "@/lib/artworks/query";
export async function GET(req: Request) { export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url); const publishedParam = req.nextUrl.searchParams.get("published") ?? "all";
const published = (searchParams.get("published") ?? "all") as const published =
| "all" publishedParam === "published" ||
| "published" publishedParam === "unpublished" ||
| "unpublished" publishedParam === "needsWork"
| "needsWork"; ? publishedParam
: "all";
const cursor = searchParams.get("cursor") ?? undefined; const cursor = req.nextUrl.searchParams.get("cursor") ?? undefined;
const take = Number(searchParams.get("take") ?? "48");
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 }); const data = await getArtworksPage({ published, cursor, take });

View File

@ -1,9 +1,9 @@
import { s3 } from "@/lib/s3"; import { s3 } from "@/lib/s3";
import { GetObjectCommand } from "@aws-sdk/client-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[] } }) { export async function GET(_req: NextRequest, context: { params: Promise<{ key: string[] }> }) {
const { key } = await params; const { key } = await context.params;
const s3Key = key.join("/"); const s3Key = key.join("/");
try { try {