2024-04-20 09:32:19 +05:30
|
|
|
import { getSearxngApiEndpoint } from '../config';
|
2024-04-09 16:21:05 +05:30
|
|
|
|
2024-07-31 11:23:39 +08:00
|
|
|
import { SearxngService, type SearxngSearchParameters } from 'searxng';
|
2024-04-09 16:21:05 +05:30
|
|
|
|
2024-07-31 11:23:39 +08:00
|
|
|
const searxng = new SearxngService({
|
|
|
|
baseURL: getSearxngApiEndpoint(),
|
|
|
|
defaultSearchParams: {
|
|
|
|
format: 'json'
|
|
|
|
}
|
|
|
|
})
|
2024-04-09 16:21:05 +05:30
|
|
|
|
|
|
|
export const searchSearxng = async (
|
|
|
|
query: string,
|
2024-07-31 11:23:39 +08:00
|
|
|
opts?: SearxngSearchParameters,
|
2024-04-09 16:21:05 +05:30
|
|
|
) => {
|
|
|
|
|
2024-07-31 11:23:39 +08:00
|
|
|
const { results, suggestions } = await searxng.search(query, opts);
|
2024-04-09 16:21:05 +05:30
|
|
|
return { results, suggestions };
|
|
|
|
};
|