(request: Request, { params }: { params: Promise<{ pixelId: string }> })
| 9 | import { createShare, getSharesByEntityId } from '@/queries/prisma'; |
| 10 | |
| 11 | export async function GET(request: Request, { params }: { params: Promise<{ pixelId: string }> }) { |
| 12 | const schema = z.object({ |
| 13 | ...filterParams, |
| 14 | ...pagingParams, |
| 15 | }); |
| 16 | |
| 17 | const { auth, query, error } = await parseRequest(request, schema); |
| 18 | |
| 19 | if (error) { |
| 20 | return error(); |
| 21 | } |
| 22 | |
| 23 | const { pixelId } = await params; |
| 24 | const { page, pageSize, search } = query; |
| 25 | |
| 26 | if (!(await canViewPixel(auth, pixelId))) { |
| 27 | return unauthorized(); |
| 28 | } |
| 29 | |
| 30 | const data = await getSharesByEntityId(pixelId, { |
| 31 | page, |
| 32 | pageSize, |
| 33 | search, |
| 34 | }); |
| 35 | |
| 36 | return json(data); |
| 37 | } |
| 38 | |
| 39 | export async function POST(request: Request, { params }: { params: Promise<{ pixelId: string }> }) { |
| 40 | const schema = z.object({ |
nothing calls this directly
no test coverage detected