(url)
| 169 | |
| 170 | // Resolve geographic info for a host via a chain of providers with country enrichment |
| 171 | const 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 | |
| 183 | export const handler = middleware(locationHandler); |
| 184 | export default handler; |
nothing calls this directly
no test coverage detected