mirror of
https://github.com/docmost/docmost.git
synced 2025-11-14 15:31:16 +10:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { Server as HocuspocusServer } from '@hocuspocus/server';
|
|
import { IncomingMessage } from 'http';
|
|
import WebSocket from 'ws';
|
|
import { AuthenticationExtension } from './extensions/authentication.extension';
|
|
import { PersistenceExtension } from './extensions/persistence.extension';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { HistoryExtension } from './extensions/history.extension';
|
|
|
|
@Injectable()
|
|
export class CollaborationGateway {
|
|
constructor(
|
|
private authenticationExtension: AuthenticationExtension,
|
|
private persistenceExtension: PersistenceExtension,
|
|
private historyExtension: HistoryExtension,
|
|
) {}
|
|
|
|
private hocuspocus = HocuspocusServer.configure({
|
|
debounce: 5000,
|
|
maxDebounce: 10000,
|
|
extensions: [
|
|
this.authenticationExtension,
|
|
this.persistenceExtension,
|
|
this.historyExtension,
|
|
],
|
|
});
|
|
|
|
handleConnection(client: WebSocket, request: IncomingMessage): any {
|
|
this.hocuspocus.handleConnection(client, request);
|
|
}
|
|
|
|
destroy() {
|
|
this.hocuspocus.destroy();
|
|
}
|
|
}
|