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

19 lines
450 B
JavaScript

import whois from 'whois-json'
const { send, sendError } = require('../util/http')
module.exports = async (req, res) => {
const name = req.query.name
if (!name) {
return sendError(res, new 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)
} catch (err) {
sendError(res, err)
}
}