create-cloudflare 0.0.0-bd00dc82 → 0.0.0-bd2031bd

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.
Files changed (60) hide show
  1. package/dist/cli.js +830 -696
  2. package/package.json +4 -4
  3. package/templates/analog/c3.ts +134 -0
  4. package/templates/analog/snippets/devBindingsModule.ts +7 -0
  5. package/templates/analog/templates/env.d.ts +13 -0
  6. package/templates/analog/templates/src/dev-bindings.ts +18 -0
  7. package/templates/analog/templates/worker-configuration.d.ts +4 -0
  8. package/templates/analog/templates/wrangler.toml +78 -0
  9. package/templates/astro/c3.ts +3 -3
  10. package/templates/astro/templates/wrangler.toml +28 -2
  11. package/templates/common/js/wrangler.toml +4 -1
  12. package/templates/common/ts/package.json +2 -1
  13. package/templates/common/ts/src/index.ts +3 -0
  14. package/templates/common/ts/worker-configuration.d.ts +2 -14
  15. package/templates/common/ts/wrangler.toml +4 -1
  16. package/templates/hello-world/js/package.json +2 -1
  17. package/templates/hello-world/js/test/index.spec.js +17 -17
  18. package/templates/hello-world/js/wrangler.toml +4 -1
  19. package/templates/hello-world/ts/package.json +2 -1
  20. package/templates/hello-world/ts/src/index.ts +3 -17
  21. package/templates/hello-world/ts/test/index.spec.ts +17 -17
  22. package/templates/hello-world/ts/worker-configuration.d.ts +4 -0
  23. package/templates/hello-world/ts/wrangler.toml +4 -1
  24. package/templates/hello-world-durable-object/js/wrangler.toml +4 -1
  25. package/templates/hello-world-durable-object/ts/package.json +2 -1
  26. package/templates/hello-world-durable-object/ts/src/index.ts +3 -20
  27. package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +6 -0
  28. package/templates/hello-world-durable-object/ts/wrangler.toml +4 -2
  29. package/templates/hello-world-python/py/wrangler.toml +97 -0
  30. package/templates/next/README.md +5 -5
  31. package/templates/next/c3.ts +3 -3
  32. package/templates/next/wrangler.toml +26 -1
  33. package/templates/nuxt/c3.ts +4 -4
  34. package/templates/nuxt/templates/worker-configuration.d.ts +1 -1
  35. package/templates/nuxt/templates/wrangler.toml +28 -2
  36. package/templates/openapi/ts/package.json +2 -1
  37. package/templates/openapi/ts/worker-configuration.d.ts +4 -0
  38. package/templates/openapi/ts/wrangler.toml +97 -0
  39. package/templates/pre-existing/js/wrangler.toml +1 -0
  40. package/templates/queues/js/wrangler.toml +4 -1
  41. package/templates/queues/ts/package.json +2 -1
  42. package/templates/queues/ts/src/index.ts +3 -5
  43. package/templates/queues/ts/worker-configuration.d.ts +5 -0
  44. package/templates/queues/ts/wrangler.toml +4 -1
  45. package/templates/qwik/c3.ts +3 -3
  46. package/templates/qwik/templates/worker-configuration.d.ts +1 -1
  47. package/templates/qwik/templates/wrangler.toml +28 -2
  48. package/templates/remix/c3.ts +3 -3
  49. package/templates/remix/templates/worker-configuration.d.ts +1 -1
  50. package/templates/remix/templates/wrangler.toml +28 -2
  51. package/templates/scheduled/js/wrangler.toml +5 -2
  52. package/templates/scheduled/ts/package.json +2 -1
  53. package/templates/scheduled/ts/src/index.ts +3 -20
  54. package/templates/scheduled/ts/worker-configuration.d.ts +4 -0
  55. package/templates/scheduled/ts/wrangler.toml +5 -2
  56. package/templates/solid/c3.ts +5 -3
  57. package/templates/solid/templates/wrangler.toml +77 -0
  58. package/templates/svelte/c3.ts +3 -3
  59. package/templates/svelte/js/wrangler.toml +28 -2
  60. package/templates/svelte/ts/wrangler.toml +28 -2
@@ -0,0 +1,6 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ MY_DURABLE_OBJECT: DurableObjectNamespace;
5
+ }
6
+
@@ -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
- # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
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"
@@ -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 `build-cf-types` script to update the `env.d.ts` file:
55
+ - If you're using TypeScript run the `cf-typegen` script to update the `env.d.ts` file:
56
56
  ```bash
57
- npm run build-cf-types
57
+ npm run cf-typegen
58
58
  # or
59
- yarn build-cf-types
59
+ yarn cf-typegen
60
60
  # or
61
- pnpm build-cf-types
61
+ pnpm cf-typegen
62
62
  # or
63
- bun build-cf-types
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.
@@ -221,10 +221,10 @@ export default {
221
221
  return {
222
222
  scripts: {
223
223
  "pages:build": `${pmCommand} ${nextOnPagesCommand}`,
224
- preview: `${pagesBuildRunCommand} && wrangler pages dev .vercel/output/static`,
225
- deploy: `${pagesBuildRunCommand} && wrangler pages deploy .vercel/output/static`,
224
+ preview: `${pagesBuildRunCommand} && wrangler pages dev`,
225
+ deploy: `${pagesBuildRunCommand} && wrangler pages deploy`,
226
226
  ...(usesTypescript(ctx) && {
227
- "build-cf-types": `wrangler types --env-interface CloudflareEnv env.d.ts`,
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
- # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
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>"
@@ -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 ./dist`,
126
- preview: `${npm} run build && wrangler pages dev ./dist`,
127
- "build-cf-types": `wrangler types`,
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,4 +1,4 @@
1
1
  // Generated by Wrangler
