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:
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