-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for wrapped bindings (#4348)
This change adds a new `wrappedBindings` worker option for configuring `workerd`'s wrapped bindings. These allow custom bindings to be written as JavaScript functions accepting an `env` parameter of "inner bindings" and returning the value to bind. The `wrappedBindings` option maps binding names to designators. The worker defined by the designator is used for the wrapped binding's source and inner bindings. The worker becomes un-routable, and cannot be used for service or Durable Object bindings. Using a worker allows us to piggyback on all of Miniflare's existing bindings. For example, the wrapped binding worker can declare a function-valued service binding for accessing Node.js state. JSON bindings can be specified with the designator to override specific bindings.
- Loading branch information
Showing
10 changed files
with
925 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"miniflare": minor | ||
--- | ||
|
||
feat: add support for wrapped bindings | ||
|
||
This change adds a new `wrappedBindings` worker option for configuring | ||
`workerd`'s [wrapped bindings](https://github.com/cloudflare/workerd/blob/bfcef2d850514c569c039cb84c43bc046af4ffb9/src/workerd/server/workerd.capnp#L469-L487). | ||
These allow custom bindings to be written as JavaScript functions accepting an | ||
`env` parameter of "inner bindings" and returning the value to bind. For more | ||
details, refer to the [API docs](https://github.com/cloudflare/workers-sdk/blob/main/packages/miniflare/README.md#core). |
This file contains 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
Oops, something went wrong.