Spaces:
Runtime error
Runtime error
Download src/server/courts/service.ts from Ali-Developments/COURTRIX: direct link, hf CLI and curl.
- Browser
- Download file 927 Bytes
-
https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/src/server/courts/service.ts
- Command line
-
hf download hf://spaces/Ali-Developments/COURTRIX/src/server/courts/service.ts
-
curl -L -o service.ts https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/src/server/courts/service.ts
927 Bytes
| import { AppError } from "@/server/errors"; | |
| import { courtDirectory } from "@/server/courts/data"; | |
| function sortArabic(values: string[]) { | |
| return values.sort((first, second) => first.localeCompare(second, "ar")); | |
| } | |
| export function listGovernorates() { | |
| return sortArabic([...new Set(courtDirectory.map((entry) => entry.governorate))]); | |
| } | |
| export function listCourtsByGovernorate(governorate: string) { | |
| return courtDirectory | |
| .filter((entry) => entry.governorate === governorate) | |
| .sort((first, second) => first.courtName.localeCompare(second.courtName, "ar")); | |
| } | |
| export function getCourtByGovernorateAndName( | |
| governorate: string, | |
| courtName: string, | |
| ) { | |
| const court = courtDirectory.find( | |
| (entry) => | |
| entry.governorate === governorate && entry.courtName === courtName, | |
| ); | |
| if (!court) { | |
| throw new AppError("المحكمة المختارة غير موجودة.", 400); | |
| } | |
| return court; | |
| } | |