Spaces:
Runtime error
Runtime error
| import { PrismaClient } from '@prisma/client' | |
| const prisma = new PrismaClient() | |
| export async function POST(request: Request) { | |
| const { ids, page } = await request.json() | |
| const images = await prisma.image.findMany({ | |
| orderBy: { | |
| id: 'desc' | |
| }, | |
| where: { | |
| id: { | |
| in: ids, | |
| } | |
| }, | |
| take: 15, | |
| skip: page * 15 | |
| }) | |
| const total = await prisma.image.count() | |
| return Response.json( | |
| { | |
| images, | |
| pagination: { | |
| total, | |
| page: page + 1, | |
| total_pages: Math.ceil(total / 15) | |
| }, | |
| status: 200, | |
| ok: true | |
| } | |
| ) | |
| } |