UNPKG

proxy-auto-ts

Version:

A comprehensive TypeScript library for automatic proxy management with validation, rotation, and intelligent selection

44 lines โ€ข 1.69 kB
import { ProxyManager } from "./lib.js"; // Simple test utility that won't hang async function simpleTest() { console.log("๐Ÿงช Simple Proxy Test"); const proxyManager = new ProxyManager(); await proxyManager.initialize(); const proxyCount = await proxyManager.getProxyCount(); console.log(`๐Ÿ“Š Loaded ${proxyCount} proxies`); // Set a short timeout for testing const testManager = new ProxyManager({ timeout: 5000, validationTimeout: 3000 }); await testManager.initialize(); try { // Test with very limited retries console.log(`\n๐Ÿ“‹ Testing with limited retries (max 3)...`); const result = await testManager.fetchWithProxy("https://httpbin.org/ip", 3); console.log(`โœ… Working proxy found: ${result.proxy}`); console.log(`๐Ÿ“Š Your IP: ${JSON.stringify(result.data)}`); console.log(`โฑ๏ธ Latency: ${result.latency}ms`); } catch (error) { console.log(`โš ๏ธ No working proxies found in first 3 attempts: ${error.message}`); } // Test stats console.log(`\n๐Ÿ“‹ Library statistics...`); const stats = await proxyManager.getStats(); console.log(`๐Ÿ“Š Total proxies: ${stats.totalProxies}`); console.log(`๐Ÿ“ Proxy list path: ${stats.proxyListPath}`); console.log(`โš™๏ธ Timeout: ${stats.config.timeout}ms`); console.log(`\n๐ŸŽ‰ Test completed!`); } // Run the test simpleTest() .then(() => { console.log(`\nโœ… All tests completed successfully!`); process.exit(0); }) .catch((error) => { console.error(`\nโŒ Test failed:`, error.message); process.exit(1); }); //# sourceMappingURL=simple-test.js.map