@kingworldjs/websocket
v0.0.0-experimental.7
Published
A plugin for kingworld that add support for websocket
Downloads
2
Readme
@kingworldjs/websocket
A plugin for kingworld that add support for websocket.
Installation
bun add @kingworldjs/websocket
Example
import { KingWorld } from 'kingworld'
import { websocket } from '@kingworldjs/websocket'
const app = new KingWorld()
.use(websocket())
.ws('/ws', {
message(ws, message) {
ws.message('Hi')
}
})
.listen(8080)
API
This plugin extends KingWorld
class with ws
method.
ws
Register Websocket to route
Parameters:
ws(
path: string,
options: Partial<WebSocketHandler<Context>> & {
schema?: Schema
beforeHandle?: WithArray<HookHandler>
headers?:
| HeadersInit
| (Context) => HeadersInt
}
): this