UNPKG

@onboardbase/cli

Version:

[![Version](https://img.shields.io/npm/v/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![Downloads/week](https://img.shields.io/npm/dw/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![License](https://img

37 lines (36 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SocketService = void 0; const base_service_1 = require("../common/base.service"); const io = require("socket.io-client"); class SocketService extends base_service_1.BaseService { constructor(configManager) { super(configManager); } getSocketHost() { var _a; const scopeApiHost = (_a = this.getConfigForCurrentScope(`api-host`)) !== null && _a !== void 0 ? _a : "http://localhost:3000"; return scopeApiHost; } createSocketInstance({ project, environment, userEmail, }) { if (this.socketInstance) return this.socketInstance; const host = this.getSocketHost(); this.socketInstance = io.connect(host, { transports: ["websocket"], query: `project=${project}_${environment}&email=${userEmail}`, }); return this.socketInstance; } closeSocket() { if (this.socketInstance) this.socketInstance.close(); } onUpdateEventEmitted(_handleLiveReload) { this.socketInstance.on("UPDATE", _handleLiveReload); } onSecretShareEventEmitted(email, project, _handleSecretShareEvent) { this.socketInstance.on(`SHARE_LOCAL_${email}_${project}`, _handleSecretShareEvent); } } exports.SocketService = SocketService;