@quickback-dev/cli 0.72.10 → 0.72.11
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/dist/index.js
CHANGED
|
@@ -120,21 +120,28 @@ This means:
|
|
|
120
120
|
|
|
121
121
|
## How limits compile
|
|
122
122
|
|
|
123
|
-
The compiler walks every resource, collects unique `(limit, period)` tuples, and emits one Cloudflare binding per tuple to `wrangler.toml
|
|
123
|
+
The compiler walks every resource, collects unique `(limit, period)` tuples, and emits one Cloudflare binding per tuple to `wrangler.toml` (shown for a project named `my-app`):
|
|
124
124
|
|
|
125
125
|
```toml
|
|
126
|
-
[[ratelimits]]
|
|
127
|
-
name = "RL_1000_60"
|
|
128
|
-
namespace_id = "60002000"
|
|
129
|
-
simple = { limit = 1000, period = 60 }
|
|
130
|
-
|
|
131
126
|
[[ratelimits]]
|
|
132
127
|
name = "RL_200_60"
|
|
133
|
-
namespace_id = "
|
|
128
|
+
namespace_id = "955231714"
|
|
134
129
|
simple = { limit = 200, period = 60 }
|
|
130
|
+
|
|
131
|
+
[[ratelimits]]
|
|
132
|
+
name = "RL_1000_60"
|
|
133
|
+
namespace_id = "596007560"
|
|
134
|
+
simple = { limit = 1000, period = 60 }
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
`namespace_id`
|
|
137
|
+
Cloudflare scopes a `namespace_id` to the **account**, not the Worker: two Workers whose bindings share an id share counters for the same key. So the compiler derives each id from the Worker name (`name` in `quickback.config.ts`) and the `(limit, period)` tuple: a SHA-256 hash mapped into `10000000`–`999999999`. The id survives resource reordering and recompiles, and two projects on one account get different ids even when their limits match. If two tuples in one project hash to the same id, the later one (sorted by period, then limit) re-hashes until it is free. Renaming the Worker changes every id.
|
|
138
|
+
|
|
139
|
+
> **Counters reset once on upgrade**
|
|
140
|
+
>
|
|
141
|
+
> Projects compiled before this scheme used `1000 + period * 1_000_000 + limit`, which gave every project the same ids, so anonymous IP-keyed limits in one project spent another project's budget whenever the resource and op names matched. The next deploy after recompiling moves each binding to its new id. Counters start from zero once, which only means a client can briefly get one extra window's worth of requests.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
Named environments do not use these ids. Each target states its own in `environments.<name>.worker.bindings.rateLimits` (see [D1](/platform/database/d1) and [Neon](/platform/database/neon)). Pick ids that no other Worker on the account uses, and give staging and production different ones.
|
|
138
145
|
|
|
139
146
|
The platform auth middleware verifies credentials and populates `ctx` before resource routes run. CRUD rate-limit middleware runs before the handler's authentication requirement and access checks; action checks run near handler entry, also before those gates. Earlier platform or namespace middleware can reject a request before it reaches a limiter. This feature does not move any auth middleware.
|
|
140
147
|
|
|
@@ -157,8 +157,8 @@ export default defineConfig({
|
|
|
157
157
|
},
|
|
158
158
|
kv: { id: "22222222222222222222222222222222" },
|
|
159
159
|
rateLimits: {
|
|
160
|
-
RL_200_60: "
|
|
161
|
-
RL_1000_60: "
|
|
160
|
+
RL_200_60: "734120911",
|
|
161
|
+
RL_1000_60: "734120912",
|
|
162
162
|
},
|
|
163
163
|
sendEmail: { name: "EMAIL" },
|
|
164
164
|
},
|
|
@@ -183,8 +183,8 @@ export default defineConfig({
|
|
|
183
183
|
hyperdrive: { id: "33333333333333333333333333333333" },
|
|
184
184
|
kv: { id: "44444444444444444444444444444444" },
|
|
185
185
|
rateLimits: {
|
|
186
|
-
RL_200_60: "
|
|
187
|
-
RL_1000_60: "
|
|
186
|
+
RL_200_60: "734120921",
|
|
187
|
+
RL_1000_60: "734120922",
|
|
188
188
|
},
|
|
189
189
|
sendEmail: { name: "EMAIL" },
|
|
190
190
|
},
|
|
@@ -230,7 +230,10 @@ The environment contract is intentionally exact and fails closed:
|
|
|
230
230
|
from the remote Hyperdrive ID.
|
|
231
231
|
- `rateLimits` must contain exactly the binding names generated by the current
|
|
232
232
|
feature set, with account-unique integer namespace IDs. Add or remove a rate
|
|
233
|
-
limit and the next compile tells you which override changed.
|
|
233
|
+
limit and the next compile tells you which override changed. Cloudflare
|
|
234
|
+
shares counters between every Worker on the account that uses the same ID,
|
|
235
|
+
so pick your own IDs rather than copying the ones above, and never reuse an
|
|
236
|
+
ID across targets or projects.
|
|
234
237
|
- `requiredSecrets` must exactly match the generated runtime inventory:
|
|
235
238
|
`BETTER_AUTH_SECRET`,
|
|
236
239
|
`ENCRYPTION_KEK` when envelope-encrypted columns are present, and every
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quickback-dev/cli",
|
|
3
|
-
"version": "0.72.
|
|
3
|
+
"version": "0.72.11",
|
|
4
4
|
"description": "CLI for Quickback — define your backend in TypeScript, compile to a fully wired Cloudflare Worker (or Bun / Node) with auth, database, migrations, security, CMS, and Account UI.",
|
|
5
5
|
"author": "Kardoe Incorporated <paul@kardoe.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -120,21 +120,28 @@ This means:
|
|
|
120
120
|
|
|
121
121
|
## How limits compile
|
|
122
122
|
|
|
123
|
-
The compiler walks every resource, collects unique `(limit, period)` tuples, and emits one Cloudflare binding per tuple to `wrangler.toml
|
|
123
|
+
The compiler walks every resource, collects unique `(limit, period)` tuples, and emits one Cloudflare binding per tuple to `wrangler.toml` (shown for a project named `my-app`):
|
|
124
124
|
|
|
125
125
|
```toml
|
|
126
|
-
[[ratelimits]]
|
|
127
|
-
name = "RL_1000_60"
|
|
128
|
-
namespace_id = "60002000"
|
|
129
|
-
simple = { limit = 1000, period = 60 }
|
|
130
|
-
|
|
131
126
|
[[ratelimits]]
|
|
132
127
|
name = "RL_200_60"
|
|
133
|
-
namespace_id = "
|
|
128
|
+
namespace_id = "955231714"
|
|
134
129
|
simple = { limit = 200, period = 60 }
|
|
130
|
+
|
|
131
|
+
[[ratelimits]]
|
|
132
|
+
name = "RL_1000_60"
|
|
133
|
+
namespace_id = "596007560"
|
|
134
|
+
simple = { limit = 1000, period = 60 }
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
`namespace_id`
|
|
137
|
+
Cloudflare scopes a `namespace_id` to the **account**, not the Worker: two Workers whose bindings share an id share counters for the same key. So the compiler derives each id from the Worker name (`name` in `quickback.config.ts`) and the `(limit, period)` tuple: a SHA-256 hash mapped into `10000000`–`999999999`. The id survives resource reordering and recompiles, and two projects on one account get different ids even when their limits match. If two tuples in one project hash to the same id, the later one (sorted by period, then limit) re-hashes until it is free. Renaming the Worker changes every id.
|
|
138
|
+
|
|
139
|
+
> **Counters reset once on upgrade**
|
|
140
|
+
>
|
|
141
|
+
> Projects compiled before this scheme used `1000 + period * 1_000_000 + limit`, which gave every project the same ids, so anonymous IP-keyed limits in one project spent another project's budget whenever the resource and op names matched. The next deploy after recompiling moves each binding to its new id. Counters start from zero once, which only means a client can briefly get one extra window's worth of requests.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
Named environments do not use these ids. Each target states its own in `environments.<name>.worker.bindings.rateLimits` (see [D1](/platform/database/d1) and [Neon](/platform/database/neon)). Pick ids that no other Worker on the account uses, and give staging and production different ones.
|
|
138
145
|
|
|
139
146
|
The platform auth middleware verifies credentials and populates `ctx` before resource routes run. CRUD rate-limit middleware runs before the handler's authentication requirement and access checks; action checks run near handler entry, also before those gates. Earlier platform or namespace middleware can reject a request before it reaches a limiter. This feature does not move any auth middleware.
|
|
140
147
|
|
|
@@ -157,8 +157,8 @@ export default defineConfig({
|
|
|
157
157
|
},
|
|
158
158
|
kv: { id: "22222222222222222222222222222222" },
|
|
159
159
|
rateLimits: {
|
|
160
|
-
RL_200_60: "
|
|
161
|
-
RL_1000_60: "
|
|
160
|
+
RL_200_60: "734120911",
|
|
161
|
+
RL_1000_60: "734120912",
|
|
162
162
|
},
|
|
163
163
|
sendEmail: { name: "EMAIL" },
|
|
164
164
|
},
|
|
@@ -183,8 +183,8 @@ export default defineConfig({
|
|
|
183
183
|
hyperdrive: { id: "33333333333333333333333333333333" },
|
|
184
184
|
kv: { id: "44444444444444444444444444444444" },
|
|
185
185
|
rateLimits: {
|
|
186
|
-
RL_200_60: "
|
|
187
|
-
RL_1000_60: "
|
|
186
|
+
RL_200_60: "734120921",
|
|
187
|
+
RL_1000_60: "734120922",
|
|
188
188
|
},
|
|
189
189
|
sendEmail: { name: "EMAIL" },
|
|
190
190
|
},
|
|
@@ -230,7 +230,10 @@ The environment contract is intentionally exact and fails closed:
|
|
|
230
230
|
from the remote Hyperdrive ID.
|
|
231
231
|
- `rateLimits` must contain exactly the binding names generated by the current
|
|
232
232
|
feature set, with account-unique integer namespace IDs. Add or remove a rate
|
|
233
|
-
limit and the next compile tells you which override changed.
|
|
233
|
+
limit and the next compile tells you which override changed. Cloudflare
|
|
234
|
+
shares counters between every Worker on the account that uses the same ID,
|
|
235
|
+
so pick your own IDs rather than copying the ones above, and never reuse an
|
|
236
|
+
ID across targets or projects.
|
|
234
237
|
- `requiredSecrets` must exactly match the generated runtime inventory:
|
|
235
238
|
`BETTER_AUTH_SECRET`,
|
|
236
239
|
`ENCRYPTION_KEK` when envelope-encrypted columns are present, and every
|