@lunora/hyperdrive 1.0.0-alpha.187 → 1.0.0-alpha.189
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/README.md +13 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -67,20 +67,26 @@ pnpm add mysql2 # mysql2 → fromMysql2
|
|
|
67
67
|
|
|
68
68
|
## Setup
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Importing `@lunora/hyperdrive` (or reading `ctx.sql`) is enough: `lunora dev` and `lunora deploy` add a `HYPERDRIVE` binding to `wrangler.jsonc` for you, with a placeholder `id`.
|
|
71
|
+
|
|
72
|
+
- **In dev**, `ctx.sql` runs against an embedded Postgres ([PGlite](https://pglite.dev)) with its data in `.wrangler/state/lunora-pglite`, under `lunora dev`, `vite dev` and `vite preview`. It needs two optional packages (`lunora dev` says so when they are missing):
|
|
71
73
|
|
|
72
74
|
```sh
|
|
73
|
-
|
|
75
|
+
pnpm add -D @electric-sql/pglite @electric-sql/pglite-socket
|
|
74
76
|
```
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
To use your own database, set `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE` (the last part is the binding name) or `localConnectionString` on the binding. The embedded database speaks PostgreSQL: a project whose only SQL driver is `mysql2` gets a warning and must set that variable to a local MySQL of its own. A plain `wrangler dev` that Lunora does not start has no embedded database either: set the variable (or `localConnectionString`) there too.
|
|
79
|
+
|
|
80
|
+
- **On deploy**, set the origin's connection string and a token that may edit Hyperdrive (`CLOUDFLARE_API_TOKEN` with _Hyperdrive: Edit_, plus `CLOUDFLARE_ACCOUNT_ID`):
|
|
77
81
|
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id from step 1>", "localConnectionString": "postgres://user:pass@localhost:5432/db" }], // gitleaks:allow -- placeholder, not a real secret
|
|
81
|
-
}
|
|
82
|
+
```sh
|
|
83
|
+
LUNORA_HYPERDRIVE_URL="postgres://user:pass@host:5432/db" lunora deploy # gitleaks:allow -- placeholder, not a real secret
|
|
82
84
|
```
|
|
83
85
|
|
|
86
|
+
The variable is `LUNORA_<BINDING>_URL`. Lunora creates a config named after the deployed Worker (so `--env staging` gets its own) and the binding, or reuses one with that name that reaches the same database, and writes its `id` into `wrangler.jsonc`. A same-named config for another database stops the deploy. The connection string is only sent to Cloudflare, never written to a file or logged.
|
|
87
|
+
|
|
88
|
+
Prefer to manage it yourself? Run `wrangler hyperdrive create my-db --connection-string=...` and put the `id` in the binding; Lunora then leaves it alone.
|
|
89
|
+
|
|
84
90
|
## Usage
|
|
85
91
|
|
|
86
92
|
`ctx.sql` is wired by codegen onto `ActionCtx` only — never `QueryCtx`/`MutationCtx`, and it is `readonly`, so it is built once at the app level rather than assigned in a handler. Codegen emits a `sql` config thunk for it (`createHyperdrive` returns connection info; only you know which driver wraps it):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/hyperdrive",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.189",
|
|
4
4
|
"description": "Bring-your-own Postgres/MySQL for Lunora via Cloudflare Hyperdrive: a driver-agnostic, action-only ctx.sql",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
54
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
55
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
56
|
-
"@lunora/sql-store": "1.0.0-alpha.
|
|
54
|
+
"@lunora/platform": "1.0.0-alpha.70",
|
|
55
|
+
"@lunora/shard-engine": "1.0.0-alpha.143",
|
|
56
|
+
"@lunora/sql-store": "1.0.0-alpha.192",
|
|
57
57
|
"drizzle-orm": "^0.45.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|