1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-18 04:50:32 +09:00
namae/api/services/domain.js

19 lines
456 B
JavaScript
Raw Normal View History

2019-07-31 02:08:41 +09:00
import whois from 'whois-json'
const { send, sendError } = require('../util/http')
2019-07-31 02:08:41 +09:00
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
send(res, availability)
2019-07-31 02:08:41 +09:00
} catch (err) {
sendError(res, err)
2019-07-31 02:08:41 +09:00
}
}