{"_id":"@affectively/websocket-server","_rev":"2-10fad8dc03590ec888f0bb99cd0b5bd5","name":"@affectively/websocket-server","dist-tags":{"latest":"5.0.0"},"versions":{"5.0.0":{"name":"@affectively/websocket-server","version":"5.0.0","_id":"@affectively/websocket-server@5.0.0","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"dist":{"shasum":"95c0a5c871ce3bbe40fee49ae50b7afd27f5cf15","tarball":"https://registry.npmjs.org/@affectively/websocket-server/-/websocket-server-5.0.0.tgz","fileCount":7,"integrity":"sha512-W8YTe4YN8iv4+ywrP7VvaY2FK4jrAG5vpxrSm4PoeV3pt4gV+BE4jwGYncPOBhQrR/vSD00Lb+m1crWGKXFqGg==","signatures":[{"sig":"MEYCIQC+LIYhLheHfE/gsd6p9gdXlKb0M4yIUZ4clokx/kLyawIhAOoBtvAKUY3AZJpgqEBsPc6t9BAEVtSisOwhj2Pjqyg9","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16644},"main":"src/index.ts","type":"module","gitHead":"ae54b0df6ac98ed86b037accafa16cf218dda541","scripts":{"dev":"bun run src/index.ts","build":"tsc --noEmit","start":"bun run src/index.ts","type-check":"tsc --noEmit"},"_npmUser":{"name":"buley","email":"buley@outlook.com"},"_npmVersion":"11.8.0","description":"WebSocket server for Twilio Media Streams (transcription and Voice Shield)","directories":{},"_nodeVersion":"25.5.0","dependencies":{"ws":"^8.18.0","@affectively/shared-ui":"workspace:*","@affectively/shared-utils":"workspace:*"},"_hasShrinkwrap":false,"devDependencies":{"@types/ws":"^8.5.13","typescript":"^5.6.3","@types/node":"^20.14.0"},"_npmOperationalInternal":{"tmp":"tmp/websocket-server_5.0.0_1773155944623_0.8616161513391742","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package is deprecated and no longer supported. Do not use."}},"time":{"created":"2026-03-10T15:19:04.514Z","modified":"2026-03-27T20:05:11.176Z","5.0.0":"2026-03-10T15:19:04.792Z"},"description":"WebSocket server for Twilio Media Streams (transcription and Voice Shield)","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"readme":"# Twilio Media Streams WebSocket Server\n\nStandalone WebSocket server for handling Twilio Media Streams connections for transcription and Voice Shield.\n\n## Overview\n\nThis server accepts WebSocket connections from Twilio Media Streams and routes messages to the appropriate handlers in the Next.js web app:\n- **Transcription streams** → `/api/twilio/media-streams/transcription`\n- **Voice Shield streams** → `/api/twilio/media-streams`\n\n## Architecture\n\n```text\nTwilio Media Streams\n    ↓\nWebSocket Server (this service)\n    ↓\nHTTP POST to Next.js API endpoints\n    ↓\nHandler functions process messages\n```text\n\n## Deployment\n\n### Railway\n\n1. Create new Railway service\n2. Connect to this directory (`apps/websocket-server`)\n3. Set environment variables (see below)\n4. Deploy\n\n### Render\n\n1. Create new Web Service\n2. Set build command: `bun install`\n3. Set start command: `bun run start`\n4. Set environment variables\n\n### VPS/Self-Hosted\n\n1. Install dependencies: `bun install`\n2. Set environment variables\n3. Run: `bun run start`\n4. Use PM2 or systemd for process management\n\n## Environment Variables\n\n### Required\n\n```bash\n# Port for WebSocket server (default: 8080)\nPORT=8080\n\n# Next.js API base URL\nNEXT_PUBLIC_BASE_URL=https://affectively.ai\n# OR\nTRANSCRIPTION_ENDPOINT_URL=https://affectively.ai/api/twilio/media-streams/transcription\nVOICE_SHIELD_ENDPOINT_URL=https://affectively.ai/api/twilio/media-streams\n```text\n\n### Optional\n\n```bash\n# Logging level\nLOG_LEVEL=info\n```text\n\n## WebSocket URLs\n\nAfter deployment, configure these URLs in your main app:\n\n```bash\n# In web-app environment variables:\nTRANSCRIPTION_WEBSOCKET_URL=wss://your-websocket-server.railway.app/transcription\nVOICE_SHIELD_WEBSOCKET_URL=wss://your-websocket-server.railway.app/voice-shield\n```text\n\n## Health Check\n\nThe server exposes a health check endpoint:\n\n```bash\nGET https://your-websocket-server.railway.app/health\n```text\n\nReturns:\n```json\n{\n  \"status\": \"ok\",\n  \"service\": \"Twilio Media Streams WebSocket Server\",\n  \"connections\": 5,\n  \"timestamp\": \"2024-01-01T12:00:00Z\"\n}\n```text\n\n## Message Routing\n\nThe server automatically routes messages based on the `purpose` parameter:\n\n- `purpose: 'transcription'` → Transcription handler\n- No purpose or other → Voice Shield handler\n\n## Development\n\n```bash\n# Install dependencies\nbun install\n\n# Run development server\nbun run dev\n\n# Type check\nbun run type-check\n```\n\n## Production Considerations\n\n1. **Scaling**: Use a load balancer for multiple instances\n2. **State**: Consider Redis for distributed session management\n3. **Monitoring**: Add metrics and logging\n4. **Security**: Verify Twilio signatures (if needed)\n5. **Error Handling**: Implement retry logic for API calls\n\n## Related Documentation\n\n- `docs/MEDIA_STREAMS_TRANSCRIPTION_IMPLEMENTATION.md` - Implementation details\n- `docs/TWILIO_MEDIA_STREAMS_STATUS.md` - Deployment status\n- `docs/VOICE_SHIELD.md` - Voice Shield documentation\n\n\nLast Updated: 2026-01-31\n\n## Sub-Directories\n\n- **[Src](./src)**\n","readmeFilename":"README.md"}