feat(server): ask the TREK services' Photon before Nominatim for search and reverse lookups

An installation that holds a key for the TREK services and has no
NOMINATIM_URL of its own now sends the OpenStreetMap search and the
reverse lookups to photon.liketrek.com first. The answers are read into
Nominatim's shape, so the place records stay the same, and every miss
(refused key, allowance spent, timeout, error, foreign body) falls back
to Nominatim, with a one minute pause after four misses in a row.

TREK_PHOTON_URL points at another copy, and the default of
TREK_SERVICES_HOSTS now lists photon.liketrek.com and
valhalla.liketrek.com beside places.liketrek.com.
This commit is contained in:
Maurice
2026-10-29 10:27:02 +01:00
committed by Maurice
parent 4ab3244f8f
commit 256f8c08e2
22 changed files with 1091 additions and 48 deletions
+5 -1
View File
@@ -63,7 +63,10 @@ export function deriveKitinerary(raw: RawEnv) {
}
/** The liketrek hosts that receive the installation key when nothing else is configured. */
const DEFAULT_SERVICE_HOSTS = ['places.liketrek.com'];
const DEFAULT_SERVICE_HOSTS = ['places.liketrek.com', 'photon.liketrek.com', 'valhalla.liketrek.com'];
/** The address search of the TREK services, asked before Nominatim while the installation holds a key. */
const DEFAULT_PHOTON_URL = 'https://photon.liketrek.com';
/**
* How this installation identifies itself to the liketrek services. Unset is
@@ -77,6 +80,7 @@ export function deriveServices(raw: RawEnv) {
mode: mode === 'auto' ? ('auto' as const) : ('off' as const),
key: raw.TREK_SERVICES_KEY?.trim() || null,
hosts: hosts?.length ? hosts : DEFAULT_SERVICE_HOSTS,
photonUrl: stripTrailingSlashes(raw.TREK_PHOTON_URL?.trim() || DEFAULT_PHOTON_URL),
};
}
+2
View File
@@ -284,6 +284,8 @@ export function deriveIntegrations(raw: RawEnv) {
// treats a blank one as unset, so a padded or whitespace-only value would
// otherwise pass startup and then be the string that cannot be fetched.
nominatimUrl: stripTrailingSlashes(raw.NOMINATIM_URL?.trim() || 'https://nominatim.openstreetmap.org'),
/** The operator runs a geocoder of their own, so search and reverse stay on it instead of going to Photon. */
nominatimOwn: Boolean(raw.NOMINATIM_URL?.trim()),
overpassUrl: raw.OVERPASS_URL,
// Longer than the `[timeout:20]` the query itself carries, or we abort an answer the
// mirror was still allowed to be working on. See OVERPASS_QUERY_TIMEOUT_S.
+1
View File
@@ -188,6 +188,7 @@ export const envSchema = z.object({
TREK_SERVICES: oneOf(['auto', 'off']),
TREK_SERVICES_KEY: optionalWith(isServiceKeyShape, 'must be a TREK services key (tk1.<kid>.<payload>.<signature>)'),
TREK_SERVICES_HOSTS: anyString,
TREK_PHOTON_URL: url,
PLACES_API_KEY: anyString,
AMAP_API_BASE: url,
AMAP_API_KEY: anyString,