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:
17
api/services/npm-org.ts
Normal file
17
api/services/npm-org.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import npmName from 'npm-name'
|
||||
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 availability = await npmName(`@${query}`)
|
||||
send(res, { availability })
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user