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.

834 B
Raw Blame
import type { ValhallaRelayAction } from '@trek/shared';

/**
 * POST /api/routing/valhalla/:action: a question for the TREK services'
 * Valhalla, which this server asks with the installation key. The answer is
 * Valhalla's own, its status included, so it is handed back as a Response and
 * read like the answer of any other Valhalla. Plain fetch on purpose: the
 * shared client would turn a 401 into a sign-in redirect and a 429 into a
 * toast, where the planner only wants to ask FOSSGIS instead.
 */
export function postValhallaRelay(action: ValhallaRelayAction, body: unknown, signal?: AbortSignal): Promise<Response> {
  return fetch(`/api/routing/valhalla/${action}`, {
    method: 'POST',
    credentials: 'include',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
    signal,
  });
}