{"id":26800503,"url":"https://github.com/alejandro-castillo-delgado/websocket","last_synced_at":"2026-04-11T02:02:22.828Z","repository":{"id":192268020,"uuid":"686398562","full_name":"alejandro-castillo-delgado/websocket","owner":"alejandro-castillo-delgado","description":"**WebSocket Server con Node.js y Socket.IO** 🌐   Servidor básico para comunicación en tiempo real, ideal para chats, notificaciones o actualizaciones instantáneas. Incluye:   - Conexiones bidireccionales vía WebSocket   - Soporte CORS para integración frontend   - Eventos personalizados (`mensaje`/`respuesta`)   - Configuración mínima y escalable ","archived":false,"fork":false,"pushed_at":"2025-03-20T14:30:42.000Z","size":1432,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T15:36:47.637Z","etag":null,"topics":["api","backend","chat-app","cors","events","express","instant-updates","javascript","nodejs","nodejs-server","notifications","realtime","realtime-api","realtime-communication","server","socketio","websocket","websocket-server"],"latest_commit_sha":null,"homepage":"https://test-websocket-b69e.onrender.com","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alejandro-castillo-delgado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-02T16:53:42.000Z","updated_at":"2025-03-20T15:15:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"effced7a-6faf-4f59-9645-943b3d0c4d6d","html_url":"https://github.com/alejandro-castillo-delgado/websocket","commit_stats":null,"previous_names":["alejandro-castillo-delgado/websocket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro-castillo-delgado%2Fwebsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro-castillo-delgado%2Fwebsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro-castillo-delgado%2Fwebsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejandro-castillo-delgado%2Fwebsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alejandro-castillo-delgado","download_url":"https://codeload.github.com/alejandro-castillo-delgado/websocket/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237435,"owners_count":20745348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","backend","chat-app","cors","events","express","instant-updates","javascript","nodejs","nodejs-server","notifications","realtime","realtime-api","realtime-communication","server","socketio","websocket","websocket-server"],"created_at":"2025-03-29T20:17:40.688Z","updated_at":"2026-04-11T02:02:17.779Z","avatar_url":"https://github.com/alejandro-castillo-delgado.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"```markdown\n# WebSocket Server with Express and Socket.IO 🚀\n\nUn servidor WebSocket básico implementado con Node.js, Express y Socket.IO, ideal para aplicaciones que requieren comunicación en tiempo real.\n\n![WebSocket](https://img.shields.io/badge/WebSocket-Enabled-brightgreen)\n![Node.js](https://img.shields.io/badge/Node.js-18.x-green)\n![Express](https://img.shields.io/badge/Express-4.x-blue)\n![Socket.IO](https://img.shields.io/badge/Socket.IO-4.x-orange)\n\n## Características principales ⚡\n- **Conexiones en tiempo real** usando WebSocket\n- **Soporte CORS** para conexiones cruzadas\n- Manejo de eventos personalizados (`mensaje` y `respuesta`)\n- Escalable y fácil de integrar\n- Configuración de puerto flexible (usando variable de entorno `PORT`)\n\n## Instalación 🔧\n\n1. Clona el repositorio:\n```bash\ngit clone https://github.com/alejandro-castillo-delgado/websocket.git\ncd websocket\n```\n\n2. Instala las dependencias:\n```bash\nnpm install express socket.io cors\n```\n\n3. Inicia el servidor:\n```bash\nnode index.js\n```\n\n## Uso básico 💻\n\n### Código del servidor (index.js)\n```javascript\nconst express = require('express');\nconst http = require('http');\nconst socketIO = require('socket.io');\nconst cors = require('cors');\n\nconst app = express();\napp.use(cors());\n\nconst server = http.createServer(app);\nconst io = socketIO(server);\n\nio.on('connection', (socket) =\u003e {\n    console.log('Cliente conectado');\n\n    socket.on('mensaje', (data) =\u003e {\n        console.log('Mensaje recibido:', data);\n        socket.emit('respuesta', '¡Mensaje recibido por el servidor!');\n    });\n\n    socket.on('disconnect', () =\u003e {\n        console.log('Cliente desconectado');\n    });\n});\n\nconst port = process.env.PORT || 3000;\nserver.listen(port, () =\u003e {\n    console.log(`Servidor WebSocket iniciado en el puerto ${port}`);\n});\n```\n\n### Ejemplo de cliente (HTML/JS)\n```html\n\u003cscript src=\"https://cdn.socket.io/4.7.2/socket.io.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    const socket = io('http://localhost:3000');\n\n    // Enviar mensaje al servidor\n    socket.emit('mensaje', 'Hola servidor!');\n\n    // Escuchar respuestas del servidor\n    socket.on('respuesta', (data) =\u003e {\n        console.log('Respuesta del servidor:', data);\n    });\n\u003c/script\u003e\n```\n\n## Estructura de eventos 📡\n| Evento       | Dirección     | Descripción                          |\n|--------------|---------------|--------------------------------------|\n| `connection` | Servidor      | Nuevo cliente conectado              |\n| `mensaje`    | Cliente → Servidor | Envío de mensajes al servidor    |\n| `respuesta`  | Servidor → Cliente | Respuesta del servidor al cliente |\n| `disconnect` | Servidor      | Cliente desconectado                 |\n\n## Configuración avanzada ⚙️\n**Cambiar puerto:**  \n```bash\nPORT=4000 node index.js\n```\n\n**Habilitar modo debug de Socket.IO:**  \n```bash\nDEBUG=socket.io* node index.js\n```\n\n## Tecnologías utilizadas 🛠️\n- Node.js (v18+)\n- Express.js\n- Socket.IO v4\n- CORS middleware\n\n## Contribuciones 🤝\n¡Las contribuciones son bienvenidas! Por favor:\n1. Haz fork del proyecto\n2. Crea una rama con tu feature (`git checkout -b feature/nueva-funcionalidad`)\n3. Haz commit de tus cambios (`git commit -m 'Add some feature'`)\n4. Push a la rama (`git push origin feature/nueva-funcionalidad`)\n5. Abre un Pull Request\n\n## Licencia 📄\nMIT License - Ver [LICENSE](LICENSE) para más detalles.\n\n---\n\n**Creado por [Alejandro Castillo Delgado](https://github.com/alejandro-castillo-delgado)**  \n[![Visitar Repositorio](https://img.shields.io/badge/GitHub-Repositorio-black?style=for-the-badge\u0026logo=github)](https://github.com/alejandro-castillo-delgado/websocket)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandro-castillo-delgado%2Fwebsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejandro-castillo-delgado%2Fwebsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandro-castillo-delgado%2Fwebsocket/lists"}