Skip to content

PatrickHollweck/SRocket

Repository files navigation

SRocket

A Socket.IO Framework focusing on being type-safe.

TRAVISCI Status FOSSA Status Known Vulnerabilities CodeFactor


📚 Docs

💨 Quickstart

📝 Source Code


Built with ❤︎ by Patrick Hollweck

Sneak Peak

Server

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"));

Client

const socket = io.connect("http://localhost:5555");

socket.emit("greet", { name: "Patrick" }, console.log);
>> "Hello, Patrick"

Interested? Visit the docs