mirror of
https://github.com/uetchy/namae.git
synced 2025-10-14 23:22:19 +09:00
feat: add domain
This commit is contained in:
@@ -8,6 +8,7 @@ import NpmCard from './components/NpmCard'
|
||||
import JsOrgCard from './components/JsOrgCard'
|
||||
import HomebrewCard from './components/HomebrewCard'
|
||||
import PypiCard from './components/PypiCard'
|
||||
import DomainCard from './components/DomainCard'
|
||||
import './App.css'
|
||||
|
||||
const GlobalStyle = createGlobalStyle`
|
||||
@@ -45,9 +46,10 @@ export default function App() {
|
||||
<CardHolder>
|
||||
<GithubCard name={query} />
|
||||
<TwitterCard name={query} />
|
||||
<DomainCard name={query} />
|
||||
<HomebrewCard name={query} />
|
||||
<NpmCard name={query} />
|
||||
<JsOrgCard name={query} />
|
||||
<HomebrewCard name={query} />
|
||||
<PypiCard name={query} />
|
||||
</CardHolder>
|
||||
</Result>
|
||||
|
23
src/components/DomainCard.js
Normal file
23
src/components/DomainCard.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import React from 'react'
|
||||
import { Card, CardTitle, DedicatedAvailability } from './Card'
|
||||
import { FaMapSigns } from 'react-icons/fa'
|
||||
|
||||
export default function DomainCard({ name }) {
|
||||
return (
|
||||
<Card key={name}>
|
||||
<CardTitle>Domain</CardTitle>
|
||||
<DedicatedAvailability
|
||||
name={`${name}.app`}
|
||||
provider="domain"
|
||||
url={`https://${name}.app`}
|
||||
icon={<FaMapSigns />}
|
||||
/>
|
||||
<DedicatedAvailability
|
||||
name={`${name}.dev`}
|
||||
provider="domain"
|
||||
url={`https://${name}.dev`}
|
||||
icon={<FaMapSigns />}
|
||||
/>
|
||||
</Card>
|
||||
)
|
||||
}
|
18
src/services/domain.js
Normal file
18
src/services/domain.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import whois from 'whois-json'
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await whois(name, { follow: 3, verbose: true })
|
||||
const availability = response[0].data.domainName ? false : true
|
||||
|
||||
res.json({ availability })
|
||||
} catch (err) {
|
||||
res.status(400).json({ error: err.message })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user