1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-03 14:50:03 +09:00
namae/api/services/launchpad.js

23 lines
490 B
JavaScript
Raw Normal View History

2019-08-05 22:59:47 +09:00
const { send, sendError, fetch } = 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 fetch(
`https://api.launchpad.net/devel/ubuntu/+source/${encodeURIComponent(
name
)}`,
'GET'
)
const availability = response.status !== 200
send(res, availability)
} catch (err) {
sendError(res, err)
}
}