@translated/lara
Version:
Official Lara SDK for JavaScript and Node.js
24 lines (23 loc) • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LaraClient = void 0;
exports.default = create;
const browser_client_1 = require("./browser-client");
const node_client_1 = require("./node-client");
var client_1 = require("./client");
Object.defineProperty(exports, "LaraClient", { enumerable: true, get: function () { return client_1.LaraClient; } });
const DEFAULT_BASE_URL = "https://api.laratranslate.com";
function create(accessKeyId, accessKeySecret, baseUrl) {
const url = new URL(baseUrl || 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) : url.protocol === "https:" ? 443 : 80
};
if (typeof window !== "undefined")
return new browser_client_1.BrowserLaraClient(parsedURL, accessKeyId, accessKeySecret);
else
return new node_client_1.NodeLaraClient(parsedURL, accessKeyId, accessKeySecret);
}