27 lines
698 B
TypeScript
27 lines
698 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export async function GET(
|
|
req: NextRequest,
|
|
{ params }: { params: Promise<{ subdomain: string }> }
|
|
) {
|
|
const { subdomain } = await params;
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { subdomain },
|
|
include: { images: { orderBy: { order: "asc" } } },
|
|
});
|
|
|
|
if (!user || !user.published) {
|
|
return NextResponse.json({ error: "Monument not found" }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({
|
|
id: user.id,
|
|
title: user.title,
|
|
description: user.description,
|
|
subdomain: user.subdomain,
|
|
templateId: user.templateId,
|
|
images: user.images,
|
|
});
|
|
} |