UNPKG

swipelime-client-node

Version:

swipelime-client-node is the official swipelime Node.js client library

35 lines (34 loc) 1.45 kB
"use strict"; // Copyright (c) 2024 swipelime (https://swipelime.com) // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. Object.defineProperty(exports, "__esModule", { value: true }); exports.getServerUrlForEnvironment = exports.swipelimeError = exports.swipelimeConsoleError = void 0; const swipelimeConsoleError = (msg) => { const errorMessage = typeof msg === 'string' ? `Swipelime client error: ${msg}` : `Swipelime client error: ${JSON.stringify(msg)}`; console.error(errorMessage); return errorMessage; }; exports.swipelimeConsoleError = swipelimeConsoleError; const swipelimeError = (msg) => { const errorMessage = (0, exports.swipelimeConsoleError)(msg); return new Error(errorMessage); }; exports.swipelimeError = swipelimeError; const getServerUrlForEnvironment = (environment) => { if (!environment) return 'wss://eu.swipelime.com/websocket'; switch (environment) { case 'live-eu': return 'wss://eu.swipelime.com/websocket'; case 'canary': return 'wss://canary.swipelime.com/websocket'; case 'test': return 'wss://test.swipelime.com/websocket'; case 'dev': return 'ws://localhost:3000/websocket'; default: throw (0, exports.swipelimeError)(`Unknown environment: ${environment}`); } }; exports.getServerUrlForEnvironment = getServerUrlForEnvironment;