refactor(geocoder): converge the 3 forward-geocode paths onto one shared createGeocoder client#59
Merged
tompscanlan merged 3 commits intoJul 7, 2026
Conversation
Extend the shared createGeocoder result so interactive callers get a display label and structured address parts without a second client, and request addressdetails=1. Prep for converging the three forward-geocode paths (om-qp3y).
Near-me forward geocode now delegates to the one shared client, so it honors a configured GEOCODER_URL/GEOCODER_KEY (key appended server-side) instead of a hardcoded public-Nominatim URL. Drops the duplicate fetch/parse and the stale 'does not honor GEOCODER_URL' comment (om-qp3y).
… shape
/api/geocoding now calls createGeocoder (one URL + User-Agent + key handling)
and returns a normalized {lat,lng,label,address,...} shape instead of the raw
Nominatim object; drops the stray console.error, keeps the auth gate. Updates
the two consumers (resolveGeoLocation, LocationSection) to the normalized keys
(om-qp3y).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Converges the three server-side forward-geocode paths onto the one shared
createGeocoderclient so there's a single source of truth for the endpoint URL, User-Agent, key handling, and error handling.Before
Three separate forward-geocoders had drifted apart:
/api/geocoding) — its own hardcoded Nominatim URL + UA, returned the raw upstream object, logged every request via a strayconsole.error.geocode.ts) — public Nominatim,format=jsonv2, own result shape, deliberately skippedGEOCODER_URL.createGeocoder) — the only path with LocationIQ key handling, 404-as-no-match, and WGS84/limit safety.After
createGeocoderclient — no path defines its own/searchURL or UA literal.GeoPointgained optionallabel(display_name),address(addressdetails),osmType,osmId, so each caller gets what it needs without a second client./api/geocodingreturns a normalized{lat, lng, label, address, osmType, osmId}shape (no more raw-object leak), 404 on no-match, auth gate kept, stray happy-pathconsole.errorremoved.resolveGeocoderUserAgent).GEOCODER_URL/GEOCODER_KEY— applied to all three call sites. The key stays server-side only; the client only ever receives coords/label.Verification
apps/webpnpm test: 175 passed / 4 skipped (21 files).apps/webpnpm check: 0 errors.Follow-up to the earlier near-me geocode dedup, which converged only
geocode.ts.