mirror of
https://github.com/uetchy/namae.git
synced 2025-10-14 23:22:19 +09:00
feat: google search card
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"google-it": "^1.2.0",
|
||||
"isomorphic-unfetch": "^3.0.0",
|
||||
"npm-name": "^5.5.0",
|
||||
"whois-json": "^2.0.4"
|
||||
|
17
api/services/google.js
Normal file
17
api/services/google.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
const googleIt = require('google-it')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const { query } = req.query
|
||||
|
||||
if (!query) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await googleIt({ query: query })
|
||||
send(res, { result: result || [] })
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user