1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-17 20:40:32 +09:00
namae/api/services/launchpad.ts

23 lines
552 B
TypeScript

import { send, sendError, fetch, NowRequest, NowResponse } from '../util/http'
export default async function handler(req: NowRequest, res: NowResponse) {
const { query } = req.query
if (!query) {
return sendError(res, new Error('no query given'))
}
try {
const response = await fetch(
`https://api.launchpad.net/devel/ubuntu/+source/${encodeURIComponent(
query
)}`,
'GET'
)
const availability = response.status !== 200
send(res, { availability })
} catch (err) {
sendError(res, err)
}
}