Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1022 B
Raw Blame
import { roadtripHazardsSchema } from '@trek/shared'
import { apiClient } from '../api/client'

/**
 * How long the browser waits for the hazard feed.
 *
 * The server keeps the feed for ten minutes and, once that is up, answers the
 * next request only after it has fetched DWD and GDACS afresh: the GDACS event
 * list and then up to twelve polygon lookups, each allowed 15 s. A cold read
 * takes nine to twenty seconds, so at the shared 8 s the browser gave up on
 * every first read after the cache expired, the map showed no warnings, and
 * the next attempt was ten minutes away although the server had the answer a
 * moment later. The bound is the sum of the server's own ceilings.
 */
export const ROADTRIP_HAZARDS_TIMEOUT_MS = 45_000

export const roadtripHazardsRepo = {
  async read(tripId: number, signal: AbortSignal) {
    const fetched = await apiClient.get(`/trips/${tripId}/roadtrip/hazards`, { signal, timeout: ROADTRIP_HAZARDS_TIMEOUT_MS })
    return roadtripHazardsSchema.parse(fetched.data)
  },
}