@astrojs/cloudflare 9.0.2 → 9.1.0
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.
|
@@ -24,7 +24,14 @@ type BASE_RUNTIME = {
|
|
|
24
24
|
name: string;
|
|
25
25
|
env?: string;
|
|
26
26
|
};
|
|
27
|
-
}
|
|
27
|
+
} | ({
|
|
28
|
+
type: 'service';
|
|
29
|
+
} & ({
|
|
30
|
+
address: string;
|
|
31
|
+
protocol?: 'http' | 'https';
|
|
32
|
+
} | {
|
|
33
|
+
service: string;
|
|
34
|
+
}))>;
|
|
28
35
|
};
|
|
29
36
|
export type RUNTIME = {
|
|
30
37
|
mode: BASE_RUNTIME['mode'];
|
|
@@ -20,6 +20,7 @@ class LocalRuntime {
|
|
|
20
20
|
const d1Bindings = [];
|
|
21
21
|
const r2Bindings = [];
|
|
22
22
|
const durableObjectBindings = {};
|
|
23
|
+
const serviceBindings = {};
|
|
23
24
|
for (const bindingName in runtimeConfig.bindings) {
|
|
24
25
|
const bindingData = runtimeConfig.bindings[bindingName];
|
|
25
26
|
switch (bindingData.type) {
|
|
@@ -41,6 +42,22 @@ class LocalRuntime {
|
|
|
41
42
|
scriptName: bindingData.service?.name,
|
|
42
43
|
};
|
|
43
44
|
break;
|
|
45
|
+
case 'service':
|
|
46
|
+
if ('address' in bindingData) {
|
|
47
|
+
// Pages mode
|
|
48
|
+
const isHttps = bindingData.protocol === 'https';
|
|
49
|
+
const serviceBindingConfig = isHttps
|
|
50
|
+
? { address: bindingData.address, https: {} }
|
|
51
|
+
: { address: bindingData.address, http: {} };
|
|
52
|
+
serviceBindings[bindingName] = {
|
|
53
|
+
external: serviceBindingConfig,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
else if ('service' in bindingData) {
|
|
57
|
+
// Worker mode
|
|
58
|
+
serviceBindings[bindingName] = bindingData.service;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
44
61
|
}
|
|
45
62
|
}
|
|
46
63
|
this._miniflare = new Miniflare({
|
|
@@ -61,6 +78,7 @@ class LocalRuntime {
|
|
|
61
78
|
r2Buckets: r2Bindings,
|
|
62
79
|
kvNamespaces: kvBindings,
|
|
63
80
|
durableObjects: durableObjectBindings,
|
|
81
|
+
serviceBindings: serviceBindings,
|
|
64
82
|
},
|
|
65
83
|
],
|
|
66
84
|
});
|
|
@@ -183,6 +201,14 @@ export class LocalWorkersRuntime extends LocalRuntime {
|
|
|
183
201
|
};
|
|
184
202
|
}
|
|
185
203
|
}
|
|
204
|
+
if (_wranglerConfig?.services) {
|
|
205
|
+
for (const service of _wranglerConfig.services) {
|
|
206
|
+
runtimeConfigWithWrangler.bindings[service.binding] = {
|
|
207
|
+
type: 'service',
|
|
208
|
+
service: service.service,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
186
212
|
super(astroConfig, runtimeConfigWithWrangler, logger);
|
|
187
213
|
}
|
|
188
214
|
}
|
package/package.json
CHANGED