mirror of
https://github.com/uetchy/namae.git
synced 2025-10-14 23:22:19 +09:00
feat: add linux card
This commit is contained in:
21
api/services/debian.js
Normal file
21
api/services/debian.js
Normal file
@@ -0,0 +1,21 @@
|
||||
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://packages.debian.org/buster/${encodeURIComponent(name)}`,
|
||||
'GET'
|
||||
)
|
||||
const body = await response.text()
|
||||
const availability = body.includes('No such package')
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
22
api/services/launchpad.js
Normal file
22
api/services/launchpad.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user