mirror of
https://github.com/uetchy/namae.git
synced 2025-08-20 01:48:12 +09:00
fix: support new vercel style
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
interface App {
|
||||
trackId: string;
|
||||
@@ -14,12 +15,12 @@ interface AppStoreResponse {
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest<{query: string; country: string}>,
|
||||
req: NowRequest,
|
||||
res: NowResponse,
|
||||
): Promise<void> {
|
||||
const {query, country} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -6,7 +7,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import dns from 'dns';
|
||||
import {send, sendError, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
function resolvePromise(hostname: string): Promise<string[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
dns.resolve4(hostname, function(err, addresses) {
|
||||
dns.resolve4(hostname, function (err, addresses) {
|
||||
if (err) return reject(err);
|
||||
resolve(addresses);
|
||||
});
|
||||
@@ -16,7 +17,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import whois from 'whois-json';
|
||||
import {send, sendError, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -7,7 +8,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import isURL from 'validator/lib/isURL';
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -7,7 +8,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('no query given'));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
import nodeFetch from 'node-fetch';
|
||||
|
||||
export default async function handler(
|
||||
@@ -7,7 +8,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -6,7 +7,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import npmName from 'npm-name';
|
||||
import {send, sendError, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -7,7 +8,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import npmName from 'npm-name';
|
||||
import {send, sendError, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -7,7 +8,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,14 +1,15 @@
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
const APPLICATION_ID = process.env.NTA_APPLICATION_ID;
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest<{query: string; country: string}>,
|
||||
req: NowRequest,
|
||||
res: NowResponse,
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -6,7 +7,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, fetch, NowResponse, NowRequest} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -6,7 +7,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import {send, sendError, fetch, NowResponse, NowRequest} from '../util/http';
|
||||
import {send, sendError, fetch} from '../../../util/http';
|
||||
import {NowRequest, NowResponse} from '@vercel/node';
|
||||
|
||||
export default async function handler(
|
||||
req: NowRequest,
|
||||
@@ -6,7 +7,7 @@ export default async function handler(
|
||||
): Promise<void> {
|
||||
const {query} = req.query;
|
||||
|
||||
if (!query) {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return sendError(res, new Error('No query given'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user