feat(sidecar)!: stream request bodies and add route middleware#96
Draft
haveyaseen wants to merge 4 commits into
Draft
feat(sidecar)!: stream request bodies and add route middleware#96haveyaseen wants to merge 4 commits into
haveyaseen wants to merge 4 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 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.