Skip to content

Commit

Permalink
Added support of INSITE_CLIENT_WSS_URL env var
Browse files Browse the repository at this point in the history
  • Loading branch information
nesvet committed Apr 9, 2024
1 parent 42e6ad4 commit 098f928
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "@nesvet",
"env": {
"browser": true,
"node": true
"node": true,
"es2020": true
},
"root": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insite-client",
"version": "1.0.58",
"version": "1.0.67",
"description": "Client-side inSite app",
"type": "module",
"main": "./dist/index.js",
Expand Down
14 changes: 4 additions & 10 deletions src/InSite.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ import { OutgoingTransport } from "insite-ws-transfers/browser/outgoing";


export class InSite extends EventEmitter {
constructor({ wssurl = process.env.INSITE_WSS }) {
constructor({ wss = globalThis.__insite?.wss_url } = {}) {
super();

if (!wssurl)
throw new Error("wssurl or INSITE_WSS have to be set");
if (!wss)
throw new Error("wss or INSITE_CLIENT_WSS_URL have to be set");

if (!/^wss?:\/\//.test(wssurl))
wssurl =
/^https?:\/\//.test(wssurl) ?
wssurl.replace(/^http(s?):\/\//, "ws$1://") :
`wss://${wssurl}`;

this.ws = new WebSocket(wssurl);
this.ws = new WebSocket(wss);

new RequestSender(this.ws);

Expand Down

0 comments on commit 098f928

Please sign in to comment.