forked from cloudflare/workers-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable hyperdrive bindings in
getPlatformProxy
(cloudflare#6612)
* fix: fix hyperdrive bindings not getting proxied by miniflare * skip hyperdrive e2e test in windows
- Loading branch information
1 parent
9ca372b
commit 6471090
Showing
18 changed files
with
291 additions
and
74 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,42 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: Add hyperdrive binding support in `getPlatformProxy` | ||
|
||
example: | ||
|
||
```toml | ||
# wrangler.toml | ||
[[hyperdrive]] | ||
binding = "MY_HYPERDRIVE" | ||
id = "000000000000000000000000000000000" | ||
localConnectionString = "postgres://user:pass@127.0.0.1:1234/db" | ||
``` | ||
|
||
```js | ||
// index.mjs | ||
|
||
import postgres from "postgres"; | ||
import { getPlatformProxy } from "wrangler"; | ||
|
||
const { env, dispose } = await getPlatformProxy(); | ||
|
||
try { | ||
const sql = postgres( | ||
// Note: connectionString points to `postgres://user:pass@127.0.0.1:1234/db` not to the actual hyperdrive | ||
// connection string, for more details see the explanation below | ||
env.MY_HYPERDRIVE.connectionString | ||
); | ||
const results = await sql`SELECT * FROM pg_tables`; | ||
await sql.end(); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
|
||
await dispose(); | ||
``` | ||
|
||
Note: the returned binding values are no-op/passthrough that can be used inside node.js, meaning | ||
that besides direct connections via the `connect` methods, all the other values point to the | ||
same db connection specified in the user configuration |
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,9 @@ | ||
--- | ||
"miniflare": patch | ||
--- | ||
|
||
fix: add hyperdrive bindings support in `getBindings` | ||
|
||
Note: the returned binding values are no-op/passthrough that can be used inside node.js, meaning | ||
that besides direct connections via the `connect` methods, all the other values point to the | ||
same db connection specified in the user configuration |
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
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
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
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
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
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
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
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
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
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
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
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
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.