1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 18:08:11 +09:00

feat(api): typescript

This commit is contained in:
2019-08-30 16:40:22 +09:00
parent 6fbd0346d0
commit f2e45bac4b
24 changed files with 340 additions and 878 deletions

22
api/services/launchpad.ts Normal file
View File

@@ -0,0 +1,22 @@
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)
}
}