[post-modularisation]Removed Redis from CE (#12695)

* Removed redis init from ce

* Added server file
This commit is contained in:
Muhsin Shah C P 2025-04-24 16:09:04 +05:30 committed by GitHub
parent 91a1720185
commit c1f7de98eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 30 deletions

@ -1 +1 @@
Subproject commit 580c287986ae9dffe6580a6c6a6840dbcd18fd80
Subproject commit d25a63dc72c911dbd2973973861c63f62990efde

View file

@ -1,39 +1,11 @@
import http from 'http';
import { WebSocketGateway, WebSocketServer, OnGatewayConnection, OnGatewayDisconnect } from '@nestjs/websockets';
import { Server } from 'ws';
import { setupWSConnection, setPersistence } from 'y-websocket/bin/utils';
import { RedisPubSub } from '../../helpers/redis';
import { setupWSConnection } from 'y-websocket/bin/utils';
import { maybeSetSubPath } from '../../helpers/utils.helper';
import { isEmpty } from 'lodash';
import { SessionUtilService } from '@modules/session/util.service';
// TODO: Mock redis for test env
if (process.env.NODE_ENV !== 'test') {
const redis = new RedisPubSub({
redisOpts: process.env.REDIS_URL
? process.env.REDIS_URL
: {
host: process.env.REDIS_HOST || 'localhost',
port: process.env.REDIS_PORT || 6379,
username: process.env.REDIS_USER || '',
password: process.env.REDIS_PASSWORD || '',
},
});
setPersistence({
provider: redis,
bindState: async (docName: any, ydoc: any) => {
const persistedYdoc = redis.bindState(docName, ydoc);
ydoc.on('update', persistedYdoc.updateHandler);
ydoc.awareness.on('update', (update, conn) => persistedYdoc.updateAwarenessHandler(ydoc.awareness, update, conn));
},
writeState: (docName: any, ydoc: any) => {
return new Promise((resolve) => {
resolve(redis.closeDoc(docName));
});
},
});
}
@WebSocketGateway({ path: maybeSetSubPath('/yjs') })
export class YjsGateway implements OnGatewayConnection, OnGatewayDisconnect {