Skip to content

Commit

Permalink
allow shard config in the providerWebsocket
Browse files Browse the repository at this point in the history
  • Loading branch information
janthurau committed Jul 1, 2024
1 parent 7b42fa2 commit 589bb11
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/provider/src/TiptapCollabProviderWebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
}

0 comments on commit 589bb11

Please sign in to comment.