1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 09:58:13 +09:00

fix: support new vercel style

This commit is contained in:
2020-06-19 16:15:53 +09:00
parent a5f9074303
commit f95f8ef551
106 changed files with 4523 additions and 1390 deletions

View File

@@ -0,0 +1,21 @@
import npmName from 'npm-name';
import {send, sendError} from '../../../util/http';
import {NowRequest, NowResponse} from '@vercel/node';
export default async function handler(
req: NowRequest,
res: NowResponse,
): Promise<void> {
const {query} = req.query;
if (!query || typeof query !== 'string') {
return sendError(res, new Error('No query given'));
}
try {
const availability = await npmName(query);
send(res, {availability});
} catch (err) {
sendError(res, err);
}
}