TM9657 / generic-socket-rooms

Generic, scalable websocket server that should support most use-cases. We are using Elixir / Phoenix to use the language specific features and mitigate the use for Redis adapters (KISS) for scaling across multiple instances.

Home Page:https://tm9657.de

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generic Socket Rooms

Generic, scalable websocket server that should support most use-cases. It comes with a client library that can be installed via

npm install @tm9657/socket-client

We are using Elixir / Phoenix to use the language specific features and mitigate the use for Redis adapters (KISS) for scaling across multiple instances.

Access to rooms is managed via JWT. The server is able to return signed JWT based on your API-Key. However you can also use our JWK Store (serverless) to implement rolling keys or sign the tokens in other services.

The token should have the following claims:

{
  "sub": "user id",
  "room_name": "the room this token gives access to",
  "type": "room | signaling"
}

Generally the following rooms are possible: room:*, pm:<sub> and signaling:*

API

> GET "/v1/api/jwk" - returns the current public key (remove this if you use symmetric keys)
> POST "/v1/api/auth/jwk_sign" - signs a new JWT that is valid for 30 days (REQUIRES API-KEY)

body: {
	"room_name": "room id (without prefix room or signaling)",
	"sub": "<user-id>",
	"type": "room|signaling"
}
> GET "/v1/api/verify" checks the auth header token for validity

Development Server:

  • Run mix setup to install and setup dependencies
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Deploy to Fly

To deploy to fly use the following commands:

  1. bun run fly
  2. adjust your newly created fly.toml
  3. bun run deploy

Provided by TM9657 GmbH with ❤️

Check out some of our products:

  • Kwirk.io (Text Editor with AI integration, privacy focus and offline support)

About

Generic, scalable websocket server that should support most use-cases. We are using Elixir / Phoenix to use the language specific features and mitigate the use for Redis adapters (KISS) for scaling across multiple instances.

https://tm9657.de

License:Other


Languages

Language:TypeScript 51.9%Language:Elixir 39.3%Language:JavaScript 4.7%Language:Dockerfile 2.2%Language:HTML 0.8%Language:CSS 0.6%Language:Shell 0.4%Language:Batchfile 0.0%