mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 04:30:31 +09:00
24 lines
611 B
TypeScript
24 lines
611 B
TypeScript
import {send, sendError, fetch, NowResponse, NowRequest} from '../util/http';
|
|
|
|
export default async function handler(req: NowRequest, res: NowResponse) {
|
|
const {query} = req.query;
|
|
|
|
if (!query) {
|
|
return sendError(res, new Error('no query given'));
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(
|
|
`https://spectrum.chat/${encodeURIComponent(query)}`,
|
|
'GET',
|
|
);
|
|
const body = await response.text();
|
|
const availability = body.includes(
|
|
'You may be trying to view something that is deleted',
|
|
);
|
|
send(res, {availability});
|
|
} catch (err) {
|
|
sendError(res, err);
|
|
}
|
|
}
|