A Socket.IO Framework focusing on being type-safe.
Built with ❤︎ by Patrick Hollweck
import { SRocket, SocketController, Controller, SocketRoute SEvent, V } from "srocket";
@SocketController()
class UserController extends Controller
{
greet(event: SEvent) {
const data = event.request.validate(
V.type({
name: V.string,
}
);
event.response
.withData({
greeting: `Hey, ${data.name}`,
})
.acknowledge();
}
}
SRocket.fromPort(5555)
.controllers(UserController)
.listen(() => console.log("SRocket listening at http://localhost:5555"));
const socket = io.connect("http://localhost:5555");
socket.emit("greet", { name: "Patrick" }, console.log);
>> "Hello, Patrick"
Interested? Visit the docs