Update lint and typecheck scripts for all packages
Add linting to the mobile app and include core and api-client packages in the root lint, typecheck, and test scripts. Ignore node_modules in all subdirectories and clean up stale test results. Update lint and typecheck scripts for all packages Add ESLint configuration for mobile app and shared packages. Rename mobile jest config to .cjs and enable ESM. Include packages/core and packages/api-client in monorepo lint, typecheck, and test scripts.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type {
|
||||
GeocodeResult,
|
||||
NearbyStop,
|
||||
BikeRoute,
|
||||
WalkRoute,
|
||||
CalendarEvent,
|
||||
@@ -113,7 +114,7 @@ export class ApiClient {
|
||||
toStationExtId: string,
|
||||
date: Date,
|
||||
): Promise<Journey[]> {
|
||||
// Use the proper HAFAS protocol body as expected by the endpoint
|
||||
// Build a proper HAFAS TripSearch body — the /api/hafas endpoint expects svcReqL.
|
||||
const { date: hafasDate, time: hafasTime } = hafasDateTime(date);
|
||||
|
||||
const body = {
|
||||
@@ -134,24 +135,47 @@ export class ApiClient {
|
||||
const res = await fetch(`${this.baseUrl}/api/hafas`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body)
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!res.ok) throw new Error(`Journey search failed: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async searchStation(query: string): Promise<Station[]> {
|
||||
// WienerLinien client expects lat/lng parameters, not query string
|
||||
// For now, use geocode to find Vienna coordinates as a fallback
|
||||
const fallbackCoords = { lat: 48.2082, lng: 16.3738 };
|
||||
const url = buildUrl(this.baseUrl, "/api/wienerlinien/stops", {
|
||||
lat: String(fallbackCoords.lat),
|
||||
lng: String(fallbackCoords.lng)
|
||||
async reverseGeocode(lat: number, lng: number): Promise<GeocodeResult | null> {
|
||||
const url = buildUrl(this.baseUrl, "/api/geocode/reverse", {
|
||||
lat: String(lat),
|
||||
lng: String(lng),
|
||||
});
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`Station search failed: ${res.status}`);
|
||||
const result = await res.json();
|
||||
return result.stops || [];
|
||||
if (!res.ok) return null;
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async findNearbyStops(lat: number, lng: number, radius: number = 1000): Promise<NearbyStop[]> {
|
||||
const url = buildUrl(this.baseUrl, "/api/wienerlinien/stops", {
|
||||
lat: String(lat),
|
||||
lng: String(lng),
|
||||
radius: String(radius),
|
||||
});
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`Nearby stops failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.stops ?? [];
|
||||
}
|
||||
|
||||
async searchStation(query: string): Promise<Station[]> {
|
||||
// Use HAFAS LocMatch to find real stations by name — returns proper extIds.
|
||||
const result = await this.hafasRequest<{
|
||||
svcReqL?: Array<{ res?: { locL?: Station[] } }>;
|
||||
}>({
|
||||
svcReqL: [
|
||||
{
|
||||
meth: "LocMatch",
|
||||
req: { searchTxt: query, maxMatches: 5 },
|
||||
},
|
||||
],
|
||||
});
|
||||
return result?.svcReqL?.[0]?.res?.locL ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user