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:
@@ -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});
|
||||
}
|
||||
|
Reference in New Issue
Block a user