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.

909 B
Raw Blame
import type { WindForecastResponse } from '@trek/shared';
import { windApi } from '../api/wind';
import { isEffectivelyOffline } from '../sync/networkMode';

/** Thrown instead of asking while the app is offline, so the view can say so rather than show a failure. */
export class WindOfflineError extends Error {
  constructor() {
    super('Wind forecast needs a connection');
    this.name = 'WindOfflineError';
  }
}

/**
 * PAD-08: the wind forecast, online only on purpose. A forecast kept on the
 * device would be read later as the current one; it is asked again every time
 * and never cached here, and offline nothing is asked at all.
 */
export const windRepo = {
  async forecast(lat: number, lng: number, date: string, signal?: AbortSignal): Promise<WindForecastResponse> {
    if (isEffectivelyOffline()) throw new WindOfflineError();
    return windApi.forecast(lat, lng, date, signal);
  },
};