Add JSDoc documentation to all TypeScript files

This commit is contained in:
2026-05-14 13:53:12 +02:00
parent 09b5e7725d
commit 498958a27c
86 changed files with 728 additions and 16 deletions
+17
View File
@@ -1,3 +1,7 @@
// ── API Client ──
// Thin wrapper around the server-side API routes. Handles journey search,
// geocoding, bike/walk routing, calendar fetching, and WienerLinien monitoring.
import type {
GeocodeResult,
NearbyStop,
@@ -16,6 +20,11 @@ type SearchJourneyOptions = {
arriveBy?: boolean;
};
/**
* Fallback window (2 hours) to search backwards when an arrive-by query
* returns no journeys. HAFAS sometimes fails to find connections if the
* target time is too tight.
*/
const ARRIVE_BY_FALLBACK_WINDOW_MS = 2 * 60 * 60 * 1000;
function buildUrl(base: string, path: string, params: Record<string, string> = {}): string {
@@ -51,11 +60,19 @@ function buildTripSearchBody(
};
}
/**
* Normalize HAFAS coordinates. HAFAS may return coordinates in either
* decimal degrees or micro-degrees (1e6 factor). This detects and fixes it.
*/
function normalizeHafasCoordinate(value: number | undefined): number | undefined {
if (value == null) return undefined;
return Math.abs(value) > 1000 ? value / 1e6 : value;
}
/**
* Client for the TimeToLeave server API. Proxy requests to HAFAS, OSRM,
* Nominatim, and WienerLinien backends. Set `baseUrl` to your deployed app.
*/
export class ApiClient {
private readonly baseUrl: string;