mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
wi[p
This commit is contained in:
parent
9588799587
commit
c33a621cbb
10 changed files with 575 additions and 13 deletions
21
src/pages/api/anim/find.ts
Normal file
21
src/pages/api/anim/find.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import type { APIRoute } from 'astro'
|
||||
import prismaClient from 'utils/prisma-client'
|
||||
|
||||
export const GET: APIRoute = async (context) => {
|
||||
const { url } = context
|
||||
const titleParam = url.searchParams.get('q')
|
||||
|
||||
const anims = await prismaClient.animation.findMany({
|
||||
where: titleParam ? { title: { contains: titleParam } } : undefined,
|
||||
select: { id: true, title: true },
|
||||
take: 10,
|
||||
orderBy: { createdAt: 'desc' }
|
||||
})
|
||||
|
||||
return new Response(JSON.stringify(anims), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue