ee/apps/ddp-streamer/src/service.ts
import { api } from '@rocket.chat/core-services';
import type { Document } from 'mongodb';
import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels';
import { Collections, getCollection, getConnection } from '../../../../apps/meteor/ee/server/services/mongo';
import { broker } from '../../../../apps/meteor/ee/server/startup/broker';
(async () => {
const db = await getConnection();
const trash = await getCollection<Document>(Collections.Trash);
registerServiceModels(db, trash);
api.setBroker(broker);
// need to import service after models are registered
const { NotificationsModule } = await import('../../../../apps/meteor/server/modules/notifications/notifications.module');
const { DDPStreamer } = await import('./DDPStreamer');
const { Stream } = await import('./Streamer');
const notifications = new NotificationsModule(Stream);
notifications.configure();
api.registerService(new DDPStreamer(notifications));
await api.start();
})();