mirror of
https://github.com/uetchy/namae.git
synced 2025-03-16 20:20:38 +09:00
fix: whois provider
This commit is contained in:
parent
71b74d4529
commit
3e6c678c46
@ -8,7 +8,7 @@
|
||||
"test": "jest --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"isomorphic-unfetch": "^3.0.0",
|
||||
"node-fetch": "^2.6.0",
|
||||
"npm-name": "^5.5.0",
|
||||
"whois-json": "^2.0.4"
|
||||
},
|
||||
|
@ -16,9 +16,6 @@ export default async function handler(
|
||||
const availability = response[0].data.domainName ? false : true;
|
||||
send(res, {availability});
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOTFOUND') {
|
||||
return send(res, {availability: true});
|
||||
}
|
||||
sendError(res, err);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import nodeFetch from 'isomorphic-unfetch';
|
||||
import nodeFetch, {Response} from 'node-fetch';
|
||||
|
||||
export type HttpMethod =
|
||||
| 'GET'
|
||||
@ -21,15 +21,18 @@ export interface NowResponse {
|
||||
length: number;
|
||||
}
|
||||
|
||||
export function fetch(url: string, method: HttpMethod = 'HEAD') {
|
||||
export function fetch(
|
||||
url: string,
|
||||
method: HttpMethod = 'HEAD',
|
||||
): Promise<Response> {
|
||||
return nodeFetch(url, {method: method});
|
||||
}
|
||||
|
||||
export function send(res: NowResponse, data: object) {
|
||||
export function send(res: NowResponse, data: object): void {
|
||||
res.setHeader('Cache-Control', 's-maxage=86400');
|
||||
res.json(data);
|
||||
}
|
||||
|
||||
export function sendError(res: NowResponse, error: Error) {
|
||||
export function sendError(res: NowResponse, error: Error): void {
|
||||
res.status(400).json({error: error.message});
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
export async function mockProvider(provider: any, query: any) {
|
||||
export async function mockProvider(
|
||||
provider: any,
|
||||
query: unknown,
|
||||
): Promise<string> {
|
||||
const req = {
|
||||
query,
|
||||
};
|
||||
|
@ -552,7 +552,6 @@ export const zones = [
|
||||
'gcc',
|
||||
'gd',
|
||||
'gdn',
|
||||
'ge',
|
||||
'gea',
|
||||
'gecompany',
|
||||
'ged',
|
||||
|
@ -7608,7 +7608,7 @@ nock@^11.7.2:
|
||||
mkdirp "^0.5.0"
|
||||
propagate "^2.0.0"
|
||||
|
||||
node-fetch@^2.1.2, node-fetch@^2.2.0:
|
||||
node-fetch@^2.1.2, node-fetch@^2.2.0, node-fetch@^2.6.0:
|
||||
version "2.6.0"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
|
||||
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
|
||||
|
Loading…
x
Reference in New Issue
Block a user