UNPKG

dymo-api

Version:

Flow system for Dymo API.

34 lines (33 loc) 1.14 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.axiosApiUrl = exports.BASE_URL = exports.setBaseUrl = void 0; const axios_1 = __importDefault(require("axios")); const config = { lib: { name: "Dymo API", dir: "dymo-api" }, env: { baseUrl: "https://api.tpeoficial.com" } }; exports.default = config; let BASE_URL = config.env.baseUrl; exports.BASE_URL = BASE_URL; const setBaseUrl = (baseUrl) => { if (/^(https:\/\/api\.tpeoficial\.com$|http:\/\/(localhost:\d+|dymoapi:\d+))$/.test(baseUrl)) exports.BASE_URL = BASE_URL = baseUrl; else throw new Error("[Dymo API] Invalid URL. It must be https://api.tpeoficial.com or start with http://localhost or http://dymoapi followed by a port."); }; exports.setBaseUrl = setBaseUrl; const axiosApiUrl = axios_1.default.create({ baseURL: `${BASE_URL}/v1`, headers: { "User-Agent": "DymoAPISDK/1.0.0" } }); exports.axiosApiUrl = axiosApiUrl;