wrangler 0.0.0-e0d2f35 → 0.0.0-e178d6fb
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/Cloudflare_CA.pem +18 -0
- package/README.md +33 -14
- package/bin/wrangler.js +159 -27
- package/kv-asset-handler.js +1 -0
- package/miniflare-dist/index.mjs +5354 -0
- package/package.json +166 -129
- package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
- package/src/__tests__/config-cache.test.ts +42 -0
- package/src/__tests__/configuration.test.ts +3950 -0
- package/src/__tests__/dev.test.tsx +1199 -67
- package/src/__tests__/guess-worker-format.test.ts +85 -0
- package/src/__tests__/{clipboardy-mock.js → helpers/clipboardy-mock.js} +0 -0
- package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
- package/src/__tests__/helpers/mock-account-id.ts +48 -0
- package/src/__tests__/helpers/mock-bin.ts +36 -0
- package/src/__tests__/helpers/mock-cfetch.ts +211 -0
- package/src/__tests__/helpers/mock-console.ts +97 -0
- package/src/__tests__/helpers/mock-dialogs.ts +153 -0
- package/src/__tests__/helpers/mock-http-server.ts +46 -0
- package/src/__tests__/helpers/mock-istty.ts +74 -0
- package/src/__tests__/helpers/mock-kv.ts +33 -0
- package/src/__tests__/helpers/mock-oauth-flow.ts +250 -0
- package/src/__tests__/helpers/mock-process.ts +39 -0
- package/src/__tests__/helpers/mock-stdin.ts +108 -0
- package/src/__tests__/helpers/mock-web-socket.ts +29 -0
- package/src/__tests__/helpers/run-in-tmp.ts +38 -0
- package/src/__tests__/helpers/run-wrangler.ts +16 -0
- package/src/__tests__/helpers/write-worker-source.ts +31 -0
- package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
- package/src/__tests__/https-options.test.ts +163 -0
- package/src/__tests__/index.test.ts +259 -421
- package/src/__tests__/init.test.ts +1992 -0
- package/src/__tests__/jest.setup.ts +105 -14
- package/src/__tests__/kv.test.ts +1420 -973
- package/src/__tests__/logger.test.ts +141 -0
- package/src/__tests__/metrics.test.ts +445 -0
- package/src/__tests__/package-manager.test.ts +353 -0
- package/src/__tests__/pages.test.ts +1261 -0
- package/src/__tests__/parse.test.ts +330 -0
- package/src/__tests__/publish.test.ts +6639 -1174
- package/src/__tests__/pubsub.test.ts +367 -0
- package/src/__tests__/r2.test.ts +233 -0
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/secret.test.ts +489 -203
- package/src/__tests__/tail.test.ts +698 -0
- package/src/__tests__/test-old-node-version.js +31 -0
- package/src/__tests__/user.test.ts +143 -0
- package/src/__tests__/version.test.ts +35 -0
- package/src/__tests__/whoami.test.tsx +222 -93
- package/src/__tests__/worker-namespace.test.ts +327 -0
- package/src/abort.d.ts +3 -0
- package/src/api/dev.ts +86 -0
- package/src/api/index.ts +1 -0
- package/src/bundle-reporter.tsx +29 -0
- package/src/bundle.ts +236 -0
- package/src/cfetch/index.ts +88 -78
- package/src/cfetch/internal.ts +124 -46
- package/src/cli.ts +24 -6
- package/src/config/README.md +107 -0
- package/src/config/config.ts +251 -0
- package/src/config/diagnostics.ts +80 -0
- package/src/config/environment.ts +453 -0
- package/src/config/index.ts +238 -0
- package/src/config/validation-helpers.ts +584 -0
- package/src/config/validation.ts +1754 -0
- package/src/config-cache.ts +84 -0
- package/src/create-worker-preview.ts +257 -0
- package/src/create-worker-upload-form.ts +263 -0
- package/src/dev/dev-vars.ts +36 -0
- package/src/dev/dev.tsx +452 -0
- package/src/dev/local.tsx +373 -0
- package/src/dev/remote.tsx +386 -0
- package/src/dev/use-esbuild.ts +150 -0
- package/src/dev.tsx +580 -817
- package/src/dialogs.tsx +117 -59
- package/src/durable.ts +102 -0
- package/src/entry.ts +328 -0
- package/src/environment-variables.ts +35 -0
- package/src/errors.ts +11 -0
- package/src/faye-websocket.d.ts +6 -0
- package/src/generate.ts +33 -0
- package/src/git-client.ts +42 -0
- package/src/global-wrangler-config-path.ts +26 -0
- package/src/https-options.ts +127 -0
- package/src/index.tsx +1978 -2051
- package/src/init.ts +549 -0
- package/src/inspect.ts +610 -543
- package/src/intl-polyfill.d.ts +139 -0
- package/src/is-interactive.ts +12 -0
- package/src/kv.ts +430 -0
- package/src/logger.ts +73 -0
- package/src/metrics/index.ts +4 -0
- package/src/metrics/is-ci.ts +14 -0
- package/src/metrics/metrics-config.ts +239 -0
- package/src/metrics/metrics-dispatcher.ts +95 -0
- package/src/metrics/send-event.ts +92 -0
- package/src/miniflare-cli/README.md +30 -0
- package/src/miniflare-cli/assets.ts +543 -0
- package/src/miniflare-cli/enum-keys.ts +17 -0
- package/src/miniflare-cli/index.ts +85 -0
- package/src/miniflare-cli/request-context.ts +40 -0
- package/src/module-collection.ts +247 -52
- package/src/open-in-browser.ts +17 -0
- package/src/package-manager.ts +219 -0
- package/src/pages/build.tsx +204 -0
- package/src/pages/constants.ts +7 -0
- package/src/pages/deployments.tsx +106 -0
- package/src/pages/dev.tsx +401 -0
- package/src/pages/functions/buildPlugin.ts +105 -0
- package/src/pages/functions/buildWorker.ts +151 -0
- package/src/pages/functions/filepath-routing.test.ts +234 -0
- package/src/pages/functions/filepath-routing.ts +189 -0
- package/src/pages/functions/identifiers.ts +78 -0
- package/src/pages/functions/routes.ts +151 -0
- package/src/pages/index.tsx +84 -0
- package/src/pages/projects.tsx +163 -0
- package/src/pages/publish.tsx +338 -0
- package/src/pages/types.ts +40 -0
- package/src/pages/upload.tsx +396 -0
- package/src/pages/utils.ts +12 -0
- package/src/parse.ts +286 -0
- package/src/paths.ts +26 -0
- package/src/preview.ts +31 -0
- package/src/proxy.ts +421 -315
- package/src/publish.ts +776 -393
- package/src/pubsub/index.ts +286 -0
- package/src/pubsub/pubsub-commands.tsx +623 -0
- package/src/r2.ts +50 -0
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.tsx +293 -161
- package/src/tail/filters.ts +279 -0
- package/src/tail/index.ts +299 -0
- package/src/tail/printing.ts +67 -0
- package/src/update-check.ts +19 -0
- package/src/user/choose-account.tsx +69 -0
- package/src/user/env-vars.ts +46 -0
- package/src/user/generate-auth-url.ts +33 -0
- package/src/user/generate-random-state.ts +16 -0
- package/src/user/index.ts +3 -0
- package/src/user/user.tsx +1171 -0
- package/src/whoami.tsx +63 -41
- package/src/worker-namespace.ts +206 -0
- package/src/worker.ts +191 -0
- package/src/zones.ts +76 -0
- package/templates/checked-fetch.js +17 -0
- package/templates/gitignore +171 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.js +15 -0
- package/templates/new-worker.ts +30 -0
- package/templates/no-op-worker.js +10 -0
- package/templates/pages-shim.ts +9 -0
- package/templates/pages-template-plugin.ts +155 -0
- package/templates/pages-template-worker.ts +161 -0
- package/templates/static-asset-facade.js +49 -0
- package/templates/tsconfig.json +105 -0
- package/wrangler-dist/cli.d.ts +327 -0
- package/wrangler-dist/cli.js +91375 -92119
- package/pages/functions/buildWorker.ts +0 -62
- package/pages/functions/filepath-routing.test.ts +0 -39
- package/pages/functions/filepath-routing.ts +0 -228
- package/pages/functions/identifiers.ts +0 -78
- package/pages/functions/routes.ts +0 -158
- package/pages/functions/template-worker.ts +0 -136
- package/src/__tests__/logout.test.ts +0 -64
- package/src/__tests__/mock-cfetch.ts +0 -173
- package/src/__tests__/mock-console.ts +0 -34
- package/src/__tests__/mock-dialogs.ts +0 -65
- package/src/__tests__/mock-kv.ts +0 -40
- package/src/__tests__/mock-user.ts +0 -27
- package/src/__tests__/run-in-tmp.ts +0 -29
- package/src/__tests__/run-wrangler.ts +0 -8
- package/src/api/form_data.ts +0 -135
- package/src/api/preview.ts +0 -128
- package/src/api/worker.ts +0 -155
- package/src/config.ts +0 -641
- package/src/kv.tsx +0 -276
- package/src/pages.tsx +0 -1043
- package/src/tail.tsx +0 -73
- package/src/user.tsx +0 -1019
- package/static-asset-facade.js +0 -47
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
- package/wrangler-dist/cli.js.map +0 -7
package/src/api/preview.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
import { fetchResult } from "../cfetch";
|
|
3
|
-
import { toFormData } from "./form_data";
|
|
4
|
-
import type { CfAccount, CfWorkerInit } from "./worker";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A preview mode.
|
|
8
|
-
*
|
|
9
|
-
* * If true, then using a `workers.dev` subdomain.
|
|
10
|
-
* * Otherwise, a list of routes under a single zone.
|
|
11
|
-
*/
|
|
12
|
-
type CfPreviewMode = { workers_dev: boolean } | { routes: string[] };
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A preview token.
|
|
16
|
-
*/
|
|
17
|
-
export interface CfPreviewToken {
|
|
18
|
-
/**
|
|
19
|
-
* The header value required to trigger a preview.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const headers = { 'cf-workers-preview-token': value }
|
|
23
|
-
* const response = await fetch('https://' + host, { headers })
|
|
24
|
-
*/
|
|
25
|
-
value: string;
|
|
26
|
-
/**
|
|
27
|
-
* The host where the preview is available.
|
|
28
|
-
*/
|
|
29
|
-
host: string;
|
|
30
|
-
/**
|
|
31
|
-
* A websocket url to a DevTools inspector.
|
|
32
|
-
*
|
|
33
|
-
* Workers does not have a fully-featured implementation
|
|
34
|
-
* of the Chrome DevTools protocol, but supports the following:
|
|
35
|
-
* * `console.log()` output.
|
|
36
|
-
* * `Error` stack traces.
|
|
37
|
-
* * `fetch()` events.
|
|
38
|
-
*
|
|
39
|
-
* There is no support for breakpoints, but we want to implement
|
|
40
|
-
* this eventually.
|
|
41
|
-
*
|
|
42
|
-
* @link https://chromedevtools.github.io/devtools-protocol/
|
|
43
|
-
*/
|
|
44
|
-
inspectorUrl: URL;
|
|
45
|
-
/**
|
|
46
|
-
* A url to prewarm the preview session.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* fetch(prewarmUrl, { method: 'POST' })
|
|
50
|
-
*/
|
|
51
|
-
prewarmUrl: URL;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Generates a preview session token.
|
|
56
|
-
*/
|
|
57
|
-
async function sessionToken(account: CfAccount): Promise<CfPreviewToken> {
|
|
58
|
-
const { accountId, zoneId } = account;
|
|
59
|
-
const initUrl = zoneId
|
|
60
|
-
? `/zones/${zoneId}/workers/edge-preview`
|
|
61
|
-
: `/accounts/${accountId}/workers/subdomain/edge-preview`;
|
|
62
|
-
|
|
63
|
-
const { exchange_url } = await fetchResult<{ exchange_url: string }>(initUrl);
|
|
64
|
-
const { inspector_websocket, token } = (await (
|
|
65
|
-
await fetch(exchange_url)
|
|
66
|
-
).json()) as { inspector_websocket: string; token: string };
|
|
67
|
-
const { host } = new URL(inspector_websocket);
|
|
68
|
-
const query = `cf_workers_preview_token=${token}`;
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
value: token,
|
|
72
|
-
host,
|
|
73
|
-
inspectorUrl: new URL(`${inspector_websocket}?${query}`),
|
|
74
|
-
prewarmUrl: new URL(
|
|
75
|
-
`https://${host}/cdn-cgi/workers/preview/prewarm?${query}`
|
|
76
|
-
),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Credit: https://stackoverflow.com/a/2117523
|
|
81
|
-
function randomId(): string {
|
|
82
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
83
|
-
const r = (Math.random() * 16) | 0,
|
|
84
|
-
v = c == "x" ? r : (r & 0x3) | 0x8;
|
|
85
|
-
return v.toString(16);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Creates a preview token.
|
|
91
|
-
*/
|
|
92
|
-
export async function previewToken(
|
|
93
|
-
account: CfAccount,
|
|
94
|
-
worker: CfWorkerInit
|
|
95
|
-
): Promise<CfPreviewToken> {
|
|
96
|
-
const { value, host, inspectorUrl, prewarmUrl } = await sessionToken(account);
|
|
97
|
-
|
|
98
|
-
const { accountId, zoneId } = account;
|
|
99
|
-
const scriptId = zoneId ? randomId() : worker.name || host.split(".")[0];
|
|
100
|
-
const url = `/accounts/${accountId}/workers/scripts/${scriptId}/edge-preview`;
|
|
101
|
-
|
|
102
|
-
const mode: CfPreviewMode = zoneId
|
|
103
|
-
? { routes: ["*/*"] }
|
|
104
|
-
: { workers_dev: true };
|
|
105
|
-
|
|
106
|
-
const formData = toFormData(worker);
|
|
107
|
-
formData.set("wrangler-session-config", JSON.stringify(mode));
|
|
108
|
-
|
|
109
|
-
const { preview_token } = await fetchResult<{ preview_token: string }>(url, {
|
|
110
|
-
method: "POST",
|
|
111
|
-
// @ts-expect-error TODO: fix this
|
|
112
|
-
body: formData,
|
|
113
|
-
headers: {
|
|
114
|
-
"cf-preview-upload-config-token": value,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
value: preview_token,
|
|
120
|
-
// TODO: verify this works with zoned workers
|
|
121
|
-
host:
|
|
122
|
-
worker.name && !zoneId
|
|
123
|
-
? `${worker.name}.${host.split(".").slice(1).join(".")}`
|
|
124
|
-
: host,
|
|
125
|
-
inspectorUrl,
|
|
126
|
-
prewarmUrl,
|
|
127
|
-
};
|
|
128
|
-
}
|
package/src/api/worker.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import type { CfPreviewToken } from "./preview";
|
|
2
|
-
import { previewToken } from "./preview";
|
|
3
|
-
import fetch from "node-fetch";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A Cloudflare account.
|
|
7
|
-
*/
|
|
8
|
-
export interface CfAccount {
|
|
9
|
-
/**
|
|
10
|
-
* An API token.
|
|
11
|
-
*
|
|
12
|
-
* @link https://api.cloudflare.com/#user-api-tokens-properties
|
|
13
|
-
*/
|
|
14
|
-
apiToken: string;
|
|
15
|
-
/**
|
|
16
|
-
* An account ID.
|
|
17
|
-
*/
|
|
18
|
-
accountId: string;
|
|
19
|
-
/**
|
|
20
|
-
* A zone ID, only required if not using `workers.dev`.
|
|
21
|
-
*/
|
|
22
|
-
zoneId?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A module type.
|
|
27
|
-
*/
|
|
28
|
-
export type CfModuleType =
|
|
29
|
-
| "esm"
|
|
30
|
-
| "commonjs"
|
|
31
|
-
| "compiled-wasm"
|
|
32
|
-
| "text"
|
|
33
|
-
| "buffer";
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* An imported module.
|
|
37
|
-
*/
|
|
38
|
-
export interface CfModule {
|
|
39
|
-
/**
|
|
40
|
-
* The module name.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* './src/index.js'
|
|
44
|
-
*/
|
|
45
|
-
name: string;
|
|
46
|
-
/**
|
|
47
|
-
* The module content, usually JavaScript or WASM code.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* export default {
|
|
51
|
-
* async fetch(request) {
|
|
52
|
-
* return new Response('Ok')
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
*/
|
|
56
|
-
content: string | BufferSource;
|
|
57
|
-
/**
|
|
58
|
-
* The module type.
|
|
59
|
-
*
|
|
60
|
-
* If absent, will default to the main module's type.
|
|
61
|
-
*/
|
|
62
|
-
type?: CfModuleType;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* A map of variable names to values.
|
|
67
|
-
*/
|
|
68
|
-
interface CfVars {
|
|
69
|
-
[key: string]: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A KV namespace.
|
|
74
|
-
*/
|
|
75
|
-
interface CfKvNamespace {
|
|
76
|
-
binding: string;
|
|
77
|
-
id: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* A Durable Object.
|
|
82
|
-
*/
|
|
83
|
-
interface CfDurableObject {
|
|
84
|
-
name: string;
|
|
85
|
-
class_name: string;
|
|
86
|
-
script_name?: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A Service.
|
|
91
|
-
*/
|
|
92
|
-
interface CfService {
|
|
93
|
-
name: string;
|
|
94
|
-
service: string;
|
|
95
|
-
environment: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface CfDurableObjectMigrations {
|
|
99
|
-
old_tag?: string;
|
|
100
|
-
new_tag: string;
|
|
101
|
-
steps: {
|
|
102
|
-
new_classes?: string[];
|
|
103
|
-
renamed_classes?: string[];
|
|
104
|
-
deleted_classes?: string[];
|
|
105
|
-
}[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Options for creating a `CfWorker`.
|
|
110
|
-
*/
|
|
111
|
-
export interface CfWorkerInit {
|
|
112
|
-
/**
|
|
113
|
-
* The name of the worker.
|
|
114
|
-
*/
|
|
115
|
-
name: string | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* The entrypoint module.
|
|
118
|
-
*/
|
|
119
|
-
main: CfModule;
|
|
120
|
-
/**
|
|
121
|
-
* The list of additional modules.
|
|
122
|
-
*/
|
|
123
|
-
modules: undefined | CfModule[];
|
|
124
|
-
/**
|
|
125
|
-
* All the bindings
|
|
126
|
-
*/
|
|
127
|
-
bindings: {
|
|
128
|
-
kv_namespaces?: CfKvNamespace[];
|
|
129
|
-
durable_objects?: { bindings: CfDurableObject[] };
|
|
130
|
-
vars?: CfVars;
|
|
131
|
-
services?: CfService[];
|
|
132
|
-
};
|
|
133
|
-
migrations: undefined | CfDurableObjectMigrations;
|
|
134
|
-
compatibility_date: string | undefined;
|
|
135
|
-
compatibility_flags: undefined | string[];
|
|
136
|
-
usage_model: undefined | "bundled" | "unbound";
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* A stub to create a Cloudflare Worker preview.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* const {value, host} = await createWorker(init, acct);
|
|
144
|
-
*/
|
|
145
|
-
export async function createWorker(
|
|
146
|
-
init: CfWorkerInit,
|
|
147
|
-
account: CfAccount
|
|
148
|
-
): Promise<CfPreviewToken> {
|
|
149
|
-
const token = await previewToken(account, init);
|
|
150
|
-
const response = await fetch(token.prewarmUrl.href, { method: "POST" });
|
|
151
|
-
if (!response.ok) {
|
|
152
|
-
// console.error("worker failed to prewarm: ", response.statusText);
|
|
153
|
-
}
|
|
154
|
-
return token;
|
|
155
|
-
}
|