1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-21 02:08:12 +09:00

feat: cache only if the response is succeeded

This commit is contained in:
2019-08-01 13:22:03 +09:00
parent 536e65e10e
commit a8fa8a04d1
12 changed files with 43 additions and 34 deletions

View File

@@ -1,4 +1,5 @@
import whois from 'whois-json'
const { send, sendError } = require('../util/http')
module.exports = async (req, res) => {
const name = req.query.name
@@ -10,9 +11,8 @@ module.exports = async (req, res) => {
try {
const response = await whois(name, { follow: 3, verbose: true })
const availability = response[0].data.domainName ? false : true
res.json({ availability })
send(res, availability)
} catch (err) {
res.status(400).json({ error: err.message })
sendError(res, err)
}
}