(url)
| 5 | |
| 6 | // Server-side Shodan lookup so the API key never touches the client |
| 7 | const shodanHandler = async (url) => { |
| 8 | const auth = requireEnv('SHODAN_API_KEY', 'Shodan'); |
| 9 | if (auth.skipped) return auth; |
| 10 | const { hostname } = parseTarget(url); |
| 11 | try { |
| 12 | const res = await httpGet(`https://api.shodan.io/shodan/host/${hostname}?key=${auth.value}`, { |
| 13 | timeout: 8000, |
| 14 | }); |
| 15 | return res.data; |
| 16 | } catch (error) { |
| 17 | return upstreamError(error, 'Shodan lookup'); |
| 18 | } |
| 19 | }; |
| 20 | |
| 21 | export const handler = middleware(shodanHandler); |
| 22 | export default handler; |
nothing calls this directly
no test coverage detected