Repository navigation
Conversation
…elay maps through geo-ip-client, address file support in the client, and an old versus new parity harness
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.
Summary
Ports every api-service route into
apps/api-serviceonBun.serve, with no web framework. Responses keep the status codes, bodies, content types, CORS headers and ETags of the Express service. The relay map and fingerprint map read locations from geo-ip-service throughgeo-ip-clientand keep serving cached locations while it is down. The MaxMind reader, the database files and the unused MongoDB connection are gone from the service. A parity harness compares the running Express service with the ported one route by route.Changes
/relays/:fingerprint,/relays,/relay-map/,/fingerprint-map/,POST /hardware,/operatorsand/anyone-domains, plus/healthz.src/express-compat.tsreproduces what the Express stack added:Access-Control-Allow-Origin: *on every answer, and a204preflight for anyOPTIONSrequest304for a matchingIf-None-Matchapplication/json; charset=utf-8, text astext/html; charset=utf-8400and413pages forPOST /hardwarePOST /hardwarevalidation returns the same error list as the express-validator rules it replaces, field paths and messages included.geo-ip-client, cached forGEO_IP_CACHE_TTL(default one hour)/healthzreportsgeoIpasdegraded503when no address has a location, as on a start with geo-ip-service down; the other routes do not depend on itfetch, and the UNS indexer database is read withBun.SQL, so axios, pg, winston, dotenv, express and mongoose are gone. Caching, timeouts, retries and stale-on-failure behave as before.GEO_IP_SERVICE_URLorGEO_IP_SERVICE_URL_FILEis new. A missing or invalid variable now stops startup instead of falling back.dev,startand the image run Bun with--max-http-header-size=80000, matching the current job's Node setting; Bun's default is 16 KiB.geo-ip-client:baseUrlmay be a function called before every request, andurlFromFile(path)reads the address from a file rendered by a Nomad template. An unknown address counts as a failed request.parity/parity.tsreplays a fixed request set against both services and reports differences in status, body, content type, CORS headers and ETag, then lists every other header difference without failing on it. It retries to ride out data changing between the two answers, defeats the Varnish cache, sends only invalid hardware bodies, and checks a long relay request.Verified
bun run checkunder Bun 1.4.3: typecheck clean, 187 tests pass, 1 skipped (it needs a real HyperBEAM node).1e-9, because Node and Bun round trigonometry differently. Header differences listed:X-Powered-By,Connection,Keep-Alive, and the not found page'sContent-Security-PolicyandX-Content-Type-Options.POST /hardwaregave identical status, body and ETag from both./healthzreporteddegraded. On a restart with geo-ip-service down, both maps answered503and every other route answered200. Once geo-ip-service was back, the maps recovered after the client's 30 second wait.200, read the domains from Postgres, and stopped onSIGTERMin 0.2 seconds with exit code 0.