trails/apps/planner/app/lib
Ullrich Schäfer a4df5a43f6
Route Overpass through server-side proxy with cache + coalescing
Adds apps/planner/app/routes/api.overpass.ts — a same-origin, rate-limited
server-side proxy that forwards Overpass QL to the upstream endpoint
configured via OVERPASS_URL (default: overpass.private.coffee).

Motivation:
- private.coffee's best-practices require a meaningful User-Agent
  identifying the project. Browsers cannot set User-Agent on fetch()
  (forbidden header), so the request has to originate server-side.
- Collaborative sessions commonly have N clients pan/zoom the same map,
  so the same bbox query arrives multiple times within seconds.
- Setting up the proxy now lets us swap OVERPASS_URL to a self-hosted
  Overpass later without client changes.

What the proxy does:
- Sets User-Agent "trails.cool Planner (https://trails.cool; legal@trails.cool)"
- Enforces same-origin via the Origin header
- Rate-limits per client IP (120 req/min)
- In-memory LRU cache of upstream responses keyed on the form-encoded body
  (TTL 10 min, max 200 entries)
- Coalesces concurrent misses for the same key so N simultaneous clients
  in one session incur exactly one upstream call

Client change: apps/planner/app/lib/overpass.ts POSTs to /api/overpass
instead of iterating over public Overpass endpoints. Fallback list
removed; resilience is now the proxy's responsibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 02:04:50 +02:00
..
brouter.test.ts Add road type color mode to route visualization 2026-04-11 11:13:43 +02:00
brouter.ts Add Journal dashboard, fix Caddy metrics, and improve alerts 2026-04-12 14:00:00 +02:00
crash-recovery.test.ts Add transactional emails (SMTP) and planner features (no-go areas, notes, crash recovery) 2026-03-26 01:00:42 +01:00
db.ts Add Drizzle ORM with shared db package (#10) 2026-03-22 22:35:50 +00:00
host-election.test.ts Fix planner production server + use .ts extensions everywhere 2026-03-25 01:41:33 +01:00
host-election.ts Fix waypoint drag, host election, segment routing, debug panel 2026-03-23 08:52:52 +01:00
logger.server.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
metrics.server.ts Guard all metric registrations against re-evaluation 2026-04-03 10:02:21 +01:00
overnight.test.ts Add per-day map coloring and remaining unit tests 2026-04-11 00:12:27 +02:00
overnight.ts Add multi-day data model, computeDays, and GPX roundtrip 2026-04-10 23:51:31 +02:00
overpass.test.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
overpass.ts Route Overpass through server-side proxy with cache + coalescing 2026-04-18 02:04:50 +02:00
poi-cache.test.ts Add i18n keys and unit tests for overlays 2026-04-11 01:19:27 +02:00
poi-cache.ts Add Overpass client, POI categories, cache, and usePois hook 2026-04-11 01:15:34 +02:00
poi-categories.test.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
poi-snap.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
rate-limit.test.ts Fix planner production server + use .ts extensions everywhere 2026-03-25 01:41:33 +01:00
rate-limit.ts Increase route rate limit from 60 to 300 requests/hour 2026-04-11 02:05:41 +02:00
sessions.ts Add split export: Export Route vs Export Plan 2026-04-03 10:52:39 +01:00
use-days.ts Add multi-day data model, computeDays, and GPX roundtrip 2026-04-10 23:51:31 +02:00
use-pois.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
use-profile-defaults.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
use-routing.ts Add smoothness, track type, cycleway, and bike route color modes 2026-04-11 11:13:44 +02:00
use-undo.test.ts Add undo/redo to planner 2026-04-04 10:04:01 +01:00
use-undo.ts Add undo/redo to planner 2026-04-04 10:04:01 +01:00
use-yjs-poi-sync.ts Add Yjs sync for POI categories across participants 2026-04-11 02:28:11 +02:00
use-yjs.ts Sync notes through GPX, Journal, and Planner roundtrip 2026-04-11 03:35:40 +02:00
vite-yjs-plugin.ts Fix waypoint drag, host election, segment routing, debug panel 2026-03-23 08:52:52 +01:00
yjs-server.ts Wire planner metrics gauges to actual session/client counts 2026-04-03 09:16:31 +01:00