From 589bb118697ec7d2bdad87b503f4f76c6fcca96e Mon Sep 17 00:00:00 2001 From: Jan Thurau Date: Mon, 1 Jul 2024 20:15:40 +0200 Subject: [PATCH] allow shard config in the providerWebsocket --- .../provider/src/TiptapCollabProviderWebsocket.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/provider/src/TiptapCollabProviderWebsocket.ts b/packages/provider/src/TiptapCollabProviderWebsocket.ts index 7dc4ac01..cc3ee69d 100644 --- a/packages/provider/src/TiptapCollabProviderWebsocket.ts +++ b/packages/provider/src/TiptapCollabProviderWebsocket.ts @@ -17,10 +17,22 @@ export interface AdditionalTiptapCollabProviderWebsocketConfiguration { * If you are using the on-premise version of TiptapCollab, put your baseUrl here (e.g. https://collab.yourdomain.com) */ baseUrl?: string + + /** + * Only fill this if you are using Tiptap Collab HA. + */ + shardKey?: string } export class TiptapCollabProviderWebsocket extends HocuspocusProviderWebsocket { constructor(configuration: TiptapCollabProviderWebsocketConfiguration) { - super({ ...configuration as HocuspocusProviderWebsocketConfiguration, url: configuration.baseUrl ?? `wss://${configuration.appId}.collab.tiptap.cloud` }) + let url = configuration.baseUrl ?? `wss://${configuration.appId}.collab.tiptap.cloud` + + if (configuration.shardKey) { + url += url.includes('?') ? '&' : '?' + url += `shard=${configuration.shardKey}` + } + + super({ ...configuration as HocuspocusProviderWebsocketConfiguration, url }) } }