fixed webshare

This commit is contained in:
Boki 2025-06-20 00:04:38 -04:00
parent 9413d6588d
commit b501d7a2da
5 changed files with 67 additions and 5 deletions

View file

@ -16,7 +16,7 @@
"redis": {
"host": "localhost",
"port": 6379,
"db": 1
"db": 0
},
"defaultJobOptions": {
"attempts": 3,
@ -27,5 +27,9 @@
"removeOnComplete": true,
"removeOnFail": false
}
},
"webshare": {
"apiKey": "",
"apiUrl": "https://proxy.webshare.io/api/v2/"
}
}

View file

@ -95,9 +95,13 @@ export const webShareProvider = {
async function fetchProxiesFromWebShare(): Promise<string[] | null> {
try {
// Get configuration from config system
const { getConfig } = await import('@stock-bot/config');
const config = getConfig();
// Try environment variables first, then fall back to config
const apiKey = process.env.WEBSHARE_API_KEY;
const apiUrl = process.env.WEBSHARE_API_URL;
const apiKey = process.env.WEBSHARE_API_KEY || config.webshare?.apiKey;
const apiUrl = process.env.WEBSHARE_API_URL || config.webshare?.apiUrl;
if (!apiKey || !apiUrl) {
logger.error('Missing WebShare configuration', {
@ -105,6 +109,8 @@ async function fetchProxiesFromWebShare(): Promise<string[] | null> {
hasApiUrl: !!apiUrl,
envApiKey: process.env.WEBSHARE_API_KEY?.substring(0, 10) + '...',
envApiUrl: process.env.WEBSHARE_API_URL,
configApiKey: config.webshare?.apiKey?.substring(0, 10) + '...',
configApiUrl: config.webshare?.apiUrl,
});
return null;
}