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

style: prettier

This commit is contained in:
2020-08-20 00:57:33 +09:00
parent a31c13e725
commit c7bbe707a9
71 changed files with 1074 additions and 1089 deletions

View File

@@ -1,31 +1,31 @@
import {send, sendError, fetch} from '../../../util/http';
import {NowRequest, NowResponse} from '@vercel/node';
import { send, sendError, fetch } from '../../../util/http'
import { NowRequest, NowResponse } from '@vercel/node'
export default async function handler(
req: NowRequest,
res: NowResponse,
res: NowResponse
): Promise<void> {
const {query} = req.query;
const { query } = req.query
if (!query || typeof query !== 'string') {
return sendError(res, new Error('No query given'));
return sendError(res, new Error('No query given'))
}
if (/[^a-zA-Z0-9_-]/.test(query)) {
return sendError(res, new Error('Invalid characters'));
return sendError(res, new Error('Invalid characters'))
}
try {
const response = await fetch(
`https://spectrum.chat/${encodeURIComponent(query)}`,
'GET',
);
const body = await response.text();
'GET'
)
const body = await response.text()
const availability = body.includes(
'You may be trying to view something that is deleted',
);
send(res, {availability});
'You may be trying to view something that is deleted'
)
send(res, { availability })
} catch (err) {
sendError(res, err);
sendError(res, err)
}
}