@@ -250,6 +250,21 @@ function resolveDateTime(departureTime?: string): { date: string; time: string }
250250 } ;
251251}
252252
253+ export function resolveLocalMotisUrl (
254+ serviceUrl : unknown ,
255+ configuredEndpoint : unknown ,
256+ environmentUrl : unknown ,
257+ ) : string {
258+ return (
259+ [ serviceUrl , configuredEndpoint , environmentUrl ]
260+ . find (
261+ ( candidate ) : candidate is string =>
262+ typeof candidate === "string" && candidate . trim ( ) . length > 0 ,
263+ )
264+ ?. trim ( ) ?? "http://localhost:8081"
265+ ) ;
266+ }
267+
253268async function planWithInstance (
254269 instance : MotisInstance ,
255270 params : TripPlanRequest ,
@@ -311,12 +326,9 @@ export function setupLocal(ctx: IntegrationContext): void {
311326 // and live-transit-motis honour, so a single deployment-wide
312327 // `MOTIS_URL=…` reaches every consumer of the local instance.
313328 const resolved = ctx . getRequiredService ( "motis" ) ;
314- const motisUrl =
315- resolved ?. url ??
316- ( ctx . config . endpoint as string | undefined ) ??
317- process . env . MOTIS_URL ??
318- "http://localhost:8081" ;
329+ const motisUrl = resolveLocalMotisUrl ( resolved ?. url , ctx . config . endpoint , process . env . MOTIS_URL ) ;
319330 setMotisLocalUrl ( motisUrl ) ;
331+ ctx . log . info ( `[transit-motis] configured local MOTIS endpoint: ${ motisUrl } ` ) ;
320332 cachedLocalReachable = false ;
321333 cachedLocalReachableAt = 0 ;
322334 // Warm the live rental-capability probe so the access options reflect reality
0 commit comments