create-cloudflare 2.11.3 → 2.12.1
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/cli.js +2607 -1343
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/templates/common/c3.ts +7 -5
- package/templates/hello-world/c3.ts +7 -5
- package/templates/hello-world-durable-object/c3.ts +7 -5
- package/templates/next/README.md +58 -0
- package/templates/next/app/js/app/api/hello/route.js +21 -0
- package/templates/next/app/js/app/not-found.js +58 -0
- package/templates/next/app/ts/app/api/hello/route.ts +22 -0
- package/templates/next/app/ts/app/not-found.tsx +58 -0
- package/templates/next/c3.ts +75 -62
- package/templates/next/env.d.ts +7 -0
- package/templates/next/pages/js/pages/api/hello.js +23 -0
- package/templates/next/pages/ts/pages/api/hello.ts +24 -0
- package/templates/next/wrangler.toml +57 -0
- package/templates/nuxt/c3.ts +57 -16
- package/templates/nuxt/templates/wrangler.toml +50 -0
- package/templates/queues/c3.ts +7 -5
- package/templates/qwik/c3.ts +76 -23
- package/templates/qwik/snippets/getPlatformProxy.ts +6 -0
- package/templates/qwik/templates/worker-configuration.d.ts +3 -0
- package/templates/qwik/templates/wrangler.toml +50 -0
- package/templates/scheduled/c3.ts +7 -5
- package/templates/solid/c3.ts +4 -2
- package/templates/svelte/c3.ts +80 -28
- package/templates/svelte/js/src/hooks.server.js +25 -0
- package/templates/svelte/js/wrangler.toml +50 -0
- package/templates/svelte/ts/src/hooks.server.ts +24 -0
- package/templates/svelte/ts/wrangler.toml +50 -0
- package/templates/next/templates.ts +0 -281
- package/templates/svelte/templates.ts +0 -13
package/templates/qwik/c3.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { endSection } from "@cloudflare/cli";
|
|
1
|
+
import { crash, endSection } from "@cloudflare/cli";
|
|
2
2
|
import { brandColor } from "@cloudflare/cli/colors";
|
|
3
3
|
import { spinner } from "@cloudflare/cli/interactive";
|
|
4
|
-
import {
|
|
4
|
+
import { loadTemplateSnippets, transformFile } from "helpers/codemod";
|
|
5
5
|
import { runCommand, runFrameworkGenerator } from "helpers/command";
|
|
6
6
|
import { usesTypescript } from "helpers/files";
|
|
7
7
|
import { detectPackageManager } from "helpers/packages";
|
|
8
|
+
import * as recast from "recast";
|
|
8
9
|
import { quoteShellArgs } from "../../src/common";
|
|
9
10
|
import type { TemplateConfig } from "../../src/templates";
|
|
10
|
-
import type * as recast from "recast";
|
|
11
11
|
import type { C3Context } from "types";
|
|
12
12
|
|
|
13
13
|
const { npm, npx } = detectPackageManager();
|
|
@@ -23,6 +23,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
23
23
|
await runCommand(cmd);
|
|
24
24
|
|
|
25
25
|
addBindingsProxy(ctx);
|
|
26
|
+
populateCloudflareEnv();
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
const addBindingsProxy = (ctx: C3Context) => {
|
|
@@ -35,43 +36,90 @@ const addBindingsProxy = (ctx: C3Context) => {
|
|
|
35
36
|
const s = spinner();
|
|
36
37
|
s.start("Updating `vite.config.ts`");
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
let env = {};
|
|
41
|
-
|
|
42
|
-
if(process.env.NODE_ENV === 'development') {
|
|
43
|
-
const { getBindingsProxy } = await import('wrangler');
|
|
44
|
-
const { bindings } = await getBindingsProxy();
|
|
45
|
-
env = bindings;
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
39
|
+
const snippets = loadTemplateSnippets(ctx);
|
|
40
|
+
const b = recast.types.builders;
|
|
48
41
|
|
|
49
42
|
transformFile("vite.config.ts", {
|
|
43
|
+
// Insert the env declaration after the last import (but before the rest of the body)
|
|
50
44
|
visitProgram: function (n) {
|
|
51
45
|
const lastImportIndex = n.node.body.findLastIndex(
|
|
52
46
|
(t) => t.type === "ImportDeclaration"
|
|
53
47
|
);
|
|
54
|
-
n.get("body"
|
|
48
|
+
const lastImport = n.get("body", lastImportIndex);
|
|
49
|
+
lastImport.insertAfter(...snippets.getPlatformProxyTs);
|
|
50
|
+
|
|
51
|
+
return this.traverse(n);
|
|
52
|
+
},
|
|
53
|
+
// Pass the `platform` object from the declaration to the `qwikCity` plugin
|
|
54
|
+
visitCallExpression: function (n) {
|
|
55
|
+
const callee = n.node.callee as recast.types.namedTypes.Identifier;
|
|
56
|
+
if (callee.name !== "qwikCity") {
|
|
57
|
+
return this.traverse(n);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The config object passed to `qwikCity`
|
|
61
|
+
const configArgument = n.node.arguments[0] as
|
|
62
|
+
| recast.types.namedTypes.ObjectExpression
|
|
63
|
+
| undefined;
|
|
64
|
+
|
|
65
|
+
const platformPropery = b.objectProperty.from({
|
|
66
|
+
key: b.identifier("platform"),
|
|
67
|
+
value: b.identifier("platform"),
|
|
68
|
+
shorthand: true,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (!configArgument) {
|
|
72
|
+
n.node.arguments = [b.objectExpression([platformPropery])];
|
|
73
|
+
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (configArgument.type !== "ObjectExpression") {
|
|
78
|
+
crash("Failed to update `vite.config.ts`");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Add the `platform` object to the object
|
|
82
|
+
configArgument.properties.push(platformPropery);
|
|
55
83
|
|
|
56
84
|
return false;
|
|
57
85
|
},
|
|
58
86
|
});
|
|
59
87
|
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
s.stop(`${brandColor("updated")} \`vite.config.ts\``);
|
|
89
|
+
};
|
|
62
90
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
const populateCloudflareEnv = () => {
|
|
92
|
+
const entrypointPath = "src/entry.cloudflare-pages.tsx";
|
|
93
|
+
|
|
94
|
+
const s = spinner();
|
|
95
|
+
s.start(`Updating \`${entrypointPath}\``);
|
|
96
|
+
|
|
97
|
+
transformFile(entrypointPath, {
|
|
98
|
+
visitTSInterfaceDeclaration: function (n) {
|
|
99
|
+
const b = recast.types.builders;
|
|
100
|
+
const id = n.node.id as recast.types.namedTypes.Identifier;
|
|
101
|
+
if (id.name !== "QwikCityPlatform") {
|
|
102
|
+
this.traverse(n);
|
|
68
103
|
}
|
|
69
104
|
|
|
70
|
-
|
|
105
|
+
const newBody = [
|
|
106
|
+
["env", "Env"],
|
|
107
|
+
// Qwik doesn't supply `cf` to the platform object. Should they do so, uncomment this
|
|
108
|
+
// ["cf", "CfProperties"],
|
|
109
|
+
].map(([varName, type]) =>
|
|
110
|
+
b.tsPropertySignature(
|
|
111
|
+
b.identifier(varName),
|
|
112
|
+
b.tsTypeAnnotation(b.tsTypeReference(b.identifier(type)))
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
n.node.body.body = newBody;
|
|
117
|
+
|
|
118
|
+
return false;
|
|
71
119
|
},
|
|
72
120
|
});
|
|
73
121
|
|
|
74
|
-
s.stop(`${brandColor("updated")}
|
|
122
|
+
s.stop(`${brandColor("updated")} \`${entrypointPath}\``);
|
|
75
123
|
};
|
|
76
124
|
|
|
77
125
|
const config: TemplateConfig = {
|
|
@@ -79,6 +127,9 @@ const config: TemplateConfig = {
|
|
|
79
127
|
id: "qwik",
|
|
80
128
|
displayName: "Qwik",
|
|
81
129
|
platform: "pages",
|
|
130
|
+
copyFiles: {
|
|
131
|
+
path: "./templates",
|
|
132
|
+
},
|
|
82
133
|
devScript: "dev",
|
|
83
134
|
deployScript: "deploy",
|
|
84
135
|
generate,
|
|
@@ -86,6 +137,8 @@ const config: TemplateConfig = {
|
|
|
86
137
|
transformPackageJson: async () => ({
|
|
87
138
|
scripts: {
|
|
88
139
|
deploy: `${npm} run build && wrangler pages deploy ./dist`,
|
|
140
|
+
preview: `${npm} run build && wrangler pages dev ./dist`,
|
|
141
|
+
"build-cf-types": `wrangler types`,
|
|
89
142
|
},
|
|
90
143
|
}),
|
|
91
144
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name = "<TBD>"
|
|
2
|
+
compatibility_date = "<TBD>"
|
|
3
|
+
|
|
4
|
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
5
|
+
# Note: Use secrets to store sensitive data.
|
|
6
|
+
# Docs: https://developers.cloudflare.com/workers/platform/environment-variables
|
|
7
|
+
# [vars]
|
|
8
|
+
# MY_VARIABLE = "production_value"
|
|
9
|
+
|
|
10
|
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
|
11
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
|
|
12
|
+
# [[kv_namespaces]]
|
|
13
|
+
# binding = "MY_KV_NAMESPACE"
|
|
14
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
15
|
+
|
|
16
|
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
|
17
|
+
# Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
|
|
18
|
+
# [[r2_buckets]]
|
|
19
|
+
# binding = "MY_BUCKET"
|
|
20
|
+
# bucket_name = "my-bucket"
|
|
21
|
+
|
|
22
|
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
23
|
+
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
24
|
+
# [[queues.producers]]
|
|
25
|
+
# binding = "MY_QUEUE"
|
|
26
|
+
# queue = "my-queue"
|
|
27
|
+
|
|
28
|
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
|
29
|
+
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
30
|
+
# [[queues.consumers]]
|
|
31
|
+
# queue = "my-queue"
|
|
32
|
+
|
|
33
|
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
|
34
|
+
# Docs: https://developers.cloudflare.com/workers/platform/services
|
|
35
|
+
# [[services]]
|
|
36
|
+
# binding = "MY_SERVICE"
|
|
37
|
+
# service = "my-service"
|
|
38
|
+
|
|
39
|
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
40
|
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
41
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
|
|
42
|
+
# [[durable_objects.bindings]]
|
|
43
|
+
# name = "MY_DURABLE_OBJECT"
|
|
44
|
+
# class_name = "MyDurableObject"
|
|
45
|
+
|
|
46
|
+
# Durable Object migrations.
|
|
47
|
+
# Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
|
|
48
|
+
# [[migrations]]
|
|
49
|
+
# tag = "v1"
|
|
50
|
+
# new_classes = ["MyDurableObject"]
|
|
@@ -4,11 +4,13 @@ export default {
|
|
|
4
4
|
displayName: "Scheduled Worker (Cron Trigger)",
|
|
5
5
|
platform: "workers",
|
|
6
6
|
copyFiles: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
variants: {
|
|
8
|
+
js: {
|
|
9
|
+
path: "./js",
|
|
10
|
+
},
|
|
11
|
+
ts: {
|
|
12
|
+
path: "./ts",
|
|
13
|
+
},
|
|
12
14
|
},
|
|
13
15
|
},
|
|
14
16
|
};
|
package/templates/solid/c3.ts
CHANGED
|
@@ -20,8 +20,10 @@ const config: TemplateConfig = {
|
|
|
20
20
|
displayName: "Solid",
|
|
21
21
|
platform: "pages",
|
|
22
22
|
copyFiles: {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
variants: {
|
|
24
|
+
js: { path: "./js" },
|
|
25
|
+
ts: { path: "./ts" },
|
|
26
|
+
},
|
|
25
27
|
},
|
|
26
28
|
generate,
|
|
27
29
|
transformPackageJson: async () => ({
|
package/templates/svelte/c3.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { platform } from "node:os";
|
|
1
2
|
import { logRaw, updateStatus } from "@cloudflare/cli";
|
|
2
3
|
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
|
|
3
|
-
import {
|
|
4
|
+
import { transformFile } from "helpers/codemod";
|
|
4
5
|
import { installPackages, runFrameworkGenerator } from "helpers/command";
|
|
5
|
-
import {
|
|
6
|
+
import { usesTypescript } from "helpers/files";
|
|
6
7
|
import { detectPackageManager } from "helpers/packages";
|
|
7
|
-
import
|
|
8
|
+
import * as recast from "recast";
|
|
8
9
|
import type { TemplateConfig } from "../../src/templates";
|
|
9
|
-
import type
|
|
10
|
-
import type { C3Context } from "types";
|
|
10
|
+
import type { C3Context, PackageJson } from "types";
|
|
11
11
|
|
|
12
12
|
const { npm } = detectPackageManager();
|
|
13
13
|
|
|
@@ -26,7 +26,14 @@ const configure = async (ctx: C3Context) => {
|
|
|
26
26
|
doneText: `${brandColor(`installed`)} ${dim(pkg)}`,
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
updateSvelteConfig();
|
|
30
|
+
updateTypeDefinitions(ctx);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const updateSvelteConfig = () => {
|
|
34
|
+
// All we need to do is change the import statement in svelte.config.js
|
|
35
|
+
updateStatus(`Changing adapter in ${blue("svelte.config.js")}`);
|
|
36
|
+
|
|
30
37
|
transformFile("svelte.config.js", {
|
|
31
38
|
visitImportDeclaration: function (n) {
|
|
32
39
|
// importSource is the `x` in `import y from "x"`
|
|
@@ -39,23 +46,51 @@ const configure = async (ctx: C3Context) => {
|
|
|
39
46
|
return false;
|
|
40
47
|
},
|
|
41
48
|
});
|
|
42
|
-
|
|
49
|
+
};
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
if (usesTypescript(ctx)) {
|
|
46
|
-
|
|
47
|
-
visitTSModuleDeclaration(n) {
|
|
48
|
-
if (n.value.id.name === "App") {
|
|
49
|
-
const patchAst = parseTs(platformInterface);
|
|
50
|
-
const body = n.node.body as recast.types.namedTypes.TSModuleBlock;
|
|
51
|
-
body.body.push(patchAst.program.body[0]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.traverse(n);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
updateStatus(`Updating global type definitions in ${blue("app.d.ts")}`);
|
|
51
|
+
const updateTypeDefinitions = (ctx: C3Context) => {
|
|
52
|
+
if (!usesTypescript(ctx)) {
|
|
53
|
+
return;
|
|
58
54
|
}
|
|
55
|
+
|
|
56
|
+
updateStatus(`Updating global type definitions in ${blue("app.d.ts")}`);
|
|
57
|
+
|
|
58
|
+
const b = recast.types.builders;
|
|
59
|
+
|
|
60
|
+
transformFile("src/app.d.ts", {
|
|
61
|
+
visitTSModuleDeclaration(n) {
|
|
62
|
+
if (n.value.id.name === "App" && n.node.body) {
|
|
63
|
+
const moduleBlock = n.node
|
|
64
|
+
.body as recast.types.namedTypes.TSModuleBlock;
|
|
65
|
+
|
|
66
|
+
const platformInterface = b.tsInterfaceDeclaration(
|
|
67
|
+
b.identifier("Platform"),
|
|
68
|
+
b.tsInterfaceBody([
|
|
69
|
+
b.tsPropertySignature(
|
|
70
|
+
b.identifier("env"),
|
|
71
|
+
b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env")))
|
|
72
|
+
),
|
|
73
|
+
b.tsPropertySignature(
|
|
74
|
+
b.identifier("cf"),
|
|
75
|
+
b.tsTypeAnnotation(
|
|
76
|
+
b.tsTypeReference(b.identifier("CfProperties"))
|
|
77
|
+
)
|
|
78
|
+
),
|
|
79
|
+
b.tsPropertySignature(
|
|
80
|
+
b.identifier("ctx"),
|
|
81
|
+
b.tsTypeAnnotation(
|
|
82
|
+
b.tsTypeReference(b.identifier("ExecutionContext"))
|
|
83
|
+
)
|
|
84
|
+
),
|
|
85
|
+
])
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
moduleBlock.body.unshift(platformInterface);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.traverse(n);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
59
94
|
};
|
|
60
95
|
|
|
61
96
|
const config: TemplateConfig = {
|
|
@@ -63,15 +98,32 @@ const config: TemplateConfig = {
|
|
|
63
98
|
id: "svelte",
|
|
64
99
|
displayName: "Svelte",
|
|
65
100
|
platform: "pages",
|
|
101
|
+
copyFiles: {
|
|
102
|
+
variants: {
|
|
103
|
+
js: { path: "./js" },
|
|
104
|
+
ts: { path: "./ts" },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
66
107
|
generate,
|
|
67
108
|
configure,
|
|
68
|
-
transformPackageJson: async () =>
|
|
69
|
-
scripts: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
109
|
+
transformPackageJson: async (original: PackageJson, ctx: C3Context) => {
|
|
110
|
+
let scripts: Record<string, string> = {
|
|
111
|
+
preview: `${npm} run build && wrangler pages dev .svelte-kit/cloudflare`,
|
|
112
|
+
deploy: `${npm} run build && wrangler pages deploy .svelte-kit/cloudflare`,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
if (usesTypescript(ctx)) {
|
|
116
|
+
const mv = platform() === "win32" ? "move" : "mv";
|
|
117
|
+
scripts = {
|
|
118
|
+
...scripts,
|
|
119
|
+
"build-cf-types": `wrangler types && ${mv} worker-configuration.d.ts src/`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { scripts };
|
|
124
|
+
},
|
|
74
125
|
devScript: "dev",
|
|
75
|
-
|
|
126
|
+
deployScript: "deploy",
|
|
127
|
+
previewScript: "preview",
|
|
76
128
|
};
|
|
77
129
|
export default config;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dev } from '$app/environment';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
When developing, this hook will add proxy objects to the `platform` object which
|
|
5
|
+
will emulate any bindings defined in `wrangler.toml`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
let platform;
|
|
9
|
+
|
|
10
|
+
if (dev) {
|
|
11
|
+
const { getPlatformProxy } = await import('wrangler');
|
|
12
|
+
platform = await getPlatformProxy();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const handle = async ({ event, resolve }) => {
|
|
16
|
+
if (platform) {
|
|
17
|
+
event.platform = {
|
|
18
|
+
...event.platform,
|
|
19
|
+
...platform
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return resolve(event);
|
|
24
|
+
};
|
|
25
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name = "<TBD>"
|
|
2
|
+
compatibility_date = "<TBD>"
|
|
3
|
+
|
|
4
|
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
5
|
+
# Note: Use secrets to store sensitive data.
|
|
6
|
+
# Docs: https://developers.cloudflare.com/workers/platform/environment-variables
|
|
7
|
+
# [vars]
|
|
8
|
+
# MY_VARIABLE = "production_value"
|
|
9
|
+
|
|
10
|
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
|
11
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
|
|
12
|
+
# [[kv_namespaces]]
|
|
13
|
+
# binding = "MY_KV_NAMESPACE"
|
|
14
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
15
|
+
|
|
16
|
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
|
17
|
+
# Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
|
|
18
|
+
# [[r2_buckets]]
|
|
19
|
+
# binding = "MY_BUCKET"
|
|
20
|
+
# bucket_name = "my-bucket"
|
|
21
|
+
|
|
22
|
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
23
|
+
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
24
|
+
# [[queues.producers]]
|
|
25
|
+
# binding = "MY_QUEUE"
|
|
26
|
+
# queue = "my-queue"
|
|
27
|
+
|
|
28
|
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
|
29
|
+
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
30
|
+
# [[queues.consumers]]
|
|
31
|
+
# queue = "my-queue"
|
|
32
|
+
|
|
33
|
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
|
34
|
+
# Docs: https://developers.cloudflare.com/workers/platform/services
|
|
35
|
+
# [[services]]
|
|
36
|
+
# binding = "MY_SERVICE"
|
|
37
|
+
# service = "my-service"
|
|
38
|
+
|
|
39
|
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
40
|
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
41
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
|
|
42
|
+
# [[durable_objects.bindings]]
|
|
43
|
+
# name = "MY_DURABLE_OBJECT"
|
|
44
|
+
# class_name = "MyDurableObject"
|
|
45
|
+
|
|
46
|
+
# Durable Object migrations.
|
|
47
|
+
# Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
|
|
48
|
+
# [[migrations]]
|
|
49
|
+
# tag = "v1"
|
|
50
|
+
# new_classes = ["MyDurableObject"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { dev } from '$app/environment';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
When developing, this hook will add proxy objects to the `platform` object which
|
|
5
|
+
will emulate any bindings defined in `wrangler.toml`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
let platform: App.Platform;
|
|
9
|
+
|
|
10
|
+
if (dev) {
|
|
11
|
+
const { getPlatformProxy } = await import('wrangler');
|
|
12
|
+
platform = await getPlatformProxy();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const handle = async ({ event, resolve }) => {
|
|
16
|
+
if (platform) {
|
|
17
|
+
event.platform = {
|
|
18
|
+
...event.platform,
|
|
19
|
+
...platform
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return resolve(event);
|
|
24
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name = "<TBD>"
|
|
2
|
+
compatibility_date = "<TBD>"
|
|
3
|
+
|
|
4
|
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
5
|
+
# Note: Use secrets to store sensitive data.
|
|
6
|
+
# Docs: https://developers.cloudflare.com/workers/platform/environment-variables
|
|
7
|
+
# [vars]
|
|
8
|
+
# MY_VARIABLE = "production_value"
|
|
9
|
+
|
|
10
|
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
|
11
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
|
|
12
|
+
# [[kv_namespaces]]
|
|
13
|
+
# binding = "MY_KV_NAMESPACE"
|
|
14
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
15
|
+
|
|
16
|
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
|
17
|
+
# Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
|
|
18
|
+
# [[r2_buckets]]
|
|
19
|
+
# binding = "MY_BUCKET"
|
|
20
|
+
# bucket_name = "my-bucket"
|
|
21
|
+
|
|
22
|
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
23
|
+
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
24
|
+
# [[queues.producers]]
|
|
25
|
+
# binding = "MY_QUEUE"
|
|
26
|
+
# queue = "my-queue"
|
|
27
|
+
|
|
28
|
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
|
29
|
+
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
30
|
+
# [[queues.consumers]]
|
|
31
|
+
# queue = "my-queue"
|
|
32
|
+
|
|
33
|
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
|
34
|
+
# Docs: https://developers.cloudflare.com/workers/platform/services
|
|
35
|
+
# [[services]]
|
|
36
|
+
# binding = "MY_SERVICE"
|
|
37
|
+
# service = "my-service"
|
|
38
|
+
|
|
39
|
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
40
|
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
41
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
|
|
42
|
+
# [[durable_objects.bindings]]
|
|
43
|
+
# name = "MY_DURABLE_OBJECT"
|
|
44
|
+
# class_name = "MyDurableObject"
|
|
45
|
+
|
|
46
|
+
# Durable Object migrations.
|
|
47
|
+
# Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
|
|
48
|
+
# [[migrations]]
|
|
49
|
+
# tag = "v1"
|
|
50
|
+
# new_classes = ["MyDurableObject"]
|