feat(sidecar)!: stream request bodies and add route middleware#96
feat(sidecar)!: stream request bodies and add route middleware#96haveyaseen wants to merge 5 commits into
Conversation
…eware
Add createRouteToForstMiddleware with route-request-stream JSON (prefix + streamed
base64 body + suffix), invokeFunctionRawWithReadableBody, and split ForstSidecar
into forst-sidecar; document and test the flow.
BREAKING CHANGE: pipeInvokeRawStream(packageName, functionName, body, destination) now
takes body: ReadableStream<Uint8Array> instead of args: unknown[]. Build the stream
from JSON.stringify([args]) or from createInvokeRawJsonBodyReadable for Express.
Example:
```typescript
import { Readable } from "node:stream";
const body = Readable.toWeb(nodeReadable) as ReadableStream<Uint8Array>;
await client.pipeInvokeRawStream("main", "StreamFn", body, res);
```
docs: rewrite root README for sidecar-first positioning
Reframe intro, comparisons, migration walkthrough, and package pointers around Node +
sidecar adoption.
refactor(devserver): extract dev HTTP server into internal/devserver
Move the dev server out of forst/cmd/forst into forst/internal/devserver: dedicated
handlers (health, version, functions, invoke, invoke/raw), shared response helpers,
invoke execution, and tests. Drop the old dev_server_http* surface from cmd in favor
of the internal package and slimmer runtime wiring.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… deps Wire Express + createRouteToForstMiddleware against a stub dev server (connect mode, GET /health + POST /invoke/raw) to assert full routed request fidelity (session-style headers, query, body) and mirrored HTTP response; cover streaming passthrough. Extend unit tests for mapRequest header injection and next(err) on invoke failure. Pin express@^4 and @types/express@^4 under devDependencies so Bun tests run (Express 5 router currently breaks under Bun); peer remains express ^5.
… sidecar)
Add `forst/gateway` (`GatewayRequest` / `GatewayResponse`, constructors, `ValidateGatewayResultJSON`).
Executor builds temp modules against the SDK (`replace forst`), encodes `Ok` gateway values to §12 JSON and maps executor failure JSON to `success: false` + `error`. Discovery sets `isGateway` from `GatewayRequest`→`GatewayResponse` signatures. Dev server bumps `HTTPContractVersion` to `2` and rejects malformed gateway `result` payloads before responding. TypeScript emit maps `gateway.*` qualified names to `@forst/sidecar` wire types; Go workspace resolution supports `forst/gateway` from example roots. Includes gateway example under `examples/in/gateway`, golden JSON fixtures, and RFC/docs updates.
BREAKING CHANGE: `@forst/sidecar` v1.0.0 removes `continue` / `reqPatch` / `ForstRoutedContinue`; gateway success `invoke` `result` must use `kind: "answer"` or `kind: "pass"` (`request` for Express merge). `FORST_DEV_HTTPTRACT_VERSION` is now `"2"` (must match `forst dev`).
Example:
```forst
import "forst/gateway"
func Hello(req gateway.GatewayRequest): Result(gateway.GatewayResponse, Error) {
return gateway.Plain200Text("hello")
}
```
…FI in goload Add `forst/gateway` entry points: `StdlibImportPath`, `IsGatewayHandlerSignature`, `TempModuleNeedsGatewayImport`, `ValidateSuccessResultIfGateway`, `TypeScriptEmitType`, plus tests. Wire discovery, executor temp `main` imports, devserver invoke validation, and TS type mapping through those helpers instead of duplicated strings and logic. Introduce `goload.IsMergeStdlibUserDefinedImport` (delegating to `gateway.StdlibImportPath`) so `go_interop` maps merge-path named Go types to Forst `UserDefined` without importing `forst/gateway` directly. Example: ```go // Discovery / devserver / codegen delegate to gateway package gateway.ValidateSuccessResultIfGateway(isGateway, execOk, resultRaw) goload.IsMergeStdlibUserDefinedImport(pkg.Path()) // go/types FFI classification ```
Record TypeScript client architecture decisions (FR-IR-1 through FR-ECO-1, SC-WIRE-2): IR as semantic source of truth, three-layer stack, generated client runtime integration, ecosystem codegen from IR, and IR-driven production protobuf wire. Index new RFCs in typescript-client and sidecar READMEs. Add adoption notes for first-use-case evaluation, Go interop audit, merged-statement coverage plan, and HTTP/DB/config porting friction.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Add createRouteToForstMiddleware with route-request-stream JSON (prefix + streamed base64 body + suffix), invokeFunctionRawWithReadableBody, and split ForstSidecar into forst-sidecar; document and test the flow.
BREAKING CHANGE: pipeInvokeRawStream(packageName, functionName, body, destination) now takes body: ReadableStream instead of args: unknown[]. Build the stream from JSON.stringify([args]) or from createInvokeRawJsonBodyReadable for Express.
Example:
docs: rewrite root README for sidecar-first positioning
Reframe intro, comparisons, migration walkthrough, and package pointers around Node + sidecar adoption.
refactor(devserver): extract dev HTTP server into internal/devserver
Move the dev server out of forst/cmd/forst into forst/internal/devserver: dedicated handlers (health, version, functions, invoke, invoke/raw), shared response helpers, invoke execution, and tests. Drop the old dev_server_http* surface from cmd in favor of the internal package and slimmer runtime wiring.