@znight/http 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1660,6 +1660,21 @@ export class StatusPlugin implements Plugin, PluginHttpRoutes {
1660
1660
  `drainTimeoutMs`. The drain waits for a returned promise too (within `drainTimeoutMs`); a failure
1661
1661
  is logged, never thrown.
1662
1662
 
1663
+ ### Upgrade routes
1664
+
1665
+ <!-- TODO(api): verify against implementation -->
1666
+
1667
+ A plugin accepting WebSocket connections (`@znight/websocket`, RFC 0003, in progress) implements
1668
+ `PluginHttpUpgrades`: `httpUpgrades(context)` returns `{ routes, bunWebSocket? }`, called once in
1669
+ `HttpPlugin.onBootstrap` after `httpRoutes()`. Each `PluginUpgradeRoute` has a `path`, a `name`,
1670
+ optional `meta`, `guards`, `timeoutMs` and `precheck`, and an `accept(ctx, upgrade)` that completes
1671
+ the handshake on `upgrade.native` (a `node:http` socket, a `Bun.serve()` request or an in-memory
1672
+ peer) and calls `upgrade.hold(closed)`. Once `timeoutMs` answered `408`, `upgrade.expired` is
1673
+ `true` and `accept` must not complete the handshake. The handshake runs the request pipeline (hook, request scope,
1674
+ global and route guards); a refusal is an HTTP response, and a plain `GET` of an upgrade path answers
1675
+ `426`. Every built-in adapter supports upgrades; `HttpPlugin.upgradeInMemory()` runs a handshake
1676
+ without socket. Applications without upgrade routes pay nothing.
1677
+
1663
1678
  ## Adapters
1664
1679
 
1665
1680
  All adapters share the same pipeline, so responses (bodies, errors, statuses, HEAD, 404/405,