diff --git a/README.md b/README.md index 28db538..097be68 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,4 @@ to run just run ``` make run -``` - -### TODO - -+ unit tests for business logic -+ export in JSON \ No newline at end of file +``` \ No newline at end of file diff --git a/app/src/search.js b/app/src/search.js index 1648a36..663cf2a 100644 --- a/app/src/search.js +++ b/app/src/search.js @@ -1,5 +1,15 @@ +// TODO: unit tests for business logic +// TODO: export in JSON + const cheerio = require("cheerio"); +function filterJson(data) { + var filtereddata = []; + data.forEach(element => { + filtereddata.push(); + }); +} + async function handleSearch(req, res) { try { const query = req.query.query; @@ -8,16 +18,11 @@ async function handleSearch(req, res) { return res.status(400).send("Missing search query"); } - /* here we use a searx.ng instance (a meta-search engine) and filter out google search results. - * by testing, i've found out that !goc (google's programmable search engine) is more reliable for - * this kind of operation. - * the instance could be changed if the current one e.g. goes out of service. + /* Here we use a local searx.ng instance (a meta-search engine) and filter out google/startpage + * search results. By testing, i've found out that !sp (startpage) ro !goc (google's programmable + * search engine) is more reliable for this kind of operation that regular google. + * A local instance instead of an already available one is used because of bot detection. :) */ - /** - * more instances: - * https://baresearch.org/ - */ - //const url = `https://baresearch.org/search?q=!goc+${encodeURIComponent(query)}`; const searxngUrl = process.env.SEARXNG_URL || "http://localhost:8080"; const params = new URLSearchParams({ q: query, @@ -35,10 +40,10 @@ async function handleSearch(req, res) { ); const data = await response.json(); - res.json(data.results || []); + res.json(filterJson(data.results || [])); } catch (error) { console.error("[SEARCH.JS] " + error); - res.status(500).send("Search failed"); + res.status(500).send("
Search failed!
See the console for the error.