update: move todos into their resp. file
This commit is contained in:
@@ -9,8 +9,3 @@ to run just run
|
||||
```
|
||||
make run
|
||||
```
|
||||
|
||||
### TODO
|
||||
|
||||
+ unit tests for business logic
|
||||
+ export in JSON
|
||||
+16
-11
@@ -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("<p><b>Search failed!<br>See the console for the error.</b></p>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user