fix/optimize wtv-news, wtv-proxy, wtv-register, wtv-search, wtv-setup, wtv-star

This commit is contained in:
zefie
2025-08-12 19:19:23 -04:00
parent d5f41837c0
commit 74ec365ae1
20 changed files with 141 additions and 133 deletions

View File

@@ -1,7 +1,7 @@
minisrv_service_file = true;
const minisrv_service_file = true;
request_is_async = true;
var searchUrl = minisrv_config.services[service_name].searxng_url;
let searchUrl = minisrv_config.services[service_name].searxng_url;
if (!searchUrl.endsWith('/')) {
searchUrl += '/';
}
@@ -42,7 +42,7 @@ if (!request_headers.query.q) {
params.append('limit', '10');
const urlObj = new URL(searchUrl);
const lib = urlObj.protocol === 'https:' ? https : http;
var post_data = params.toString();
const post_data = params.toString();
const options = {
protocol: urlObj.protocol,
hostname: urlObj.hostname,
@@ -68,7 +68,7 @@ if (!request_headers.query.q) {
function fetch(lib, options, post_data) {
return new Promise((resolve, reject) => {
var req = lib.request(options, (res) => {
const req = lib.request(options, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve({ text: () => Promise.resolve(data) }));