@forinda/kickjs-ws
v1.2.13
Published
WebSocket support with decorators, namespaces, rooms, and DI integration for KickJS
Maintainers
Readme
@forinda/kickjs-ws
WebSocket support with decorators, namespaces, rooms, and DI integration for KickJS.
Install
# Using the KickJS CLI (recommended — auto-installs peer dependencies)
kick add ws
# Manual install
pnpm add @forinda/kickjs-ws wsFeatures
WsAdapter— lifecycle adapter that attaches a WebSocket server to your app- Decorator-driven handlers:
@WsController,@OnConnect,@OnDisconnect,@OnMessage,@OnError WsContext— typed context for WebSocket handlersRoomManager— built-in room/namespace management
Quick Example
import { WsAdapter, WsController, OnConnect, OnMessage, WsContext } from '@forinda/kickjs-ws'
@WsController('/chat')
class ChatHandler {
@OnConnect()
onConnect(ctx: WsContext) {
console.log('Client connected')
}
@OnMessage('message')
onMessage(ctx: WsContext) {
ctx.broadcast(ctx.data)
}
}
// In bootstrap
bootstrap({
modules,
adapters: [new WsAdapter()],
})Documentation
License
MIT
