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

Function locationHandler

api/location.js:171–181  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

169
170// Resolve geographic info for a host via a chain of providers with country enrichment
171const locationHandler = async (url) => {
172 const { hostname } = parseTarget(url);
173 const ip = await resolveHost(hostname);
174 const geo = await lookupGeo(ip);
175 if (!geo) {
176 log.error(`all geo providers failed for ${ip}`);
177 return { error: 'IP location lookup unavailable across all providers, please try again later' };
178 }
179 const enrichment = await enrichCountry(geo.country_code);
180 return { ...enrichment, ...compact(geo) };
181};
182
183export const handler = middleware(locationHandler);
184export default handler;

Callers

nothing calls this directly

Calls 5

parseTargetFunction · 0.90
resolveHostFunction · 0.85
lookupGeoFunction · 0.85
enrichCountryFunction · 0.85
compactFunction · 0.85

Tested by

no test coverage detected