chore: add prettier formatting
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s

This commit is contained in:
zv
2026-06-14 20:26:56 +02:00
parent 8bbd9397a1
commit ee55521803
79 changed files with 2451 additions and 969 deletions

View File

@@ -49,28 +49,32 @@ export async function GET(request: Request) {
headers: { Accept: "application/json", "User-Agent": USER_AGENT },
});
if (!response.ok) return NextResponse.json({ error: "Reverse geocoding is unavailable." }, { status: 502 });
const data = await response.json() as RawReverseLocation;
const name = data.address?.city
?? data.address?.town
?? data.address?.village
?? data.address?.municipality
?? data.name
?? data.display_name?.split(",")[0]?.trim();
const data = (await response.json()) as RawReverseLocation;
const name =
data.address?.city ??
data.address?.town ??
data.address?.village ??
data.address?.municipality ??
data.name ??
data.display_name?.split(",")[0]?.trim();
if (!name) return NextResponse.json({ error: "Place name is unavailable." }, { status: 404 });
const countryCode = data.address?.country_code?.toUpperCase() ?? null;
return NextResponse.json({
name,
province: data.address?.state ?? null,
district: data.address?.county ?? null,
country: data.address?.country ?? null,
countryCode,
admin1: data.address?.state ?? null,
admin2: data.address?.county ?? null,
timezone: null,
region: getWeatherRegionForCountryCode(countryCode),
}, {
headers: { "Cache-Control": "public, s-maxage=86400, stale-while-revalidate=604800" },
});
return NextResponse.json(
{
name,
province: data.address?.state ?? null,
district: data.address?.county ?? null,
country: data.address?.country ?? null,
countryCode,
admin1: data.address?.state ?? null,
admin2: data.address?.county ?? null,
timezone: null,
region: getWeatherRegionForCountryCode(countryCode),
},
{
headers: { "Cache-Control": "public, s-maxage=86400, stale-while-revalidate=604800" },
},
);
} catch {
return NextResponse.json({ error: "Reverse geocoding is unavailable." }, { status: 502 });
}