lomavuokraus/app/api/listings/check-slug/route.ts
Tero Halla-aho 0bb709d9c5
Some checks failed
CI / checks (push) Has been cancelled
chore: fix audit alerts and formatting
2026-02-04 12:43:03 +02:00

18 lines
533 B
TypeScript

import { NextResponse } from "next/server";
import { prisma } from "../../../../lib/prisma";
export async function GET(req: Request) {
const url = new URL(req.url);
const slug = url.searchParams.get("slug")?.trim().toLowerCase();
if (!slug) {
return NextResponse.json({ error: "Missing slug" }, { status: 400 });
}
const existing = await prisma.listingTranslation.findFirst({
where: { slug, listing: { removedAt: null } },
select: { id: true },
});
return NextResponse.json({ available: !existing });
}