@translated/lara
Version:
Official Lara SDK for JavaScript and Node.js
22 lines (21 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpClient = exports.LaraClient = void 0;
exports.default = create;
const defaultBaseUrl_1 = require("../../utils/defaultBaseUrl");
const browser_client_1 = require("./browser-client");
var client_1 = require("./client");
Object.defineProperty(exports, "LaraClient", { enumerable: true, get: function () { return client_1.LaraClient; } });
function create(auth, baseUrl, keepAlive, timeout) {
const url = new URL(baseUrl || defaultBaseUrl_1.DEFAULT_BASE_URL);
if (url.protocol !== "https:" && url.protocol !== "http:")
throw new TypeError(`Invalid URL (protocol): ${url.protocol}`);
const parsedURL = {
secure: url.protocol === "https:",
hostname: url.hostname,
port: url.port ? parseInt(url.port, 10) : url.protocol === "https:" ? 443 : 80
};
return new browser_client_1.BrowserLaraClient(parsedURL, auth, keepAlive !== null && keepAlive !== void 0 ? keepAlive : true, timeout);
}
var browser_client_2 = require("./browser-client");
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return browser_client_2.BrowserClient; } });