(request: Request, { params }: { params: Promise<{ userId: string }> })
| 5 | import { getUserTeams } from '@/queries/prisma'; |
| 6 | |
| 7 | export async function GET(request: Request, { params }: { params: Promise<{ userId: string }> }) { |
| 8 | const schema = z.object({ |
| 9 | ...pagingParams, |
| 10 | ...sortingParams, |
| 11 | }); |
| 12 | |
| 13 | const { auth, query, error } = await parseRequest(request, schema); |
| 14 | |
| 15 | if (error) { |
| 16 | return error(); |
| 17 | } |
| 18 | |
| 19 | const { userId } = await params; |
| 20 | |
| 21 | if (auth.user.id !== userId && !auth.user.isAdmin) { |
| 22 | return unauthorized(); |
| 23 | } |
| 24 | |
| 25 | const teams = await getUserTeams(userId, query); |
| 26 | |
| 27 | return json(teams); |
| 28 | } |
nothing calls this directly
no test coverage detected