Skip to content

Commit ef25ef7

Browse files
committed
docs: update readmes
1 parent 4f7f06e commit ef25ef7

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

src/adapters/bun/readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ export default bunAdapter(compose(ws.handler, httpHandler), {
2626

2727
3. Refer to [this guide](https://crossws.unjs.io/guide/hooks) for the available hooks.
2828

29+
### Peer context
30+
31+
Every hook (except `upgrade`) receives a [peer](https://crossws.unjs.io/guide/peer) as its first argument.
32+
33+
Each peer has a `context` property that contains the Hattip context, which your Hattip middlewares can define new properties on.
34+
35+
The following properties are always available on `peer.context`:
36+
37+
- `url: URL` The URL that facilitated the WebSocket upgrade.
38+
- `env: (name: string) => string` A function to access environment variables in a platform-agnostic way.
39+
- `locals: Record<string, unknown>` A mutable object that can be used to store data for the duration of the WebSocket connection.
40+
- `platform: BunPlatformInfo`
41+
- `name: "bun"`
42+
- `server: Server` The Bun server instance.
43+
2944
### WebSocketAdapter API
3045

3146
The adapter returned by the `createWebSocketAdapter` function has the following properties:

src/adapters/cloudflare-workers/readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ export default {
2626

2727
3. Refer to [this guide](https://crossws.unjs.io/guide/hooks) for the available hooks.
2828

29+
### Peer context
30+
31+
Every hook (except `upgrade`) receives a [peer](https://crossws.unjs.io/guide/peer) as its first argument.
32+
33+
Each peer has a `context` property that contains the Hattip context, which your Hattip middlewares can define new properties on.
34+
35+
The following properties are always available on `peer.context`:
36+
37+
- `url: URL` The URL that facilitated the WebSocket upgrade.
38+
- `env: (name: string) => string` A function to access environment variables in a platform-agnostic way.
39+
- `locals: Record<string, unknown>` A mutable object that can be used to store data for the duration of the WebSocket connection.
40+
- `platform: CloudflareWorkersPlatformInfo`
41+
- `name: "cloudflare-workers"`
42+
- `env: unknown` [Bindings](https://developers.cloudflare.com/workers/configuration/bindings) for secrets, [environment variables](https://developers.cloudflare.com/workers/platform/environment-variables), and other resources like KV namespaces, etc.
43+
- `context: ExecutionContext` The Cloudflare Workers execution context.
44+
2945
### WebSocketAdapter API
3046

3147
The adapter returned by the `createWebSocketAdapter` function has the following properties:

src/adapters/deno/readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ Deno.serve(createServeHandler(compose(ws.handler, httpHandler)))
2424

2525
3. Refer to [this guide](https://crossws.unjs.io/guide/hooks) for the available hooks.
2626

27+
### Peer context
28+
29+
Every hook (except `upgrade`) receives a [peer](https://crossws.unjs.io/guide/peer) as its first argument.
30+
31+
Each peer has a `context` property that contains the Hattip context, which your Hattip middlewares can define new properties on.
32+
33+
The following properties are always available on `peer.context`:
34+
35+
- `url: URL` The URL that facilitated the WebSocket upgrade.
36+
- `env: (name: string) => string` A function to access environment variables in a platform-agnostic way.
37+
- `locals: Record<string, unknown>` A mutable object that can be used to store data for the duration of the WebSocket connection.
38+
- `platform: DenoPlatformInfo`
39+
- `name: "deno"`
40+
- `info: Deno.ServeInfo` The Deno serve info object.
41+
2742
### WebSocketAdapter API
2843

2944
The adapter returned by the `createWebSocketAdapter` function has the following properties:

src/adapters/node/readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ export default server
2727

2828
3. Refer to [this guide](https://crossws.unjs.io/guide/hooks) for the available hooks.
2929

30+
### Peer context
31+
32+
Every hook (except `upgrade`) receives a [peer](https://crossws.unjs.io/guide/peer) as its first argument.
33+
34+
Each peer has a `context` property that contains the Hattip context, which your Hattip middlewares can define new properties on.
35+
36+
The following properties are always available on `peer.context`:
37+
38+
- `url: URL` The URL that facilitated the WebSocket upgrade.
39+
- `env: (name: string) => string` A function to access environment variables in a platform-agnostic way.
40+
- `locals: Record<string, unknown>` A mutable object that can be used to store data for the duration of the WebSocket connection.
41+
- `platform: NodePlatformInfo`
42+
- `name: "node"`
43+
- `request: http.IncomingMessage` The Node.js HTTP request object.
44+
- `response: http.ServerResponse` The Node.js HTTP response object.
45+
3046
### WebSocketAdapter API
3147

3248
The adapter returned by the `createWebSocketAdapter` function has the following properties:

0 commit comments

Comments
 (0)