mirror of
https://github.com/Lissy93/web-check.git
synced 2026-05-12 21:00:38 -04:00
- Fixes Vercel deployment by pinning to 20.x - Refactors console outputs into logger.js - Fixes sections still visible when no data (Server Info) - Fixes checks still show error after fallback succeeds (Screenshot) - Updates client-side env var names, from `REACT_APP_` to `PUBLIC_`
18 lines
499 B
JavaScript
18 lines
499 B
JavaScript
import dns from 'dns';
|
|
import middleware from './_common/middleware.js';
|
|
import { parseTarget } from './_common/parse-target.js';
|
|
|
|
const lookupAsync = (address) => new Promise((resolve, reject) => {
|
|
dns.lookup(address, (err, ip, family) => {
|
|
if (err) reject(err); else resolve({ ip, family });
|
|
});
|
|
});
|
|
|
|
const ipHandler = async (url) => {
|
|
const { hostname } = parseTarget(url);
|
|
return await lookupAsync(hostname);
|
|
};
|
|
|
|
export const handler = middleware(ipHandler);
|
|
export default handler;
|