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-31 08:41:53 +09:00
committed by uetchy
parent 9278b7a2ee
commit f5f7b51fcb
73 changed files with 1014 additions and 5220 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
): 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()
);
const body = await response.text();
const availability = body.includes(
'You may be trying to view something that is deleted'
)
send(res, { availability })
);
send(res, { availability });
} catch (err) {
sendError(res, err)
sendError(res, err);
}
}