anil-brd-typescript-sdk
Version:
TypeScript SDK for Bright Data APIs - Web Unlocker, SERP, and Scraper APIs
29 lines (28 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BrightDataClient = void 0;
const http_client_1 = require("./http/http-client");
const web_unlocker_service_1 = require("./services/web-unlocker-service");
class BrightDataClient {
constructor(config) {
// Normalize config
const normalizedConfig = typeof config === 'string'
? { apiKey: config, zone: 'web_unlocker1' } // Default zone if only API key is provided
: config;
if (!normalizedConfig.apiKey) {
throw new Error('API key is required');
}
if (!normalizedConfig.zone) {
throw new Error('Zone is required in config');
}
// Initialize HTTP client with default configuration
this.httpClient = new http_client_1.HttpClient({
apiKey: normalizedConfig.apiKey,
baseUrl: normalizedConfig.baseUrl,
timeout: normalizedConfig.timeout
});
// Initialize Web Unlocker service
this.webUnlocker = new web_unlocker_service_1.WebUnlockerService(this.httpClient, normalizedConfig.zone);
}
}
exports.BrightDataClient = BrightDataClient;