1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-21 02:08:12 +09:00

fix: whois provider

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

View File

@@ -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});
}