2019-08-05 22:59:47 +09:00
|
|
|
const { send, sendError, fetch } = require('../util/http')
|
|
|
|
|
|
|
|
module.exports = async (req, res) => {
|
2019-08-06 01:17:45 +09:00
|
|
|
const { query } = req.query
|
2019-08-05 22:59:47 +09:00
|
|
|
|
2019-08-06 01:17:45 +09:00
|
|
|
if (!query) {
|
2019-08-05 22:59:47 +09:00
|
|
|
return sendError(res, new Error('no query given'))
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await fetch(
|
|
|
|
`https://api.launchpad.net/devel/ubuntu/+source/${encodeURIComponent(
|
2019-08-06 01:17:45 +09:00
|
|
|
query
|
2019-08-05 22:59:47 +09:00
|
|
|
)}`,
|
|
|
|
'GET'
|
|
|
|
)
|
|
|
|
const availability = response.status !== 200
|
2019-08-06 01:17:45 +09:00
|
|
|
send(res, { availability })
|
2019-08-05 22:59:47 +09:00
|
|
|
} catch (err) {
|
|
|
|
sendError(res, err)
|
|
|
|
}
|
|
|
|
}
|