feat: Add preferences parameter to /searxng endpoint

Added paramater and handles it in the query parameters.
This commit is contained in:
Jonathan Nogueira 2024-11-13 14:27:31 +09:00
parent a3ca407b27
commit f880c68968
No known key found for this signature in database
GPG Key ID: D7EB0A1BB2B6A5EA
1 changed files with 4 additions and 1 deletions

View File

@ -160,7 +160,7 @@ router.post('/transcript', jsonParser, async (request, response) => {
router.post('/searxng', jsonParser, async (request, response) => {
try {
const { baseUrl, query } = request.body;
const { baseUrl, query, preferences } = request.body;
if (!baseUrl || !query) {
console.log('Missing required parameters for /searxng');
@ -188,6 +188,9 @@ router.post('/searxng', jsonParser, async (request, response) => {
const searchUrl = new URL('/search', baseUrl);
const searchParams = new URLSearchParams();
searchParams.append('q', query);
if (preferences.length > 0) {
searchParams.append('preferences', preferences);
}
searchUrl.search = searchParams.toString();
const searchResult = await fetch(searchUrl, { headers: visitHeaders });