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

feat: add domain

This commit is contained in:
2019-07-31 02:08:41 +09:00
parent 396cd18aa6
commit 540d1d1660
5 changed files with 216 additions and 8 deletions

18
src/services/domain.js Normal file
View 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 })
}
}