mirror of
https://github.com/uetchy/namae.git
synced 2025-03-16 20:20:38 +09:00
fix: .js.org provider
This commit is contained in:
parent
2790dfb7ac
commit
3c17a189b6
32
api/services/jsorg/[query].ts
Normal file
32
api/services/jsorg/[query].ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
if (!query || typeof query !== 'string') {
|
||||||
|
return sendError(res, new Error('No query given'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!/([a-zA-Z0-9_-])\.js\.org/.test(query)) {
|
||||||
|
return sendError(res, new Error('Invalid format'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Get js.org domain data from js.org.json repo
|
||||||
|
const domains = await fetch(
|
||||||
|
`https://raw.githubusercontent.com/raikasdev/js.org.json/master/output/subdomains_registered.min.json`,
|
||||||
|
'GET'
|
||||||
|
).then((res) => res.json());
|
||||||
|
if (domains.includes(query)) {
|
||||||
|
send(res, { availability: false });
|
||||||
|
} else {
|
||||||
|
send(res, { availability: true });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
sendError(res, err);
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ const JsOrgCard: React.FC<{ query: string }> = ({ query }) => {
|
|||||||
{(name) => (
|
{(name) => (
|
||||||
<DedicatedAvailability
|
<DedicatedAvailability
|
||||||
name={`${name}.js.org`}
|
name={`${name}.js.org`}
|
||||||
service="dns"
|
service="jsorg"
|
||||||
message="Go to js.org repository"
|
message="Go to js.org repository"
|
||||||
link="https://github.com/js-org/js.org"
|
link="https://github.com/js-org/js.org"
|
||||||
messageIfTaken={`Go to ${name}.js.org`}
|
messageIfTaken={`Go to ${name}.js.org`}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user