mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 04:30:31 +09:00
fix: better whois impl
This commit is contained in:
parent
a233c24516
commit
bd239acb87
@ -1,6 +1,6 @@
|
||||
import { VercelRequest, VercelResponse } from '@vercel/node';
|
||||
import 'cross-fetch';
|
||||
import whois from 'whois-json';
|
||||
import whoiser from 'whoiser';
|
||||
import { send, sendError } from '../../../util/http';
|
||||
|
||||
export default async function handler(
|
||||
@ -14,9 +14,17 @@ export default async function handler(
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await whois(query, { follow: 3, verbose: true });
|
||||
const availability = response[0].data.domainName ? false : true;
|
||||
send(res, { availability });
|
||||
const response = await whoiser(query, { follow: 1, timeout: 5000 });
|
||||
const first = Object.values<any>(response)[0];
|
||||
if (first.error) {
|
||||
throw new Error(`Got error while querying for ${query}: ${first.error}`);
|
||||
}
|
||||
try {
|
||||
const availability = first['Domain Status'].length > 0 ? false : true;
|
||||
send(res, { availability });
|
||||
} catch (err) {
|
||||
console.log(response);
|
||||
}
|
||||
} catch (err: any) {
|
||||
sendError(res, err);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
"styled-components": "^5.3.5",
|
||||
"swr": "^1.2.2",
|
||||
"validator": "^13.7.0",
|
||||
"whois-json": "^2.0.4"
|
||||
"whoiser": "^1.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sentry/cli": "^1.74.2",
|
||||
|
@ -2,7 +2,6 @@ import useFetch from 'fetch-suspense';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FaFirefoxBrowser } from 'react-icons/fa';
|
||||
import { RiChromeFill } from 'react-icons/ri';
|
||||
import { Card, Result } from '../core';
|
||||
|
||||
const Search: React.FC<{ query: string }> = ({ query }) => {
|
||||
|
@ -10541,6 +10541,13 @@ whois@^2.6.0:
|
||||
underscore "^1.9.1"
|
||||
yargs "^15.4.1"
|
||||
|
||||
whoiser@^1.13.1:
|
||||
version "1.13.1"
|
||||
resolved "https://registry.npmjs.org/whoiser/-/whoiser-1.13.1.tgz#943a2030199efd774d5047df22528316ac6de5de"
|
||||
integrity sha512-4MF0LoIsSdM7R9rs9A+PxbCXMDRmRdF7eZb8IC8pGethCrSizqMLcbJCXZO5iZGqOKovQlRhpSFGGUlwUPzoQA==
|
||||
dependencies:
|
||||
punycode "^2.1.1"
|
||||
|
||||
wide-align@^1.1.0:
|
||||
version "1.1.5"
|
||||
resolved "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz#df1d4c206854369ecf3c9a4898f1b23fbd9d15d3"
|
||||
|
Loading…
x
Reference in New Issue
Block a user