UNPKG

@openfga/sdk

Version:

JavaScript and Node.js SDK for OpenFGA

51 lines (50 loc) 1.73 kB
"use strict"; /** * JavaScript and Node.js SDK for OpenFGA * * API version: 1.x * Website: https://openfga.dev * Documentation: https://openfga.dev/docs * Support: https://openfga.dev/community * License: [Apache-2.0](https://github.com/openfga/js-sdk/blob/main/LICENSE) * * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseAPI = void 0; // Some imports not used depending on template conditions const axios_1 = require("axios"); const http = require("http"); const https = require("https"); const configuration_1 = require("./configuration"); const credentials_1 = require("./credentials"); const DEFAULT_CONNECTION_TIMEOUT_IN_MS = 10000; /** * * @export * @class BaseAPI */ class BaseAPI { constructor(configuration, axios) { this.axios = axios; if (configuration instanceof configuration_1.Configuration) { this.configuration = configuration; } else { this.configuration = new configuration_1.Configuration(configuration); } this.configuration.isValid(); this.credentials = credentials_1.Credentials.init(this.configuration, this.axios); if (!this.axios) { const httpAgent = new http.Agent({ keepAlive: true }); const httpsAgent = new https.Agent({ keepAlive: true }); this.axios = axios_1.default.create({ httpAgent, httpsAgent, timeout: DEFAULT_CONNECTION_TIMEOUT_IN_MS, headers: this.configuration.baseOptions?.headers, }); } } } exports.BaseAPI = BaseAPI;