2
- // After adding bindings to `wrangler.toml`, regenerate this interface via `npm build-cf-types`
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
3
  interface Env {
4
4
  }
@@ -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
- # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
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>"
@@ -5,7 +5,8 @@
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
  "dependencies": {
11
12
  "@cloudflare/itty-router-openapi": "^1.0.1"
@@ -0,0 +1,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ }
@@ -1,3 +1,100 @@
1
+ #:schema node_modules/wrangler/config-schema.json
1
2
  name = "<TBD>"
2
3
  main = "src/index.ts"
3
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"
@@ -1,3 +1,4 @@
1
+ #:schema node_modules/wrangler/config-schema.json
1
2
  name = "<TBD>"
2
3
  main = "src/index.js"
3
4
  compatibility_date = "<TBD>"
@@ -1,10 +1,13 @@
1
+ #:schema node_modules/wrangler/config-schema.json
1
2
  name = "<TBD>"
2
3
  main = "src/index.js"
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
- # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
10
+ # - https://developers.cloudflare.com/workers/configuration/secrets/
8
11
  # [vars]
9
12
  # MY_VARIABLE = "production_value"
10
13
 
@@ -5,7 +5,8 @@
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
12
  "typescript": "^5.0.4",
@@ -8,14 +8,12 @@
8
8
  * - Open a browser tab at http://localhost:8787/ to see your worker in action
9
9
  * - Run `npm run deploy` to publish your worker
10
10
  *
11
+ * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
12
+ * `Env` object can be regenerated with `npm run cf-typegen`.
13
+ *
11
14
  * Learn more at https://developers.cloudflare.com/workers/
12
15
  */
13
16
 
14
- export interface Env {
15
- // Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/
16
- MY_QUEUE: Queue;
17
- }
18
-
19
17
  export default {
20
18
  // Our fetch handler is invoked on a HTTP request: we can send a message to a queue
21
19
  // during (or after) a request.
@@ -0,0 +1,5 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ MY_QUEUE: Queue;
5
+ }
@@ -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
- # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
10
+ # - https://developers.cloudflare.com/workers/configuration/secrets/
8
11
  # [vars]
9
12
  # MY_VARIABLE = "production_value"
10
13
 
@@ -134,9 +134,9 @@ const config: TemplateConfig = {
134
134
  configure,
135
135
  transformPackageJson: async () => ({
136
136
  scripts: {
137
- deploy: `${npm} run build && wrangler pages deploy ./dist`,
138
- preview: `${npm} run build && wrangler pages dev ./dist`,
139
- "build-cf-types": `wrangler types`,
137
+ deploy: `${npm} run build && wrangler pages deploy`,
138
+ preview: `${npm} run build && wrangler pages dev`,
139
+ "cf-typegen": `wrangler types`,
140
140
  },
141
141
  }),
142
142
  devScript: "dev",
@@ -1,4 +1,4 @@
1
1
  // Generated by Wrangler
2
- // After adding bindings to `wrangler.toml`, regenerate this interface via `npm build-cf-types`
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
3
  interface Env {
4
4
  }
@@ -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
- # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
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>"
@@ -54,9 +54,9 @@ const config: TemplateConfig = {
54
54
  configure,
55
55
  transformPackageJson: async () => ({
56
56
  scripts: {
57
- deploy: `${npm} run build && wrangler pages deploy ./build/client`,
58
- preview: `${npm} run build && wrangler pages dev ./build/client`,
59
- "build-cf-types": `wrangler types`,
57
+ deploy: `${npm} run build && wrangler pages deploy`,
58
+ preview: `${npm} run build && wrangler pages dev`,
59
+ "cf-typegen": `wrangler types`,
60
60
  },
61
61
  }),
62
62
  devScript: "dev",
@@ -1,4 +1,4 @@
1
1
  // Generated by Wrangler
2
- // After adding bindings to `wrangler.toml`, regenerate this interface via `npm build-cf-types`
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
3
  interface Env {
4
4
  }
@@ -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 = "./build/client"
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
- # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
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>"
@@ -1,3 +1,4 @@
1
+ #:schema node_modules/wrangler/config-schema.json
1
2
  name = "<TBD>"
2
3
  main = "src/index.js"
3
4
  compatibility_date = "<TBD>"
@@ -9,8 +10,10 @@ compatibility_date = "<TBD>"
9
10
  crons = ["* * * * *"] # * * * * * = run every minute
10
11
 
11
12
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
13
+ # Docs:
14
+ # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
12
15
  # Note: Use secrets to store sensitive data.
13
- # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
16
+ # - https://developers.cloudflare.com/workers/configuration/secrets/
14
17
  # [vars]
15
18
  # MY_VARIABLE = "production_value"
16
19
 
@@ -100,4 +103,4 @@ crons = ["* * * * *"] # * * * * * = run every minute
100
103
  # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
101
104
  # [[vectorize]]
102
105
  # binding = "MY_INDEX"
103
- # index_name = "my-index"
106
+ # index_name = "my-index"
@@ -5,7 +5,8 @@
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
12
  "typescript": "^5.0.4",