@godspeedai/cognate-protocol-connect-bun 0.8.0 → 0.9.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/package.json +3 -3
- package/src/EGM.md +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@godspeedai/cognate-protocol-connect-bun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Serves the Connect runtime service on Bun.serve with authentication, payload limits, and deadlines; provides a fetch transport.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
".": "./src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@godspeedai/cognate-protocol-connect": "^0.
|
|
26
|
-
"@godspeedai/cognate-runtime-api": "^0.
|
|
25
|
+
"@godspeedai/cognate-protocol-connect": "^0.9.1",
|
|
26
|
+
"@godspeedai/cognate-runtime-api": "^0.9.1",
|
|
27
27
|
"@connectrpc/connect": "2.2.0",
|
|
28
28
|
"@connectrpc/connect-web": "2.2.0"
|
|
29
29
|
},
|
package/src/EGM.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# protocol-connect-bun source
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Serves `RuntimeService` on `Bun.serve` with authentication, payload limits, and deadlines, and provides a fetch transport (package description; [package.json:description]). Because there is no first-party Bun Connect adapter, the module indexes a `ConnectRouter`'s universal handlers by request path and bridges each through `createFetchHandler` [src/index.ts:createConnectFetchHandler]. The package is a single module [package.json:exports].
|
|
5
|
+
|
|
6
|
+
## Interface
|
|
7
|
+
- `serveRuntime(options)` — returns `RuntimeServer` (`url`, `stop`) [src/index.ts:serveRuntime]
|
|
8
|
+
- `ServeOptions` — `service`, `authenticate`, `port`, `hostname`, `limits` [src/index.ts:ServeOptions]
|
|
9
|
+
- `RuntimeServer` [src/index.ts:RuntimeServer]
|
|
10
|
+
- `connectTransport(baseUrl, options?)` — fetch-based Connect transport with `cache: "no-store"` [src/index.ts:connectTransport]
|
|
11
|
+
- `devTokenAuthenticator(headers)` and `devToken(caller)` — test/dev `Bearer <tenant>:<principalId>` [src/index.ts:devTokenAuthenticator]
|
|
12
|
+
|
|
13
|
+
## Invariants
|
|
14
|
+
- HTTP/1.1 only: unary plus server streaming (DEBT-004) [src/index.ts:1]
|
|
15
|
+
- A declared `content-length` above `maxBodyBytes` (default 1 048 576) is rejected as `resource_exhausted` with HTTP 429 before routing [src/index.ts:serveRuntime]
|
|
16
|
+
- When the client sends no `Connect-Timeout-Ms`, a `defaultDeadlineMs` (default 30 000) header is injected [src/index.ts:serveRuntime]
|
|
17
|
+
- `maxJsonDepth` (default 32) is passed to `registerRuntimeService` for `invalid_argument` rejection [src/index.ts:serveRuntime]
|
|
18
|
+
- Every response carries `cache-control: no-store` because Bun's fetch caches identical unary POST responses (DEBT-027) [src/index.ts:serveRuntime]
|
|
19
|
+
- Unknown paths answer 404 from the bridge rather than reaching the service [src/index.ts:createConnectFetchHandler]
|
|
20
|
+
- `devTokenAuthenticator` accepts only `Bearer` with exactly one colon and returns `undefined` otherwise; it is documented as not for production use [src/index.ts:devTokenAuthenticator]
|
|
21
|
+
|
|
22
|
+
## Side Effects
|
|
23
|
+
- Binds a listening socket on `port` (default 0, i.e. an ephemeral port) and `hostname` via `Bun.serve` [src/index.ts:serveRuntime]
|
|
24
|
+
- `stop()` calls `server.stop(true)` to force-close connections [src/index.ts:serveRuntime]
|
|
25
|
+
- Outbound fetches from `connectTransport` with `cache: "no-store"` [src/index.ts:connectTransport]
|
|
26
|
+
|
|
27
|
+
## Verification
|
|
28
|
+
- Run: `cd packages/protocol-connect-bun && bun test`
|