@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 +15 -0
- package/dist/adapter-Dh3UF0ot.d.mts +2163 -0
- package/dist/compiler.d.mts +1 -1
- package/dist/compiler.mjs +1 -1
- package/dist/express.d.mts +1 -1
- package/dist/express.mjs +4 -1
- package/dist/express.mjs.map +1 -1
- package/dist/fastify.d.mts +1 -1
- package/dist/fastify.mjs +4 -1
- package/dist/fastify.mjs.map +1 -1
- package/dist/hono.d.mts +1 -1
- package/dist/hono.mjs +38 -3
- package/dist/hono.mjs.map +1 -1
- package/dist/index.d.mts +3 -1117
- package/dist/index.mjs +263 -269
- package/dist/index.mjs.map +1 -1
- package/dist/{node-DnYv_AMI.mjs → node-DVEO_lrR.mjs} +5 -2
- package/dist/node-DVEO_lrR.mjs.map +1 -0
- package/dist/node.d.mts +1 -1
- package/dist/node.mjs +1 -1
- package/dist/{node-io-BkdRSQeg.mjs → upgrade-io-CdQG7pZg.mjs} +625 -27
- package/dist/upgrade-io-CdQG7pZg.mjs.map +1 -0
- package/package.json +4 -4
- package/src/adapter.ts +7 -0
- package/src/adapters/express.ts +4 -0
- package/src/adapters/fastify.ts +4 -0
- package/src/adapters/hono.ts +48 -2
- package/src/adapters/node-io.ts +8 -0
- package/src/adapters/node.ts +4 -0
- package/src/adapters/upgrade-io.ts +255 -0
- package/src/decorators.ts +1 -1
- package/src/index.ts +14 -0
- package/src/pipeline.ts +108 -2
- package/src/plugin-routes.ts +6 -0
- package/src/plugin.ts +197 -16
- package/src/upgrade.ts +341 -0
- package/dist/adapter-DmhQGqAR.d.mts +0 -895
- package/dist/node-DnYv_AMI.mjs.map +0 -1
- package/dist/node-io-BkdRSQeg.mjs.map +0 -1
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,
|