feat: sessão #3 — lib (db/auth/email/validations), API routes, NextAuth v5, middleware, páginas account/shelters/shelter-dashboard, Prisma v7 fix
This commit is contained in:
23
app/api/animals/[id]/route.ts
Normal file
23
app/api/animals/[id]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user