MCPcopy
hub / github.com/lissy93/web-check / tryProvider

Function tryProvider

api/location.js:98–103  ·  view source on GitHub ↗
(p, ip, signal)

Source from the content-addressed store, hash-verified

96
97// Query a single provider, throw unless it yields a usable result
98const tryProvider = async (p, ip, signal) => {
99 const parsed = p.parse(await getJson(p.url(ip), signal));
100 if (!parsed?.country_code) throw new Error('no usable data');
101 log.debug(`${p.name} resolved ${ip} to ${parsed.country_code}`);
102 return parsed;
103};
104
105// Race all providers, first successful result wins, abort the rest
106const lookupGeo = async (ip) => {

Callers 1

lookupGeoFunction · 0.85

Calls 1

getJsonFunction · 0.85

Tested by

no test coverage detected