18 lines
533 B
TypeScript
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 });
|
|
}
|