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
+8 -2
View File
@@ -2,6 +2,7 @@ import { AppSettings } from '../../db/entities/AppSettings.entity';
import { PlaceDetailsCache } from '../../db/entities/PlaceDetailsCache.entity';
import { Places } from '../../db/entities/Places.entity';
import { Users } from '../../db/entities/Users.entity';
import { AppConfigModule } from '../app-config/app-config.module';
import { GoogleQuotaModule } from '../google-quota/google-quota.module';
import { PlacePhotosModule } from '../place-photos/place-photos.module';
import { StorageModule } from '../storage/storage.module';
@@ -15,6 +16,7 @@ import { PlacesProviderSelector } from './places-provider.selector';
import { PoisAlongResolver } from './pois-along.resolver';
import { GooglePlacesClient } from './providers/google-places.provider';
import { OsmClient } from './providers/osm.client';
import { PhotonClient } from './providers/photon.client';
import { WikimediaClient } from './providers/wikimedia.client';
import { TrekPlacesLayersService } from './trek-places-layers.service';
import { MikroOrmModule } from '@mikro-orm/nestjs';
@@ -26,7 +28,8 @@ import { Module } from '@nestjs/common';
* MapsService is the orchestrator every consumer injects (BookingImportModule's
* geocoding, PlacesModule's search_place tool and list-import enrichment, the
* road trip search). Behind it sit one provider per outbound source
* (GooglePlacesClient, OsmClient, WikimediaClient; Amap is built per request by
* (GooglePlacesClient, OsmClient with the PhotonClient it asks before
* Nominatim, WikimediaClient; Amap is built per request by
* PlacesProviderSelector) and the resolvers it delegates to. The three clients
* are exported too, so the enrichment column asks Google, OpenStreetMap and
* Wikimedia directly rather than through a MapsService facade, and
@@ -34,7 +37,8 @@ import { Module } from '@nestjs/common';
* routes layers before it asks the Overpass mirrors. Nothing outside
* the container consumes this domain, so there is no bridge.
*
* MikroOrmModule.forFeature: AppSettings and Users for the key chain
* AppConfigModule for the servicesConfig token PhotonClient reads its address
* from. MikroOrmModule.forFeature: AppSettings and Users for the key chain
* (instance-api-keys.ts's resolveApiKey) and the kill switches,
* PlaceDetailsCache for the details cache (the entity only, not
* place-enrichment's module, so there is no new module edge) and Places for the
@@ -42,6 +46,7 @@ import { Module } from '@nestjs/common';
*/
@Module({
imports: [
AppConfigModule,
PlacePhotosModule,
StorageModule,
GoogleQuotaModule,
@@ -53,6 +58,7 @@ import { Module } from '@nestjs/common';
MapsMcp,
GooglePlacesClient,
OsmClient,
PhotonClient,
WikimediaClient,
PlacesProviderSelector,
PlacePhotoResolver,