UNPKG

backend-mcp

Version:

Generador automático de backends con Node.js, Express, Prisma y módulos configurables. Servidor MCP compatible con npx para agentes IA. Soporta PostgreSQL, MySQL, MongoDB y SQLite.

233 lines (211 loc) 5.06 kB
module: name: "websockets" version: "1.0.0" description: "Sistema completo de WebSockets para comunicación en tiempo real" category: "realtime" author: "Backend MCP" license: "MIT" triggers: - condition: "user_wants_realtime" value: true - condition: "needs_websockets" value: true - condition: "requires_chat" value: true - condition: "has_notifications" value: true - keywords: - "websockets" - "tiempo real" - "realtime" - "chat" - "notificaciones" - "socket.io" - "ws" - "live" - "streaming" entry_points: gateway: "templates/websocket.gateway.ts.hbs" service: "templates/websocket.service.ts.hbs" handlers: "templates/socket.handlers.ts.hbs" middleware: "templates/socket.middleware.ts.hbs" events: "templates/socket.events.ts.hbs" dependencies: required: - "database" optional: - "auth" - "logging" - "redis" environment_variables: required: [] optional: - WEBSOCKET_PORT - WEBSOCKET_CORS_ORIGIN - REDIS_URL - WEBSOCKET_ADAPTER - MAX_CONNECTIONS - HEARTBEAT_INTERVAL features: - "real-time-messaging" - "room-management" - "user-presence" - "message-broadcasting" - "private-messaging" - "typing-indicators" - "connection-management" - "event-handling" - "middleware-support" - "authentication-integration" - "redis-adapter" - "scalable-architecture" api_endpoints: - "WS /socket.io" - "GET /websocket/status" - "GET /websocket/rooms" - "POST /websocket/broadcast" - "GET /websocket/connections" generated_files: - "src/websockets/websocket.gateway.ts" - "src/websockets/websocket.service.ts" - "src/websockets/socket.handlers.ts" - "src/websockets/socket.middleware.ts" - "src/websockets/socket.events.ts" - "src/websockets/websocket.controller.ts" - "src/websockets/websocket.module.ts" integration: database_tables: - "socket_connections" - "chat_messages" - "user_presence" auth_integration: - "jwt-authentication" - "user-identification" - "permission-checking" redis_integration: - "connection-scaling" - "message-persistence" - "presence-tracking" events: client_to_server: - "join_room" - "leave_room" - "send_message" - "typing_start" - "typing_stop" - "user_status_change" server_to_client: - "message_received" - "user_joined" - "user_left" - "typing_indicator" - "notification" - "presence_update" rooms: types: - "public" - "private" - "group" - "broadcast" features: - "auto-join" - "permission-based" - "temporary" - "persistent" middleware: - "authentication" - "rate-limiting" - "logging" - "error-handling" - "cors" usage_examples: - "Real-time chat application" - "Live notifications system" - "Collaborative editing" - "Live dashboard updates" - "Gaming real-time features" - "Live streaming comments" ai_instructions: | Use this module when: - User mentions "real-time", "websockets", "chat", "live", "streaming" - Project requires instant communication - Need live updates or notifications Always combine with: - database module (for message persistence) - auth module (for user identification) - redis (for scaling across instances) Configuration steps: 1. Setup Socket.IO gateway 2. Configure authentication middleware 3. Define event handlers 4. Setup room management 5. Configure Redis adapter for scaling 6. Integrate with existing auth system automation: scripts: - "setup-socketio" - "test-connection" - "monitor-connections" - "broadcast-message" testing: unit_tests: - "websocket.gateway.test.ts" - "websocket.service.test.ts" - "socket.handlers.test.ts" integration_tests: - "websocket-flow.test.ts" - "room-management.test.ts" e2e_tests: - "chat-functionality.e2e.test.ts" - "real-time-notifications.e2e.test.ts" performance: metrics: - "concurrent_connections" - "messages_per_second" - "room_join_leave_rate" - "memory_usage_per_connection" optimization: - "connection_pooling" - "message_batching" - "redis_clustering" - "load_balancing" scaling: strategies: - "horizontal_scaling" - "redis_adapter" - "sticky_sessions" - "load_balancer_config" limits: - max_connections: 10000 - max_rooms: 1000 - message_rate_limit: 100 security: features: - "jwt_authentication" - "rate_limiting" - "cors_protection" - "input_validation" - "room_permissions" best_practices: - "validate_all_inputs" - "authenticate_connections" - "limit_message_size" - "monitor_abuse" compatibility: node_versions: - ">=16.0.0" frameworks: - "nestjs" - "express" - "fastify" clients: - "socket.io-client" - "native-websockets" - "react-socket.io" - "vue-socket.io" documentation: - "README.md" - "API.md" - "EVENTS.md" - "SCALING.md" - "SECURITY.md"