Skip to content

Commit ec9c078

Browse files
committed
chore(docs): update README.md
1 parent 2bee92f commit ec9c078

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Bun WebSocket Router
22

3-
A type-safe WebSocket router for Bun with Zod-based message validation. Route WebSocket messages to handlers based on message type with full TypeScript support.
3+
Tired of wrestling WebSocket connections like a tangled mess of holiday lights? `bun-ws-router` is here to bring order to the chaos! It's a type-safe WebSocket router for Bun, powered by Zod, making your real-time message handling smoother than a fresh jar of peanut butter. Route WebSocket messages to handlers based on message type with full TypeScript support.
44

55
### Key Features
66

7-
- **Type-safe messaging**: Built-in validation using Zod schemas
8-
- **Simple API**: Intuitive routing system for WebSocket messages
9-
- **Performance**: Leverages Bun's native WebSocket implementation
10-
- **Flexible**: Works with any Bun server setup, including Hono
11-
- **Room support**: Easily group clients and broadcast messages
12-
- **Lightweight**: Minimal dependencies for fast startup
7+
- 🔒 **Type-safe messaging**: Built-in validation using Zod schemas (catch errors before they bite!)
8+
-**Simple API**: Intuitive routing system for WebSocket messages (so easy, your cat could _almost_ use it)
9+
- 🚀 **Performance**: Leverages Bun's native WebSocket implementation (it's fast, like, _really_ fast)
10+
- 🧩 **Flexible**: Works with any Bun server setup, including Hono
11+
- 🪶 **Lightweight**: Minimal dependencies for fast startup
1312

1413
Perfect for real-time applications like chat systems, live dashboards, multiplayer games, and notification services.
1514

@@ -105,6 +104,8 @@ Bun.serve({
105104

106105
The `verifyIdToken` function is a placeholder for your authentication logic which could use user ID token verification from `firebase-admin` or any other authentication library.
107106

107+
By verifying the user _before_ the WebSocket connection is fully established and passing the `user` data, you ensure that only authenticated users can connect, and you have their info ready to use in your `onOpen`, `onMessage`, and `onClose` handlers without needing to ask again. Secure _and_ convenient!
108+
108109
## How to define message types
109110

110111
You can define message types using the `messageSchema` function from `bun-ws-router`. This function takes a message type name such as `JOIN_ROOM`, `SEND_MESSAGE` etc. and a Zod schema for the message payload. The following example demonstrates how to define message types for a chat application.
@@ -180,7 +181,7 @@ ws.onClose((c) => {
180181
});
181182
```
182183

183-
**Note:** The `c.send(...)` function sends a message back to the _current_ client.
184+
**Important Note:** The `c.send(...)` function sends a message back _only_ to the client that sent the original message. For broadcasting to rooms or multiple clients, you'll need to implement your own logic (we handle the routing, you handle the party!).
184185

185186
## How to compose routes
186187

@@ -201,7 +202,7 @@ Where `chatRoutes` and `notificationRoutes` are other router instances defined i
201202

202203
## Support
203204

204-
Feel free to discuss any issues or suggestions on our [Discord](https://discord.com/invite/bSsv7XM) channel. We welcome contributions and feedback from the community.
205+
Got questions? Hit a snag? Or just want to share your awesome WebSocket creation? Find us on [Discord](https://discord.com/invite/bSsv7XM). We promise we don't bite (usually 😉).
205206

206207
## Backers
207208

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bun-ws-router",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "A simple and efficient WebSocket router for Bun with Zod-based message validation.",
55
"keywords": [
66
"bun",

0 commit comments

Comments
 (0)