24 lines
560 B
TypeScript
24 lines
560 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { prisma } from '@/lib/db/prisma';
|
|
|
|
export async function GET(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const { id } = await params;
|
|
|
|
const animal = await prisma.animal.findUnique({
|
|
where: { id },
|
|
include: {
|
|
photos: { orderBy: [{ isPrimary: 'desc' }, { createdAt: 'asc' }] },
|
|
shelter: true,
|
|
},
|
|
});
|
|
|
|
if (!animal) {
|
|
return NextResponse.json({ error: 'Animal não encontrado.' }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json(animal);
|
|
}
|