Spaces:
Runtime error
Runtime error
Download src/app/api/courts/route.ts from Ali-Developments/COURTRIX: direct link, hf CLI and curl.
- Browser
- Download file 695 Bytes
-
https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/src/app/api/courts/route.ts
- Command line
-
hf download hf://spaces/Ali-Developments/COURTRIX/src/app/api/courts/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/src/app/api/courts/route.ts
695 Bytes
| import { NextRequest, NextResponse } from "next/server"; | |
| import { requireApiUser } from "@/server/auth/session"; | |
| import { listCourtsByGovernorate } from "@/server/courts/service"; | |
| import { createRouteErrorResponse } from "@/server/errors"; | |
| import { courtsGovernorateQuerySchema } from "@/server/validation/case"; | |
| export async function GET(request: NextRequest) { | |
| try { | |
| await requireApiUser(); | |
| const query = courtsGovernorateQuerySchema.parse( | |
| Object.fromEntries(request.nextUrl.searchParams.entries()), | |
| ); | |
| return NextResponse.json({ | |
| items: listCourtsByGovernorate(query.governorate), | |
| }); | |
| } catch (error) { | |
| return createRouteErrorResponse(error); | |
| } | |
| } | |