1.0.0 • Published 4 months ago
sockster v1.0.0
🔌 sockster
A lightweight, blazing-fast WebSocket server that broadcasts all events to connected clients. Perfect for real-time applications, chat systems, or any project requiring WebSocket functionality.
✨ Features
- 🎯 Simple to use - Just start the server and it broadcasts all events
- 🔄 Universal Broadcasting - Every event is automatically broadcast to all connected clients
- 🛡️ Production Ready - Built-in CORS, error handling, and health checks
- 🐳 Docker Support - Ready-to-use Docker images with environment variable support
- 📦 Easy Deployment - Deploy anywhere with comprehensive environment variable support
- 🔌 Socket.IO Powered - Built on the reliable Socket.IO framework
🚀 Quick Start
NPM
# Install the package
npm install sockster
# Create an .env file
echo "SOCKSTER_PORT=4000\nSOCKSTER_ORIGIN_URL=http://localhost:3000" > .env
# Start the server
npx sockster
Docker
# Pull and run
docker run -p 4000:4000 -e SOCKSTER_ORIGIN_URL=http://localhost:3000 djurnamn/sockster
Docker Compose
services:
sockster:
image: djurnamn/sockster:latest
ports:
- "${SOCKSTER_PORT:-4000}:4000"
environment:
- SOCKSTER_PORT=4000
- SOCKSTER_ORIGIN_URL=http://localhost:3000
🔌 Client Connection
Connect from your frontend application (JavaScript/TypeScript):
import { io } from "socket.io-client";
const socket = io("http://localhost:4000");
// Listen for connection
socket.on("connect", () => {
console.log("Connected to sockster! 🎉");
});
// Send an event
socket.emit("my-event", { data: "Hello!" });
// Listen for events
socket.on("my-event", (data) => {
console.log("Received:", data);
});
🌍 Production Deployment
Railway (Recommended)
Install Railway CLI:
npm i -g @railway/cli
Deploy to Railway:
railway login railway init railway up
Set environment variables:
railway variables add SOCKSTER_ORIGIN_URL=https://your-frontend-app.com
Get your WebSocket URL:
railway domain
Update your client configuration:
const socket = io("wss://your-app-name.railway.app");
⚙️ Environment Variables
Variable | Description | Default |
---|---|---|
SOCKSTER_PORT | Port to run the server on | 4000 |
SOCKSTER_ORIGIN_URL | Allowed CORS origin | - |
🛠️ Development
# Clone the repository
git clone https://github.com/djurnamn/sockster.git
# Install dependencies
pnpm install
# Start the server
pnpm start
🤝 Contributing
Contributions are welcome! Feel free to:
- 🐛 Report bugs
- 💡 Suggest features
- 🔧 Submit pull requests
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
Built with:
🌟 Star Us!
If you find sockster helpful, please consider giving it a star ⭐️ It helps others discover the project!
1.0.0
4 months ago