-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #445 from MeshJS/playground-and-hydra
Playground and hydra
- Loading branch information
Showing
33 changed files
with
1,003 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { post } from "./"; | ||
|
||
export async function searchQuery(query: string) { | ||
const googleSearchResults = await post(`google/search`, { query }); | ||
|
||
const results: any[] = []; | ||
|
||
for (const result of googleSearchResults.items) { | ||
results.push({ | ||
title: result.title, | ||
url: result.link.replace("https://meshjs.dev/", "/"), | ||
displayUrl: result.htmlFormattedUrl, | ||
snippet: result.htmlSnippet, | ||
}); | ||
} | ||
|
||
return results; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
import axios from "axios"; | ||
|
||
export default async function handler( | ||
_req: NextApiRequest, | ||
_res: NextApiResponse, | ||
) { | ||
try { | ||
const query = _req.body.query; | ||
const resGoogle = await axios.get( | ||
`https://customsearch.googleapis.com/customsearch/v1?key=${process.env.GOOGLE_SEARCH_API}&cx=${process.env.GOOGLE_SEARCH_CX}&num=10&q=${query}`, | ||
); | ||
_res.status(200).json(resGoogle.data); | ||
} catch (error) { | ||
_res.status(500).json(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.