Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/patrickhollweck/srocket

A socket.io framework focusing on type-safety
https://github.com/patrickhollweck/srocket

framework nodejs socket-io typescript typescript-library web websocket

Last synced: 18 days ago
JSON representation

A socket.io framework focusing on type-safety

Awesome Lists containing this project

README

        

# SRocket

A [Socket.IO](https://socket.io/docs) Framework focusing on being **type-safe**.

[![TRAVISCI Status](https://travis-ci.org/PatrickHollweck/SRocket.svg?branch=master)](https://travis-ci.org/PatrickHollweck/SRocket)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FPatrickHollweck%2FSRocket.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FPatrickHollweck%2FSRocket?ref=badge_shield)
[![Known Vulnerabilities](https://snyk.io/test/github/PatrickHollweck/SRocket/badge.svg)](https://snyk.io/test/github/PatrickHollweck/SRocket)
[![CodeFactor](https://www.codefactor.io/repository/github/patrickhollweck/srocket/badge)](https://www.codefactor.io/repository/github/patrickhollweck/srocket)


[📚 Docs](https://patrickhollweck.github.io/SRocket/#/)

[💨 Quickstart](https://patrickhollweck.github.io/SRocket/#/quickstart)

[📝 Source Code](https://github.com/PatrickHollweck/srocket)


Built with ❤︎ by Patrick Hollweck

## Sneak Peak

### Server

```ts
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

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

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

Interested? Visit the [docs](https://patrickhollweck.github.io/SRocket/#/)