mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 04:30:31 +09:00
18 lines
369 B
JavaScript
18 lines
369 B
JavaScript
const npmName = require('npm-name')
|
|
const { send, sendError } = require('../util/http')
|
|
|
|
module.exports = async (req, res) => {
|
|
const { query } = req.query
|
|
|
|
if (!query) {
|
|
return sendError(res, new Error('no query given'))
|
|
}
|
|
|
|
try {
|
|
const availability = await npmName(query)
|
|
send(res, { availability })
|
|
} catch (err) {
|
|
sendError(res, err)
|
|
}
|
|
}
|