1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-17 04:30:31 +09:00
namae/api/services/github.js

20 lines
439 B
JavaScript

const { send, sendError, fetch } = require('../util/http')
module.exports = async (req, res) => {
const { query } = req.query
if (!query) {
return sendError(res, new Error('no query given'))
}
try {
const response = await fetch(
`https://github.com/${encodeURIComponent(query)}`
)
const availability = response.status !== 200
send(res, { availability })
} catch (err) {
sendError(res, err)
}
}