Skip to content

Commit

Permalink
Add TS File
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchoeler committed May 5, 2022
1 parent deb0455 commit e491153
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/livechat/src/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import LivechatClient from '@rocket.chat/sdk/lib/clients/Livechat';
import { parse } from 'query-string';

const host = window.SERVER_URL
|| parse(window.location.search).serverUrl
|| (process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : null);
export const useSsl = Boolean((Array.isArray(host) ? host[0] : host)?.match(/^https:/));

export const Livechat = new LivechatClient({ host, protocol: 'ddp', useSsl });
2 changes: 2 additions & 0 deletions packages/livechat/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-unused-vars
interface Window {SERVER_URL: string;}

0 comments on commit e491153

Please sign in to comment.