Skip to content

Commit 1781bde

Browse files
committed
Preserve rate-limit bindings with pinned secrets, closes #462.
1 parent d9ce787 commit 1781bde

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎packages/void/src/cli/cf-version-api.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ function bindingsFromOutput(
160160
...(value.deliveryDelay === undefined ? {} : { delivery_delay: value.deliveryDelay }),
161161
});
162162
break;
163+
case 'rate-limit':
164+
bindings.push({
165+
name,
166+
type: 'ratelimit',
167+
namespace_id: requiredString(value.namespace, name),
168+
simple: value.simple,
169+
});
170+
break;
163171
case 'ai':
164172
case 'browser':
165173
case 'images':

‎packages/void/test/unit/cf-version-runner.test.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,10 @@ async function verifyPinnedUpload(atomic: boolean): Promise<void> {
715715
keep_vars: true,
716716
assets: { directory: '../client', binding: 'ASSETS', not_found_handling: 'none' },
717717
queues: { producers: [{ binding: 'JOBS', queue: 'jobs', delivery_delay: 7 }] },
718+
ratelimits: [
719+
{ name: 'FAST_LIMIT', namespace_id: '1001', simple: { limit: 5, period: 10 } },
720+
{ name: 'MINUTE_LIMIT', namespace_id: '1002', simple: { limit: 30, period: 60 } },
721+
],
718722
ai: { binding: 'AI' },
719723
hyperdrive: [{ binding: 'POSTGRES', id: 'a'.repeat(32) }],
720724
services: [
@@ -880,6 +884,18 @@ async function verifyPinnedUpload(atomic: boolean): Promise<void> {
880884
{ name: 'DASHBOARD_VAR', type: 'inherit', version_id: activeVersionId },
881885
{ name: 'APP_VERSION', type: 'version_metadata' },
882886
{ name: 'JOBS', type: 'queue', queue_name: 'jobs', delivery_delay: 7 },
887+
{
888+
name: 'FAST_LIMIT',
889+
type: 'ratelimit',
890+
namespace_id: '1001',
891+
simple: { limit: 5, period: 10 },
892+
},
893+
{
894+
name: 'MINUTE_LIMIT',
895+
type: 'ratelimit',
896+
namespace_id: '1002',
897+
simple: { limit: 30, period: 60 },
898+
},
883899
{ name: 'AI', type: 'ai' },
884900
{ name: 'POSTGRES', type: 'hyperdrive', id: 'a'.repeat(32) },
885901
{
@@ -985,10 +1001,10 @@ async function verifyPinnedUpload(atomic: boolean): Promise<void> {
9851001
}
9861002
}
9871003

988-
it('uploads live secrets and multiple asset batches when the latest upload is inactive', () =>
1004+
it('uploads live secrets, rate limits and multiple asset batches when the latest upload is inactive', () =>
9891005
verifyPinnedUpload(false));
9901006

991-
it('uploads live secrets and multiple asset batches for atomic publication', () =>
1007+
it('uploads live secrets, rate limits and multiple asset batches for atomic publication', () =>
9921008
verifyPinnedUpload(true));
9931009

9941010
it('converts Container and transfer exports as cf does', () => {

0 commit comments

Comments
 (0)