1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-17 04:30:31 +09:00

fix: whois provider

This commit is contained in:
uetchy 2020-02-08 19:43:22 +09:00
parent 71b74d4529
commit 3e6c678c46
6 changed files with 13 additions and 11 deletions

View File

@ -8,7 +8,7 @@
"test": "jest --coverage" "test": "jest --coverage"
}, },
"dependencies": { "dependencies": {
"isomorphic-unfetch": "^3.0.0", "node-fetch": "^2.6.0",
"npm-name": "^5.5.0", "npm-name": "^5.5.0",
"whois-json": "^2.0.4" "whois-json": "^2.0.4"
}, },

View File

@ -16,9 +16,6 @@ export default async function handler(
const availability = response[0].data.domainName ? false : true; const availability = response[0].data.domainName ? false : true;
send(res, {availability}); send(res, {availability});
} catch (err) { } catch (err) {
if (err.code === 'ENOTFOUND') {
return send(res, {availability: true});
}
sendError(res, err); sendError(res, err);
} }
} }

View File

@ -1,4 +1,4 @@
import nodeFetch from 'isomorphic-unfetch'; import nodeFetch, {Response} from 'node-fetch';
export type HttpMethod = export type HttpMethod =
| 'GET' | 'GET'
@ -21,15 +21,18 @@ export interface NowResponse {
length: number; 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}); 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.setHeader('Cache-Control', 's-maxage=86400');
res.json(data); 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}); res.status(400).json({error: error.message});
} }

View File

@ -1,4 +1,7 @@
export async function mockProvider(provider: any, query: any) { export async function mockProvider(
provider: any,
query: unknown,
): Promise<string> {
const req = { const req = {
query, query,
}; };

View File

@ -552,7 +552,6 @@ export const zones = [
'gcc', 'gcc',
'gd', 'gd',
'gdn', 'gdn',
'ge',
'gea', 'gea',
'gecompany', 'gecompany',
'ged', 'ged',

View File

@ -7608,7 +7608,7 @@ nock@^11.7.2:
mkdirp "^0.5.0" mkdirp "^0.5.0"
propagate "^2.0.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" version "2.6.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==