
- Complete NestJS TypeScript implementation with WebSocket support - Direct messaging (DM) and group chat functionality - End-to-end encryption with AES encryption and key pairs - Media file support (images, videos, audio, documents) up to 100MB - Push notifications with Firebase Cloud Messaging integration - Mention alerts and real-time typing indicators - User authentication with JWT and Passport - SQLite database with TypeORM entities and relationships - Comprehensive API documentation with Swagger/OpenAPI - File upload handling with secure access control - Online/offline status tracking and presence management - Message editing, deletion, and reply functionality - Notification management with automatic cleanup - Health check endpoint for monitoring - CORS configuration for cross-origin requests - Environment-based configuration management - Structured for Flutter SDK integration Features implemented: ✅ Real-time messaging with Socket.IO ✅ User registration and authentication ✅ Direct messages and group chats ✅ Media file uploads and management ✅ End-to-end encryption ✅ Push notifications ✅ Mention alerts ✅ Typing indicators ✅ Message read receipts ✅ Online status tracking ✅ File access control ✅ Comprehensive API documentation Ready for Flutter SDK development and production deployment.
56 lines
2.5 KiB
JavaScript
56 lines
2.5 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SocketServerProvider = void 0;
|
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
const server_and_event_streams_factory_1 = require("./factories/server-and-event-streams-factory");
|
|
class SocketServerProvider {
|
|
constructor(socketsContainer, applicationConfig) {
|
|
this.socketsContainer = socketsContainer;
|
|
this.applicationConfig = applicationConfig;
|
|
}
|
|
scanForSocketServer(options, port) {
|
|
const serverAndStreamsHost = this.socketsContainer.getOneByConfig({
|
|
port,
|
|
path: options.path,
|
|
});
|
|
if (serverAndStreamsHost && options.namespace) {
|
|
return this.decorateWithNamespace(options, port, serverAndStreamsHost.server);
|
|
}
|
|
return serverAndStreamsHost
|
|
? serverAndStreamsHost
|
|
: this.createSocketServer(options, port);
|
|
}
|
|
createSocketServer(options, port) {
|
|
const adapter = this.applicationConfig.getIoAdapter();
|
|
const { namespace, server, ...partialOptions } = options;
|
|
const ioServer = adapter.create(port, partialOptions);
|
|
const serverAndEventStreamsHost = server_and_event_streams_factory_1.ServerAndEventStreamsFactory.create(ioServer);
|
|
this.socketsContainer.addOne({ port, path: options.path }, serverAndEventStreamsHost);
|
|
if (!namespace) {
|
|
return serverAndEventStreamsHost;
|
|
}
|
|
return this.decorateWithNamespace(options, port, ioServer);
|
|
}
|
|
decorateWithNamespace(options, port, targetServer) {
|
|
const namespaceServer = this.getServerOfNamespace(options, port, targetServer);
|
|
const serverAndEventStreamsHost = server_and_event_streams_factory_1.ServerAndEventStreamsFactory.create(namespaceServer);
|
|
this.socketsContainer.addOne({ port, path: options.path, namespace: options.namespace }, serverAndEventStreamsHost);
|
|
return serverAndEventStreamsHost;
|
|
}
|
|
getServerOfNamespace(options, port, server) {
|
|
const adapter = this.applicationConfig.getIoAdapter();
|
|
return adapter.create(port, {
|
|
...options,
|
|
namespace: this.validateNamespace(options.namespace || ''),
|
|
server,
|
|
});
|
|
}
|
|
validateNamespace(namespace) {
|
|
if (!(0, shared_utils_1.isString)(namespace)) {
|
|
return namespace;
|
|
}
|
|
return (0, shared_utils_1.addLeadingSlash)(namespace);
|
|
}
|
|
}
|
|
exports.SocketServerProvider = SocketServerProvider;
|