create-cloudflare 0.0.0-a7aa28ad → 0.0.0-a7e36d50
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 +877 -700
- package/package.json +4 -4
- package/templates/analog/c3.ts +134 -0
- package/templates/analog/snippets/devBindingsModule.ts +7 -0
- package/templates/analog/templates/env.d.ts +13 -0
- package/templates/analog/templates/src/dev-bindings.ts +18 -0
- package/templates/analog/templates/worker-configuration.d.ts +4 -0
- package/templates/analog/templates/wrangler.toml +78 -0
- package/templates/astro/c3.ts +3 -3
- package/templates/astro/templates/wrangler.toml +28 -2
- package/templates/common/js/wrangler.toml +4 -1
- package/templates/common/ts/package.json +2 -1
- package/templates/common/ts/src/index.ts +3 -0
- package/templates/common/ts/worker-configuration.d.ts +2 -14
- package/templates/common/ts/wrangler.toml +4 -1
- package/templates/hello-world/js/package.json +2 -1
- package/templates/hello-world/js/test/index.spec.js +17 -17
- package/templates/hello-world/js/wrangler.toml +4 -1
- package/templates/hello-world/ts/package.json +2 -1
- package/templates/hello-world/ts/src/index.ts +3 -17
- package/templates/hello-world/ts/test/index.spec.ts +17 -17
- package/templates/hello-world/ts/worker-configuration.d.ts +4 -0
- package/templates/hello-world/ts/wrangler.toml +4 -1
- package/templates/hello-world-durable-object/js/src/index.js +18 -14
- package/templates/hello-world-durable-object/js/wrangler.toml +4 -1
- package/templates/hello-world-durable-object/ts/package.json +2 -2
- package/templates/hello-world-durable-object/ts/src/index.ts +24 -16
- package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +6 -0
- package/templates/hello-world-durable-object/ts/wrangler.toml +4 -2
- package/templates/hello-world-python/py/wrangler.toml +97 -0
- package/templates/hono/c3.ts +53 -0
- package/templates/hono/snippets/appDeclaration.ts +1 -0
- package/templates/hono/snippets/bindingsType.ts +1 -0
- package/templates/hono/templates/worker-configuration.d.ts +4 -0
- package/templates/hono/templates/wrangler.toml +100 -0
- package/templates/next/README.md +5 -5
- package/templates/next/c3.ts +3 -3
- package/templates/next/wrangler.toml +26 -1
- package/templates/nuxt/c3.ts +4 -4
- package/templates/nuxt/templates/worker-configuration.d.ts +1 -1
- package/templates/nuxt/templates/wrangler.toml +28 -2
- package/templates/openapi/ts/package.json +2 -1
- package/templates/openapi/ts/worker-configuration.d.ts +4 -0
- package/templates/openapi/ts/wrangler.toml +97 -0
- package/templates/pre-existing/js/wrangler.toml +1 -0
- package/templates/queues/js/wrangler.toml +4 -1
- package/templates/queues/ts/package.json +2 -1
- package/templates/queues/ts/src/index.ts +3 -5
- package/templates/queues/ts/worker-configuration.d.ts +5 -0
- package/templates/queues/ts/wrangler.toml +4 -1
- package/templates/qwik/c3.ts +3 -3
- package/templates/qwik/templates/worker-configuration.d.ts +1 -1
- package/templates/qwik/templates/wrangler.toml +28 -2
- package/templates/remix/c3.ts +3 -3
- package/templates/remix/templates/worker-configuration.d.ts +1 -1
- package/templates/remix/templates/wrangler.toml +28 -2
- package/templates/scheduled/js/wrangler.toml +5 -2
- package/templates/scheduled/ts/package.json +2 -1
- package/templates/scheduled/ts/src/index.ts +3 -20
- package/templates/scheduled/ts/worker-configuration.d.ts +4 -0
- package/templates/scheduled/ts/wrangler.toml +5 -2
- package/templates/solid/c3.ts +5 -3
- package/templates/solid/templates/wrangler.toml +77 -0
- package/templates/svelte/c3.ts +3 -3
- package/templates/svelte/js/wrangler.toml +28 -2
- package/templates/svelte/ts/wrangler.toml +28 -2
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
1
2
|
name = "<TBD>"
|
|
2
3
|
main = "src/index.ts"
|
|
3
4
|
compatibility_date = "<TBD>"
|
|
4
5
|
|
|
5
6
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
7
|
+
# Docs:
|
|
8
|
+
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
6
9
|
# Note: Use secrets to store sensitive data.
|
|
7
|
-
#
|
|
10
|
+
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
|
8
11
|
# [vars]
|
|
9
12
|
# MY_VARIABLE = "production_value"
|
|
10
13
|
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"deploy": "wrangler deploy",
|
|
7
7
|
"dev": "wrangler dev",
|
|
8
|
-
"start": "wrangler dev"
|
|
8
|
+
"start": "wrangler dev",
|
|
9
|
+
"cf-typegen": "wrangler types"
|
|
9
10
|
},
|
|
10
11
|
"devDependencies": {
|
|
11
|
-
"@cloudflare/workers-types": "^4.20231218.0",
|
|
12
12
|
"typescript": "^5.0.4",
|
|
13
13
|
"wrangler": "^3.0.0"
|
|
14
14
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DurableObject } from "cloudflare:workers";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Welcome to Cloudflare Workers! This is your first Durable Objects application.
|
|
3
5
|
*
|
|
@@ -5,9 +7,13 @@
|
|
|
5
7
|
* - Open a browser tab at http://localhost:8787/ to see your Durable Object in action
|
|
6
8
|
* - Run `npm run deploy` to publish your application
|
|
7
9
|
*
|
|
10
|
+
* Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
|
|
11
|
+
* `Env` object can be regenerated with `npm run cf-typegen`.
|
|
12
|
+
*
|
|
8
13
|
* Learn more at https://developers.cloudflare.com/durable-objects
|
|
9
14
|
*/
|
|
10
15
|
|
|
16
|
+
|
|
11
17
|
/**
|
|
12
18
|
* Associate bindings declared in wrangler.toml with the TypeScript type system
|
|
13
19
|
*/
|
|
@@ -16,7 +22,7 @@ export interface Env {
|
|
|
16
22
|
// MY_KV_NAMESPACE: KVNamespace;
|
|
17
23
|
//
|
|
18
24
|
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
|
19
|
-
MY_DURABLE_OBJECT: DurableObjectNamespace
|
|
25
|
+
MY_DURABLE_OBJECT: DurableObjectNamespace<MyDurableObject>;
|
|
20
26
|
//
|
|
21
27
|
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
|
|
22
28
|
// MY_BUCKET: R2Bucket;
|
|
@@ -29,25 +35,27 @@ export interface Env {
|
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
/** A Durable Object's behavior is defined in an exported Javascript class */
|
|
32
|
-
export class MyDurableObject {
|
|
38
|
+
export class MyDurableObject extends DurableObject {
|
|
33
39
|
/**
|
|
34
40
|
* The constructor is invoked once upon creation of the Durable Object, i.e. the first call to
|
|
35
|
-
* `DurableObjectStub::get` for a given identifier
|
|
41
|
+
* `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
|
|
36
42
|
*
|
|
37
|
-
* @param
|
|
43
|
+
* @param ctx - The interface for interacting with Durable Object state
|
|
38
44
|
* @param env - The interface to reference bindings declared in wrangler.toml
|
|
39
45
|
*/
|
|
40
|
-
constructor(
|
|
46
|
+
constructor(ctx: DurableObjectState, env: Env) {
|
|
47
|
+
super(ctx, env);
|
|
48
|
+
}
|
|
41
49
|
|
|
42
50
|
/**
|
|
43
|
-
* The Durable Object
|
|
44
|
-
*
|
|
51
|
+
* The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable
|
|
52
|
+
* Object instance receives a request from a Worker via the same method invokation on the stub
|
|
45
53
|
*
|
|
46
|
-
* @param
|
|
47
|
-
* @returns The
|
|
54
|
+
* @param name - The name provided to a Durable Object instance from a Worker
|
|
55
|
+
* @returns The greeting to be sent back to the Worker
|
|
48
56
|
*/
|
|
49
|
-
async
|
|
50
|
-
return
|
|
57
|
+
async sayHello(name: string): Promise<string> {
|
|
58
|
+
return `Hello, ${name}!`;
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -67,12 +75,12 @@ export default {
|
|
|
67
75
|
|
|
68
76
|
// This stub creates a communication channel with the Durable Object instance
|
|
69
77
|
// The Durable Object constructor will be invoked upon the first call for a given id
|
|
70
|
-
let stub
|
|
78
|
+
let stub = env.MY_DURABLE_OBJECT.get(id);
|
|
71
79
|
|
|
72
|
-
// We call `
|
|
73
|
-
//
|
|
74
|
-
let
|
|
80
|
+
// We call the `sayHello()` RPC method on the stub to invoke the method on the remote
|
|
81
|
+
// Durable Object instance
|
|
82
|
+
let greeting = await stub.sayHello("world");
|
|
75
83
|
|
|
76
|
-
return
|
|
84
|
+
return new Response(greeting);
|
|
77
85
|
},
|
|
78
86
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
1
2
|
name = "<TBD>"
|
|
2
3
|
main = "src/index.ts"
|
|
3
4
|
compatibility_date = "<TBD>"
|
|
4
5
|
|
|
5
6
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
7
|
+
# Docs:
|
|
8
|
+
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
6
9
|
# Note: Use secrets to store sensitive data.
|
|
7
|
-
#
|
|
10
|
+
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
|
8
11
|
# [vars]
|
|
9
12
|
# MY_VARIABLE = "production_value"
|
|
10
13
|
|
|
@@ -95,4 +98,3 @@ new_classes = ["MyDurableObject"]
|
|
|
95
98
|
# [[vectorize]]
|
|
96
99
|
# binding = "MY_INDEX"
|
|
97
100
|
# index_name = "my-index"
|
|
98
|
-
|
|
@@ -1,4 +1,101 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
1
2
|
name = "<TBD>"
|
|
2
3
|
main = "src/entry.py"
|
|
3
4
|
compatibility_flags = ["python_workers"]
|
|
4
5
|
compatibility_date = "<TBD>"
|
|
6
|
+
|
|
7
|
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
8
|
+
# Docs:
|
|
9
|
+
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
10
|
+
# Note: Use secrets to store sensitive data.
|
|
11
|
+
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
|
12
|
+
# [vars]
|
|
13
|
+
# MY_VARIABLE = "production_value"
|
|
14
|
+
|
|
15
|
+
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
|
|
16
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
17
|
+
# [ai]
|
|
18
|
+
# binding = "AI"
|
|
19
|
+
|
|
20
|
+
# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
|
|
21
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
22
|
+
# [[analytics_engine_datasets]]
|
|
23
|
+
# binding = "MY_DATASET"
|
|
24
|
+
|
|
25
|
+
# Bind a headless browser instance running on Cloudflare's global network.
|
|
26
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
27
|
+
# [browser]
|
|
28
|
+
# binding = "MY_BROWSER"
|
|
29
|
+
|
|
30
|
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
|
31
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
32
|
+
# [[d1_databases]]
|
|
33
|
+
# binding = "MY_DB"
|
|
34
|
+
# database_name = "my-database"
|
|
35
|
+
# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
36
|
+
|
|
37
|
+
# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
|
|
38
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
39
|
+
# [[dispatch_namespaces]]
|
|
40
|
+
# binding = "MY_DISPATCHER"
|
|
41
|
+
# namespace = "my-namespace"
|
|
42
|
+
|
|
43
|
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
44
|
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
45
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
46
|
+
# [[durable_objects.bindings]]
|
|
47
|
+
# name = "MY_DURABLE_OBJECT"
|
|
48
|
+
# class_name = "MyDurableObject"
|
|
49
|
+
|
|
50
|
+
# Durable Object migrations.
|
|
51
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
|
|
52
|
+
# [[migrations]]
|
|
53
|
+
# tag = "v1"
|
|
54
|
+
# new_classes = ["MyDurableObject"]
|
|
55
|
+
|
|
56
|
+
# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
|
|
57
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
58
|
+
# [[hyperdrive]]
|
|
59
|
+
# binding = "MY_HYPERDRIVE"
|
|
60
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
61
|
+
|
|
62
|
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
|
63
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
64
|
+
# [[kv_namespaces]]
|
|
65
|
+
# binding = "MY_KV_NAMESPACE"
|
|
66
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
67
|
+
|
|
68
|
+
# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
|
|
69
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
70
|
+
# [[mtls_certificates]]
|
|
71
|
+
# binding = "MY_CERTIFICATE"
|
|
72
|
+
# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
73
|
+
|
|
74
|
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
75
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
76
|
+
# [[queues.producers]]
|
|
77
|
+
# binding = "MY_QUEUE"
|
|
78
|
+
# queue = "my-queue"
|
|
79
|
+
|
|
80
|
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
|
81
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
82
|
+
# [[queues.consumers]]
|
|
83
|
+
# queue = "my-queue"
|
|
84
|
+
|
|
85
|
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
|
86
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
87
|
+
# [[r2_buckets]]
|
|
88
|
+
# binding = "MY_BUCKET"
|
|
89
|
+
# bucket_name = "my-bucket"
|
|
90
|
+
|
|
91
|
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
|
92
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
93
|
+
# [[services]]
|
|
94
|
+
# binding = "MY_SERVICE"
|
|
95
|
+
# service = "my-service"
|
|
96
|
+
|
|
97
|
+
# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
|
|
98
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
99
|
+
# [[vectorize]]
|
|
100
|
+
# binding = "MY_INDEX"
|
|
101
|
+
# index_name = "my-index"
|
package/templates/hono/c3.ts
CHANGED
|
@@ -1,24 +1,77 @@
|
|
|
1
1
|
import { logRaw } from "@cloudflare/cli";
|
|
2
|
+
import { brandColor, dim } from "@cloudflare/cli/colors";
|
|
3
|
+
import { spinner } from "@cloudflare/cli/interactive";
|
|
2
4
|
import { runFrameworkGenerator } from "frameworks/index";
|
|
5
|
+
import { loadTemplateSnippets, transformFile } from "helpers/codemod";
|
|
6
|
+
import { detectPackageManager } from "helpers/packageManagers";
|
|
3
7
|
import type { TemplateConfig } from "../../src/templates";
|
|
8
|
+
import type * as recast from "recast";
|
|
4
9
|
import type { C3Context } from "types";
|
|
5
10
|
|
|
6
11
|
const generate = async (ctx: C3Context) => {
|
|
12
|
+
const { name: pm } = detectPackageManager();
|
|
13
|
+
|
|
7
14
|
await runFrameworkGenerator(ctx, [
|
|
8
15
|
ctx.project.name,
|
|
9
16
|
"--template",
|
|
10
17
|
"cloudflare-workers",
|
|
18
|
+
"--install",
|
|
19
|
+
"--pm",
|
|
20
|
+
pm,
|
|
11
21
|
]);
|
|
12
22
|
|
|
13
23
|
logRaw(""); // newline
|
|
14
24
|
};
|
|
15
25
|
|
|
26
|
+
const configure = async (ctx: C3Context) => {
|
|
27
|
+
const indexFile = "src/index.ts";
|
|
28
|
+
|
|
29
|
+
const s = spinner();
|
|
30
|
+
s.start(`Updating \`${indexFile}\``);
|
|
31
|
+
|
|
32
|
+
const snippets = loadTemplateSnippets(ctx);
|
|
33
|
+
|
|
34
|
+
transformFile(indexFile, {
|
|
35
|
+
// Insert the env declaration after the last import (but before the rest of the body)
|
|
36
|
+
visitProgram: function (n) {
|
|
37
|
+
const lastImportIndex = n.node.body.findLastIndex(
|
|
38
|
+
(t) => t.type === "ImportDeclaration"
|
|
39
|
+
);
|
|
40
|
+
const lastImport = n.get("body", lastImportIndex);
|
|
41
|
+
lastImport.insertAfter(...snippets.bindingsTypeTs);
|
|
42
|
+
|
|
43
|
+
return this.traverse(n);
|
|
44
|
+
},
|
|
45
|
+
visitVariableDeclarator(n) {
|
|
46
|
+
if (n.node.id.type === "Identifier" && n.node.id.name === "app") {
|
|
47
|
+
n.node.init = snippets
|
|
48
|
+
.appDeclarationTs[0] as recast.types.namedTypes.NewExpression;
|
|
49
|
+
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
s.stop(`${brandColor("updated")} \`${dim(indexFile)}\``);
|
|
56
|
+
};
|
|
57
|
+
|
|
16
58
|
const config: TemplateConfig = {
|
|
17
59
|
configVersion: 1,
|
|
18
60
|
id: "hono",
|
|
19
61
|
displayName: "Hono",
|
|
62
|
+
copyFiles: {
|
|
63
|
+
path: "./templates",
|
|
64
|
+
},
|
|
20
65
|
platform: "workers",
|
|
21
66
|
generate,
|
|
67
|
+
configure,
|
|
68
|
+
transformPackageJson: async () => ({
|
|
69
|
+
scripts: {
|
|
70
|
+
dev: "wrangler dev",
|
|
71
|
+
deploy: "wrangler deploy --minify",
|
|
72
|
+
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
22
75
|
devScript: "dev",
|
|
23
76
|
deployScript: "deploy",
|
|
24
77
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
new Hono<{ Bindings: Bindings }>()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type Bindings = Record<string, unknown> & CloudflareBindings
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
2
|
+
name = "<TBD>"
|
|
3
|
+
main = "src/index.ts"
|
|
4
|
+
compatibility_date = "<TBD>"
|
|
5
|
+
|
|
6
|
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
7
|
+
# Docs:
|
|
8
|
+
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
9
|
+
# Note: Use secrets to store sensitive data.
|
|
10
|
+
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
|
11
|
+
# [vars]
|
|
12
|
+
# MY_VARIABLE = "production_value"
|
|
13
|
+
|
|
14
|
+
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
|
|
15
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
16
|
+
# [ai]
|
|
17
|
+
# binding = "AI"
|
|
18
|
+
|
|
19
|
+
# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
|
|
20
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
21
|
+
# [[analytics_engine_datasets]]
|
|
22
|
+
# binding = "MY_DATASET"
|
|
23
|
+
|
|
24
|
+
# Bind a headless browser instance running on Cloudflare's global network.
|
|
25
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
26
|
+
# [browser]
|
|
27
|
+
# binding = "MY_BROWSER"
|
|
28
|
+
|
|
29
|
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
|
30
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
31
|
+
# [[d1_databases]]
|
|
32
|
+
# binding = "MY_DB"
|
|
33
|
+
# database_name = "my-database"
|
|
34
|
+
# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
35
|
+
|
|
36
|
+
# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
|
|
37
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
38
|
+
# [[dispatch_namespaces]]
|
|
39
|
+
# binding = "MY_DISPATCHER"
|
|
40
|
+
# namespace = "my-namespace"
|
|
41
|
+
|
|
42
|
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
43
|
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
44
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
45
|
+
# [[durable_objects.bindings]]
|
|
46
|
+
# name = "MY_DURABLE_OBJECT"
|
|
47
|
+
# class_name = "MyDurableObject"
|
|
48
|
+
|
|
49
|
+
# Durable Object migrations.
|
|
50
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
|
|
51
|
+
# [[migrations]]
|
|
52
|
+
# tag = "v1"
|
|
53
|
+
# new_classes = ["MyDurableObject"]
|
|
54
|
+
|
|
55
|
+
# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
|
|
56
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
57
|
+
# [[hyperdrive]]
|
|
58
|
+
# binding = "MY_HYPERDRIVE"
|
|
59
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
60
|
+
|
|
61
|
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
|
62
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
63
|
+
# [[kv_namespaces]]
|
|
64
|
+
# binding = "MY_KV_NAMESPACE"
|
|
65
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
66
|
+
|
|
67
|
+
# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
|
|
68
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
69
|
+
# [[mtls_certificates]]
|
|
70
|
+
# binding = "MY_CERTIFICATE"
|
|
71
|
+
# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
72
|
+
|
|
73
|
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
74
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
75
|
+
# [[queues.producers]]
|
|
76
|
+
# binding = "MY_QUEUE"
|
|
77
|
+
# queue = "my-queue"
|
|
78
|
+
|
|
79
|
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
|
80
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
81
|
+
# [[queues.consumers]]
|
|
82
|
+
# queue = "my-queue"
|
|
83
|
+
|
|
84
|
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
|
85
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
86
|
+
# [[r2_buckets]]
|
|
87
|
+
# binding = "MY_BUCKET"
|
|
88
|
+
# bucket_name = "my-bucket"
|
|
89
|
+
|
|
90
|
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
|
91
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
92
|
+
# [[services]]
|
|
93
|
+
# binding = "MY_SERVICE"
|
|
94
|
+
# service = "my-service"
|
|
95
|
+
|
|
96
|
+
# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
|
|
97
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
98
|
+
# [[vectorize]]
|
|
99
|
+
# binding = "MY_INDEX"
|
|
100
|
+
# index_name = "my-index"
|
package/templates/next/README.md
CHANGED
|
@@ -52,15 +52,15 @@ In order to enable the example:
|
|
|
52
52
|
```
|
|
53
53
|
# KV Example:
|
|
54
54
|
```
|
|
55
|
-
- If you're using TypeScript run the `
|
|
55
|
+
- If you're using TypeScript run the `cf-typegen` script to update the `env.d.ts` file:
|
|
56
56
|
```bash
|
|
57
|
-
npm run
|
|
57
|
+
npm run cf-typegen
|
|
58
58
|
# or
|
|
59
|
-
yarn
|
|
59
|
+
yarn cf-typegen
|
|
60
60
|
# or
|
|
61
|
-
pnpm
|
|
61
|
+
pnpm cf-typegen
|
|
62
62
|
# or
|
|
63
|
-
bun
|
|
63
|
+
bun cf-typegen
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
After doing this you can run the `dev` or `preview` script and visit the `/api/hello` route to see the example in action.
|
package/templates/next/c3.ts
CHANGED
|
@@ -221,10 +221,10 @@ export default {
|
|
|
221
221
|
return {
|
|
222
222
|
scripts: {
|
|
223
223
|
"pages:build": `${pmCommand} ${nextOnPagesCommand}`,
|
|
224
|
-
preview: `${pagesBuildRunCommand} && wrangler pages dev
|
|
225
|
-
deploy: `${pagesBuildRunCommand} && wrangler pages deploy
|
|
224
|
+
preview: `${pagesBuildRunCommand} && wrangler pages dev`,
|
|
225
|
+
deploy: `${pagesBuildRunCommand} && wrangler pages deploy`,
|
|
226
226
|
...(usesTypescript(ctx) && {
|
|
227
|
-
"
|
|
227
|
+
"cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`,
|
|
228
228
|
}),
|
|
229
229
|
},
|
|
230
230
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
1
2
|
name = "<TBD>"
|
|
2
3
|
compatibility_date = "<TBD>"
|
|
3
4
|
compatibility_flags = ["nodejs_compat"]
|
|
5
|
+
pages_build_output_dir = ".vercel/output/static"
|
|
4
6
|
|
|
5
7
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
8
|
+
# Docs:
|
|
9
|
+
# - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
|
|
6
10
|
# Note: Use secrets to store sensitive data.
|
|
7
|
-
#
|
|
11
|
+
# - https://developers.cloudflare.com/pages/functions/bindings/#secrets
|
|
8
12
|
# [vars]
|
|
9
13
|
# MY_VARIABLE = "production_value"
|
|
10
14
|
|
|
@@ -52,3 +56,24 @@ compatibility_flags = ["nodejs_compat"]
|
|
|
52
56
|
# binding = "MY_SERVICE"
|
|
53
57
|
# service = "my-service"
|
|
54
58
|
|
|
59
|
+
# To use different bindings for preview and production environments, follow the examples below.
|
|
60
|
+
# When using environment-specific overrides for bindings, ALL bindings must be specified on a per-environment basis.
|
|
61
|
+
# Docs: https://developers.cloudflare.com/pages/functions/wrangler-configuration#environment-specific-overrides
|
|
62
|
+
|
|
63
|
+
######## PREVIEW environment config ########
|
|
64
|
+
|
|
65
|
+
# [env.preview.vars]
|
|
66
|
+
# API_KEY = "xyz789"
|
|
67
|
+
|
|
68
|
+
# [[env.preview.kv_namespaces]]
|
|
69
|
+
# binding = "MY_KV_NAMESPACE"
|
|
70
|
+
# id = "<PREVIEW_NAMESPACE_ID>"
|
|
71
|
+
|
|
72
|
+
######## PRODUCTION environment config ########
|
|
73
|
+
|
|
74
|
+
# [env.production.vars]
|
|
75
|
+
# API_KEY = "abc123"
|
|
76
|
+
|
|
77
|
+
# [[env.production.kv_namespaces]]
|
|
78
|
+
# binding = "MY_KV_NAMESPACE"
|
|
79
|
+
# id = "<PRODUCTION_NAMESPACE_ID>"
|
package/templates/nuxt/c3.ts
CHANGED
|
@@ -56,7 +56,7 @@ const updateEnvTypes = (ctx: C3Context) => {
|
|
|
56
56
|
|
|
57
57
|
let file = readFile(filepath);
|
|
58
58
|
|
|
59
|
-
let typesEntrypoint = `@cloudflare/workers-types
|
|
59
|
+
let typesEntrypoint = `@cloudflare/workers-types`;
|
|
60
60
|
const latestEntrypoint = getLatestTypesEntrypoint(ctx);
|
|
61
61
|
if (latestEntrypoint) {
|
|
62
62
|
typesEntrypoint += `/${latestEntrypoint}`;
|
|
@@ -122,9 +122,9 @@ const config: TemplateConfig = {
|
|
|
122
122
|
configure,
|
|
123
123
|
transformPackageJson: async () => ({
|
|
124
124
|
scripts: {
|
|
125
|
-
deploy: `${npm} run build && wrangler pages deploy
|
|
126
|
-
preview: `${npm} run build && wrangler pages dev
|
|
127
|
-
"
|
|
125
|
+
deploy: `${npm} run build && wrangler pages deploy`,
|
|
126
|
+
preview: `${npm} run build && wrangler pages dev`,
|
|
127
|
+
"cf-typegen": `wrangler types`,
|
|
128
128
|
},
|
|
129
129
|
}),
|
|
130
130
|
devScript: "dev",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
1
2
|
name = "<TBD>"
|
|
2
3
|
compatibility_date = "<TBD>"
|
|
4
|
+
pages_build_output_dir = "./dist"
|
|
3
5
|
|
|
4
6
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
7
|
+
# Docs:
|
|
8
|
+
# - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
|
|
5
9
|
# Note: Use secrets to store sensitive data.
|
|
6
|
-
#
|
|
10
|
+
# - https://developers.cloudflare.com/pages/functions/bindings/#secrets
|
|
7
11
|
# [vars]
|
|
8
12
|
# MY_VARIABLE = "production_value"
|
|
9
13
|
|
|
@@ -49,4 +53,26 @@ compatibility_date = "<TBD>"
|
|
|
49
53
|
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
|
|
50
54
|
# [[services]]
|
|
51
55
|
# binding = "MY_SERVICE"
|
|
52
|
-
# service = "my-service"
|
|
56
|
+
# service = "my-service"
|
|
57
|
+
|
|
58
|
+
# To use different bindings for preview and production environments, follow the examples below.
|
|
59
|
+
# When using environment-specific overrides for bindings, ALL bindings must be specified on a per-environment basis.
|
|
60
|
+
# Docs: https://developers.cloudflare.com/pages/functions/wrangler-configuration#environment-specific-overrides
|
|
61
|
+
|
|
62
|
+
######## PREVIEW environment config ########
|
|
63
|
+
|
|
64
|
+
# [env.preview.vars]
|
|
65
|
+
# API_KEY = "xyz789"
|
|
66
|
+
|
|
67
|
+
# [[env.preview.kv_namespaces]]
|
|
68
|
+
# binding = "MY_KV_NAMESPACE"
|
|
69
|
+
# id = "<PREVIEW_NAMESPACE_ID>"
|
|
70
|
+
|
|
71
|
+
######## PRODUCTION environment config ########
|
|
72
|
+
|
|
73
|
+
# [env.production.vars]
|
|
74
|
+
# API_KEY = "abc123"
|
|
75
|
+
|
|
76
|
+
# [[env.production.kv_namespaces]]
|
|
77
|
+
# binding = "MY_KV_NAMESPACE"
|
|
78
|
+
# id = "<PRODUCTION_NAMESPACE_ID>"
|