1
0
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:
2019-08-07 14:08:32 +09:00
parent 6113bfe6a5
commit 1031a70b0f
7 changed files with 201 additions and 14 deletions

View File

@@ -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
View 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)
}
}