create-cloudflare 2.20.0 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/cli.js +71 -28
  2. package/package.json +3 -3
  3. package/templates/analog/templates/wrangler.toml +7 -0
  4. package/templates/astro/templates/wrangler.toml +7 -0
  5. package/templates/common/js/wrangler.toml +7 -0
  6. package/templates/common/ts/wrangler.toml +7 -0
  7. package/templates/hello-world/js/wrangler.toml +7 -0
  8. package/templates/hello-world/ts/wrangler.toml +7 -0
  9. package/templates/hello-world-durable-object/js/src/index.js +18 -14
  10. package/templates/hello-world-durable-object/js/wrangler.toml +7 -0
  11. package/templates/hello-world-durable-object/ts/package.json +0 -1
  12. package/templates/hello-world-durable-object/ts/src/index.ts +40 -15
  13. package/templates/hello-world-durable-object/ts/wrangler.toml +7 -0
  14. package/templates/hello-world-python/py/wrangler.toml +7 -0
  15. package/templates/hono/c3.ts +53 -0
  16. package/templates/hono/snippets/appDeclaration.ts +1 -0
  17. package/templates/hono/snippets/bindingsType.ts +1 -0
  18. package/templates/hono/templates/worker-configuration.d.ts +4 -0
  19. package/templates/hono/templates/wrangler.toml +107 -0
  20. package/templates/next/wrangler.toml +7 -0
  21. package/templates/nuxt/templates/wrangler.toml +7 -0
  22. package/templates/openapi/ts/wrangler.toml +7 -0
  23. package/templates/queues/js/wrangler.toml +7 -0
  24. package/templates/queues/ts/wrangler.toml +7 -0
  25. package/templates/qwik/templates/wrangler.toml +7 -0
  26. package/templates/remix/templates/wrangler.toml +7 -0
  27. package/templates/scheduled/js/wrangler.toml +7 -0
  28. package/templates/scheduled/ts/wrangler.toml +7 -0
  29. package/templates/solid/templates/wrangler.toml +7 -0
  30. package/templates/svelte/js/wrangler.toml +7 -0
  31. package/templates/svelte/ts/wrangler.toml +7 -0
package/dist/cli.js CHANGED
@@ -3897,7 +3897,7 @@ var init_args = __esm({
3897
3897
  var version, devDependencies;
3898
3898
  var init_package = __esm({
3899
3899
  "package.json"() {
3900
- version = "2.20.0";
3900
+ version = "2.21.0";
3901
3901
  devDependencies = {
3902
3902
  "@babel/parser": "^7.21.3",
3903
3903
  "@babel/types": "^7.21.4",
@@ -3905,7 +3905,7 @@ var init_package = __esm({
3905
3905
  "@cloudflare/cli": "workspace:*",
3906
3906
  "@cloudflare/eslint-config-worker": "*",
3907
3907
  "@cloudflare/workers-tsconfig": "workspace:*",
3908
- "@cloudflare/workers-types": "^4.20240405.0",
3908
+ "@cloudflare/workers-types": "^4.20240419.0",
3909
3909
  "@iarna/toml": "^3.0.0",
3910
3910
  "@types/command-exists": "^1.2.0",
3911
3911
  "@types/cross-spawn": "^6.0.2",
@@ -24607,7 +24607,7 @@ var init_package2 = __esm({
24607
24607
  "create-analog": "1.2.0",
24608
24608
  "@angular/create": "17.2.3",
24609
24609
  "create-docusaurus": "3.1.1",
24610
- "create-hono": "0.5.0",
24610
+ "create-hono": "0.7.0",
24611
24611
  "create-next-app": "14.1.0",
24612
24612
  "create-qwik": "1.4.5",
24613
24613
  "create-react-app": "5.0.1",
@@ -70931,25 +70931,68 @@ var c3_exports6 = {};
70931
70931
  __export(c3_exports6, {
70932
70932
  default: () => c3_default6
70933
70933
  });
70934
- var generate6, config6, c3_default6;
70934
+ var generate6, configure4, config6, c3_default6;
70935
70935
  var init_c36 = __esm({
70936
70936
  "templates/hono/c3.ts"() {
70937
70937
  init_cli();
70938
+ init_colors();
70939
+ init_interactive();
70938
70940
  init_frameworks();
70941
+ init_codemod();
70942
+ init_packageManagers();
70939
70943
  generate6 = async (ctx) => {
70944
+ const { name: pm3 } = detectPackageManager();
70940
70945
  await runFrameworkGenerator(ctx, [
70941
70946
  ctx.project.name,
70942
70947
  "--template",
70943
- "cloudflare-workers"
70948
+ "cloudflare-workers",
70949
+ "--install",
70950
+ "--pm",
70951
+ pm3
70944
70952
  ]);
70945
70953
  logRaw("");
70946
70954
  };
70955
+ configure4 = async (ctx) => {
70956
+ const indexFile = "src/index.ts";
70957
+ const s = spinner();
70958
+ s.start(`Updating \`${indexFile}\``);
70959
+ const snippets = loadTemplateSnippets(ctx);
70960
+ transformFile(indexFile, {
70961
+ // Insert the env declaration after the last import (but before the rest of the body)
70962
+ visitProgram: function(n2) {
70963
+ const lastImportIndex = n2.node.body.findLastIndex(
70964
+ (t) => t.type === "ImportDeclaration"
70965
+ );
70966
+ const lastImport = n2.get("body", lastImportIndex);
70967
+ lastImport.insertAfter(...snippets.bindingsTypeTs);
70968
+ return this.traverse(n2);
70969
+ },
70970
+ visitVariableDeclarator(n2) {
70971
+ if (n2.node.id.type === "Identifier" && n2.node.id.name === "app") {
70972
+ n2.node.init = snippets.appDeclarationTs[0];
70973
+ return false;
70974
+ }
70975
+ }
70976
+ });
70977
+ s.stop(`${brandColor("updated")} \`${dim(indexFile)}\``);
70978
+ };
70947
70979
  config6 = {
70948
70980
  configVersion: 1,
70949
70981
  id: "hono",
70950
70982
  displayName: "Hono",
70983
+ copyFiles: {
70984
+ path: "./templates"
70985
+ },
70951
70986
  platform: "workers",
70952
70987
  generate: generate6,
70988
+ configure: configure4,
70989
+ transformPackageJson: async () => ({
70990
+ scripts: {
70991
+ dev: "wrangler dev",
70992
+ deploy: "wrangler deploy --minify",
70993
+ "cf-typegen": "wrangler types --env-interface CloudflareBindings"
70994
+ }
70995
+ }),
70953
70996
  devScript: "dev",
70954
70997
  deployScript: "deploy"
70955
70998
  };
@@ -70964,7 +71007,7 @@ __export(c3_exports7, {
70964
71007
  shouldInstallNextOnPagesEslintPlugin: () => shouldInstallNextOnPagesEslintPlugin,
70965
71008
  writeEslintrc: () => writeEslintrc
70966
71009
  });
70967
- var import_path13, npm5, npx3, generate7, updateNextConfig, configure4, shouldInstallNextOnPagesEslintPlugin, writeEslintrc, addDevDependencies, c3_default7;
71010
+ var import_path13, npm5, npx3, generate7, updateNextConfig, configure5, shouldInstallNextOnPagesEslintPlugin, writeEslintrc, addDevDependencies, c3_default7;
70968
71011
  var init_c37 = __esm({
70969
71012
  "templates/next/c3.ts"() {
70970
71013
  import_path13 = require("path");
@@ -71011,7 +71054,7 @@ ${$1}`
71011
71054
  writeFile2(configFile, updatedConfigFile);
71012
71055
  s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
71013
71056
  };
71014
- configure4 = async (ctx) => {
71057
+ configure5 = async (ctx) => {
71015
71058
  const projectPath = ctx.project.path;
71016
71059
  const path4 = probePaths([
71017
71060
  `${projectPath}/pages/api`,
@@ -71091,7 +71134,7 @@ ${$1}`
71091
71134
  platform: "pages",
71092
71135
  displayName: "Next",
71093
71136
  generate: generate7,
71094
- configure: configure4,
71137
+ configure: configure5,
71095
71138
  copyFiles: {
71096
71139
  async selectVariant(ctx) {
71097
71140
  const isApp = probePaths([
@@ -71153,7 +71196,7 @@ var c3_exports8 = {};
71153
71196
  __export(c3_exports8, {
71154
71197
  default: () => c3_default8
71155
71198
  });
71156
- var recast4, npm6, pm2, generate8, configure5, updateEnvTypes2, updateNuxtConfig, config7, c3_default8;
71199
+ var recast4, npm6, pm2, generate8, configure6, updateEnvTypes2, updateNuxtConfig, config7, c3_default8;
71157
71200
  var init_c38 = __esm({
71158
71201
  "templates/nuxt/c3.ts"() {
71159
71202
  init_cli();
@@ -71179,7 +71222,7 @@ var init_c38 = __esm({
71179
71222
  writeFile2("./.node-version", "17");
71180
71223
  logRaw("");
71181
71224
  };
71182
- configure5 = async (ctx) => {
71225
+ configure6 = async (ctx) => {
71183
71226
  const packages = ["nitro-cloudflare-dev"];
71184
71227
  if (pm2 === "pnpm") {
71185
71228
  packages.push("h3");
@@ -71246,7 +71289,7 @@ var init_c38 = __esm({
71246
71289
  path: "./templates"
71247
71290
  },
71248
71291
  generate: generate8,
71249
- configure: configure5,
71292
+ configure: configure6,
71250
71293
  transformPackageJson: async () => ({
71251
71294
  scripts: {
71252
71295
  deploy: `${npm6} run build && wrangler pages deploy`,
@@ -71267,7 +71310,7 @@ var c3_exports9 = {};
71267
71310
  __export(c3_exports9, {
71268
71311
  default: () => c3_default9
71269
71312
  });
71270
- var recast5, npm7, npx4, generate9, configure6, addBindingsProxy, populateCloudflareEnv, config8, c3_default9;
71313
+ var recast5, npm7, npx4, generate9, configure7, addBindingsProxy, populateCloudflareEnv, config8, c3_default9;
71271
71314
  var init_c39 = __esm({
71272
71315
  "templates/qwik/c3.ts"() {
71273
71316
  init_cli();
@@ -71283,7 +71326,7 @@ var init_c39 = __esm({
71283
71326
  generate9 = async (ctx) => {
71284
71327
  await runFrameworkGenerator(ctx, ["basic", ctx.project.name]);
71285
71328
  };
71286
- configure6 = async (ctx) => {
71329
+ configure7 = async (ctx) => {
71287
71330
  const cmd = [npx4, "qwik", "add", "cloudflare-pages"];
71288
71331
  endSection(`Running ${quoteShellArgs(cmd)}`);
71289
71332
  await runCommand(cmd);
@@ -71369,7 +71412,7 @@ var init_c39 = __esm({
71369
71412
  path: "./templates"
71370
71413
  },
71371
71414
  generate: generate9,
71372
- configure: configure6,
71415
+ configure: configure7,
71373
71416
  transformPackageJson: async () => ({
71374
71417
  scripts: {
71375
71418
  deploy: `${npm7} run build && wrangler pages deploy`,
@@ -71426,7 +71469,7 @@ var c3_exports11 = {};
71426
71469
  __export(c3_exports11, {
71427
71470
  default: () => c3_default11
71428
71471
  });
71429
- var npm9, generate11, configure7, config10, c3_default11;
71472
+ var npm9, generate11, configure8, config10, c3_default11;
71430
71473
  var init_c311 = __esm({
71431
71474
  "templates/remix/c3.ts"() {
71432
71475
  init_cli();
@@ -71444,7 +71487,7 @@ var init_c311 = __esm({
71444
71487
  ]);
71445
71488
  logRaw("");
71446
71489
  };
71447
- configure7 = async () => {
71490
+ configure8 = async () => {
71448
71491
  const typeDefsPath = "load-context.ts";
71449
71492
  const s = spinner();
71450
71493
  s.start(`Updating \`${typeDefsPath}\``);
@@ -71468,7 +71511,7 @@ var init_c311 = __esm({
71468
71511
  path: "./templates"
71469
71512
  },
71470
71513
  generate: generate11,
71471
- configure: configure7,
71514
+ configure: configure8,
71472
71515
  transformPackageJson: async () => ({
71473
71516
  scripts: {
71474
71517
  deploy: `${npm9} run build && wrangler pages deploy`,
@@ -71489,7 +71532,7 @@ var c3_exports12 = {};
71489
71532
  __export(c3_exports12, {
71490
71533
  default: () => c3_default12
71491
71534
  });
71492
- var recast6, npm10, generate12, configure8, config11, c3_default12;
71535
+ var recast6, npm10, generate12, configure9, config11, c3_default12;
71493
71536
  var init_c312 = __esm({
71494
71537
  "templates/solid/c3.ts"() {
71495
71538
  init_cli();
@@ -71504,7 +71547,7 @@ var init_c312 = __esm({
71504
71547
  await runFrameworkGenerator(ctx, ["-p", ctx.project.name, "-s"]);
71505
71548
  logRaw("");
71506
71549
  };
71507
- configure8 = async (ctx) => {
71550
+ configure9 = async (ctx) => {
71508
71551
  usesTypescript(ctx);
71509
71552
  const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
71510
71553
  updateStatus(`Updating configuration in ${blue(filePath)}`);
@@ -71550,7 +71593,7 @@ var init_c312 = __esm({
71550
71593
  path: "./templates"
71551
71594
  },
71552
71595
  generate: generate12,
71553
- configure: configure8,
71596
+ configure: configure9,
71554
71597
  transformPackageJson: async () => ({
71555
71598
  scripts: {
71556
71599
  preview: `${npm10} run build && npx wrangler pages dev`,
@@ -71571,7 +71614,7 @@ var c3_exports13 = {};
71571
71614
  __export(c3_exports13, {
71572
71615
  default: () => c3_default13
71573
71616
  });
71574
- var import_node_os, recast7, npm11, generate13, configure9, updateSvelteConfig, updateTypeDefinitions, config12, c3_default13;
71617
+ var import_node_os, recast7, npm11, generate13, configure10, updateSvelteConfig, updateTypeDefinitions, config12, c3_default13;
71575
71618
  var init_c313 = __esm({
71576
71619
  "templates/svelte/c3.ts"() {
71577
71620
  import_node_os = require("node:os");
@@ -71588,7 +71631,7 @@ var init_c313 = __esm({
71588
71631
  await runFrameworkGenerator(ctx, [ctx.project.name]);
71589
71632
  logRaw("");
71590
71633
  };
71591
- configure9 = async (ctx) => {
71634
+ configure10 = async (ctx) => {
71592
71635
  const pkg = `@sveltejs/adapter-cloudflare`;
71593
71636
  await installPackages([pkg], {
71594
71637
  dev: true,
@@ -71659,7 +71702,7 @@ var init_c313 = __esm({
71659
71702
  }
71660
71703
  },
71661
71704
  generate: generate13,
71662
- configure: configure9,
71705
+ configure: configure10,
71663
71706
  transformPackageJson: async (original, ctx) => {
71664
71707
  let scripts = {
71665
71708
  preview: `${npm11} run build && wrangler pages dev`,
@@ -77802,7 +77845,7 @@ init_command();
77802
77845
  init_packageManagers();
77803
77846
 
77804
77847
  // ../wrangler/package.json
77805
- var version2 = "3.51.1";
77848
+ var version2 = "3.52.0";
77806
77849
 
77807
77850
  // src/git.ts
77808
77851
  init_package();
@@ -79389,7 +79432,7 @@ var printSummary = async (ctx) => {
79389
79432
  const { npm: npm14 } = detectPackageManager();
79390
79433
  const dirRelativePath = (0, import_path10.relative)(ctx.originalCWD, ctx.project.path);
79391
79434
  const nextSteps = [
79392
- dirRelativePath ? ["Navigate to the new directory", `cd ${dirRelativePath}`] : [],
79435
+ ...dirRelativePath ? [["Navigate to the new directory", `cd ${dirRelativePath}`]] : [],
79393
79436
  [
79394
79437
  "Run the development server",
79395
79438
  quoteShellArgs([npm14, "run", ctx.template.devScript ?? "start"])
@@ -79408,7 +79451,7 @@ var printSummary = async (ctx) => {
79408
79451
  "Read the documentation",
79409
79452
  `https://developers.cloudflare.com/${ctx.template.platform}`
79410
79453
  ],
79411
- ["Stuck? Join us at", "https://discord.gg/cloudflaredev"]
79454
+ ["Stuck? Join us at", "https://discord.cloudflare.com"]
79412
79455
  ];
79413
79456
  if (ctx.deployment.url) {
79414
79457
  const msg = [
@@ -80889,7 +80932,7 @@ var setupProjectDirectory = (args) => {
80889
80932
  };
80890
80933
  var runTemplate = async (ctx) => {
80891
80934
  await create(ctx);
80892
- await configure10(ctx);
80935
+ await configure11(ctx);
80893
80936
  await deploy(ctx);
80894
80937
  await printSummary(ctx);
80895
80938
  };
@@ -80905,7 +80948,7 @@ var create = async (ctx) => {
80905
80948
  await rectifyPmMismatch(ctx);
80906
80949
  endSection(`Application created`);
80907
80950
  };
80908
- var configure10 = async (ctx) => {
80951
+ var configure11 = async (ctx) => {
80909
80952
  startSection("Configuring your application for Cloudflare", "Step 2 of 3");
80910
80953
  await installWrangler();
80911
80954
  await installWorkersTypes(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.20.0",
3
+ "version": "2.21.0",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -30,7 +30,7 @@
30
30
  "@babel/types": "^7.21.4",
31
31
  "@clack/prompts": "^0.6.3",
32
32
  "@cloudflare/eslint-config-worker": "*",
33
- "@cloudflare/workers-types": "^4.20240405.0",
33
+ "@cloudflare/workers-types": "^4.20240419.0",
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
@@ -70,7 +70,7 @@
70
70
  "yarn": "^1.22.19",
71
71
  "@cloudflare/cli": "1.1.1",
72
72
  "@cloudflare/workers-tsconfig": "0.0.0",
73
- "wrangler": "3.51.1"
73
+ "wrangler": "3.52.0"
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=18.14.1"
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = "./dist/analog/public"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Note: Use secrets to store sensitive data.
8
15
  # Docs:
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = "./dist"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.js"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -4,6 +4,13 @@ main = "src/index.js"
4
4
  compatibility_date = "<TBD>"
5
5
  compatibility_flags = ["nodejs_compat"]
6
6
 
7
+ # Automatically place your workloads in an optimal location to minimize latency.
8
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
9
+ # rather than the end user may result in better performance.
10
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
11
+ # [placement]
12
+ # mode = "smart"
13
+
7
14
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
8
15
  # Docs:
9
16
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -4,6 +4,13 @@ main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
  compatibility_flags = ["nodejs_compat"]
6
6
 
7
+ # Automatically place your workloads in an optimal location to minimize latency.
8
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
9
+ # rather than the end user may result in better performance.
10
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
11
+ # [placement]
12
+ # mode = "smart"
13
+
7
14
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
8
15
  # Docs:
9
16
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -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
  *
@@ -16,25 +18,27 @@
16
18
  */
17
19
 
18
20
  /** A Durable Object's behavior is defined in an exported Javascript class */
19
- export class MyDurableObject {
21
+ export class MyDurableObject extends DurableObject {
20
22
  /**
21
23
  * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to
22
- * `DurableObjectStub::get` for a given identifier
24
+ * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
23
25
  *
24
- * @param {DurableObjectState} state - The interface for interacting with Durable Object state
26
+ * @param {DurableObjectState} ctx - The interface for interacting with Durable Object state
25
27
  * @param {Env} env - The interface to reference bindings declared in wrangler.toml
26
28
  */
27
- constructor(state, env) {}
29
+ constructor(ctx, env) {
30
+ super(ctx, env);
31
+ }
28
32
 
29
33
  /**
30
- * The Durable Object fetch handler will be invoked when a Durable Object instance receives a
31
- * request from a Worker via an associated stub
34
+ * The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable
35
+ * Object instance receives a request from a Worker via the same method invokation on the stub
32
36
  *
33
- * @param {Request} request - The request submitted to a Durable Object instance from a Worker
34
- * @returns {Promise<Response>} The response to be sent back to the Worker
37
+ * @param {string} name - The name provided to a Durable Object instance from a Worker
38
+ * @returns {Promise<string>} The greeting to be sent back to the Worker
35
39
  */
36
- async fetch(request) {
37
- return new Response('Hello World');
40
+ async sayHello(name) {
41
+ return `Hello, ${name}!`;
38
42
  }
39
43
  }
40
44
 
@@ -56,10 +60,10 @@ export default {
56
60
  // The Durable Object constructor will be invoked upon the first call for a given id
57
61
  let stub = env.MY_DURABLE_OBJECT.get(id);
58
62
 
59
- // We call `fetch()` on the stub to send a request to the Durable Object instance
60
- // The Durable Object instance will invoke its fetch handler to handle the request
61
- let response = await stub.fetch(request);
63
+ // We call the `sayHello()` RPC method on the stub to invoke the method on the remote
64
+ // Durable Object instance
65
+ let greeting = await stub.sayHello("world");
62
66
 
63
- return response;
67
+ return new Response(greeting);
64
68
  },
65
69
  };
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -9,7 +9,6 @@
9
9
  "cf-typegen": "wrangler types"
10
10
  },
11
11
  "devDependencies": {
12
- "@cloudflare/workers-types": "^4.20231218.0",
13
12
  "typescript": "^5.0.4",
14
13
  "wrangler": "^3.0.0"
15
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
  *
@@ -11,26 +13,49 @@
11
13
  * Learn more at https://developers.cloudflare.com/durable-objects
12
14
  */
13
15
 
16
+
17
+ /**
18
+ * Associate bindings declared in wrangler.toml with the TypeScript type system
19
+ */
20
+ export interface Env {
21
+ // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
22
+ // MY_KV_NAMESPACE: KVNamespace;
23
+ //
24
+ // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
25
+ MY_DURABLE_OBJECT: DurableObjectNamespace<MyDurableObject>;
26
+ //
27
+ // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
28
+ // MY_BUCKET: R2Bucket;
29
+ //
30
+ // Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
31
+ // MY_SERVICE: Fetcher;
32
+ //
33
+ // Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/
34
+ // MY_QUEUE: Queue;
35
+ }
36
+
14
37
  /** A Durable Object's behavior is defined in an exported Javascript class */
15
- export class MyDurableObject {
38
+ export class MyDurableObject extends DurableObject {
16
39
  /**
17
40
  * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to
18
- * `DurableObjectStub::get` for a given identifier
41
+ * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
19
42
  *
20
- * @param state - The interface for interacting with Durable Object state
43
+ * @param ctx - The interface for interacting with Durable Object state
21
44
  * @param env - The interface to reference bindings declared in wrangler.toml
22
45
  */
23
- constructor(state: DurableObjectState, env: Env) {}
46
+ constructor(ctx: DurableObjectState, env: Env) {
47
+ super(ctx, env);
48
+ }
24
49
 
25
50
  /**
26
- * The Durable Object fetch handler will be invoked when a Durable Object instance receives a
27
- * request from a Worker via an associated stub
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
28
53
  *
29
- * @param request - The request submitted to a Durable Object instance from a Worker
30
- * @returns The response to be sent back to the Worker
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
31
56
  */
32
- async fetch(request: Request): Promise<Response> {
33
- return new Response('Hello World');
57
+ async sayHello(name: string): Promise<string> {
58
+ return `Hello, ${name}!`;
34
59
  }
35
60
  }
36
61
 
@@ -50,12 +75,12 @@ export default {
50
75
 
51
76
  // This stub creates a communication channel with the Durable Object instance
52
77
  // The Durable Object constructor will be invoked upon the first call for a given id
53
- let stub: DurableObjectStub = env.MY_DURABLE_OBJECT.get(id);
78
+ let stub = env.MY_DURABLE_OBJECT.get(id);
54
79
 
55
- // We call `fetch()` on the stub to send a request to the Durable Object instance
56
- // The Durable Object instance will invoke its fetch handler to handle the request
57
- let response = await stub.fetch(request);
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");
58
83
 
59
- return response;
84
+ return new Response(greeting);
60
85
  },
61
86
  };
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -4,6 +4,13 @@ main = "src/entry.py"
4
4
  compatibility_flags = ["python_workers"]
5
5
  compatibility_date = "<TBD>"
6
6
 
7
+ # Automatically place your workloads in an optimal location to minimize latency.
8
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
9
+ # rather than the end user may result in better performance.
10
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
11
+ # [placement]
12
+ # mode = "smart"
13
+
7
14
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
8
15
  # Docs:
9
16
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -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,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface CloudflareBindings {
4
+ }
@@ -0,0 +1,107 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ main = "src/index.ts"
4
+ compatibility_date = "<TBD>"
5
+
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
13
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
14
+ # Docs:
15
+ # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
16
+ # Note: Use secrets to store sensitive data.
17
+ # - https://developers.cloudflare.com/workers/configuration/secrets/
18
+ # [vars]
19
+ # MY_VARIABLE = "production_value"
20
+
21
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
22
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
23
+ # [ai]
24
+ # binding = "AI"
25
+
26
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
27
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
28
+ # [[analytics_engine_datasets]]
29
+ # binding = "MY_DATASET"
30
+
31
+ # Bind a headless browser instance running on Cloudflare's global network.
32
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
33
+ # [browser]
34
+ # binding = "MY_BROWSER"
35
+
36
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
37
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
38
+ # [[d1_databases]]
39
+ # binding = "MY_DB"
40
+ # database_name = "my-database"
41
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
42
+
43
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
44
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
45
+ # [[dispatch_namespaces]]
46
+ # binding = "MY_DISPATCHER"
47
+ # namespace = "my-namespace"
48
+
49
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
50
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
51
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
52
+ # [[durable_objects.bindings]]
53
+ # name = "MY_DURABLE_OBJECT"
54
+ # class_name = "MyDurableObject"
55
+
56
+ # Durable Object migrations.
57
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
58
+ # [[migrations]]
59
+ # tag = "v1"
60
+ # new_classes = ["MyDurableObject"]
61
+
62
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
63
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
64
+ # [[hyperdrive]]
65
+ # binding = "MY_HYPERDRIVE"
66
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
67
+
68
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
69
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
70
+ # [[kv_namespaces]]
71
+ # binding = "MY_KV_NAMESPACE"
72
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
73
+
74
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
75
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
76
+ # [[mtls_certificates]]
77
+ # binding = "MY_CERTIFICATE"
78
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
79
+
80
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
81
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
82
+ # [[queues.producers]]
83
+ # binding = "MY_QUEUE"
84
+ # queue = "my-queue"
85
+
86
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
87
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
88
+ # [[queues.consumers]]
89
+ # queue = "my-queue"
90
+
91
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
92
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
93
+ # [[r2_buckets]]
94
+ # binding = "MY_BUCKET"
95
+ # bucket_name = "my-bucket"
96
+
97
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
98
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
99
+ # [[services]]
100
+ # binding = "MY_SERVICE"
101
+ # service = "my-service"
102
+
103
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
104
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
105
+ # [[vectorize]]
106
+ # binding = "MY_INDEX"
107
+ # index_name = "my-index"
@@ -4,6 +4,13 @@ compatibility_date = "<TBD>"
4
4
  compatibility_flags = ["nodejs_compat"]
5
5
  pages_build_output_dir = ".vercel/output/static"
6
6
 
7
+ # Automatically place your workloads in an optimal location to minimize latency.
8
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
9
+ # rather than the end user may result in better performance.
10
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
11
+ # [placement]
12
+ # mode = "smart"
13
+
7
14
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
8
15
  # Docs:
9
16
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = "./dist"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.js"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = "./dist"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = "./build/client"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -9,6 +9,13 @@ compatibility_date = "<TBD>"
9
9
  [triggers]
10
10
  crons = ["* * * * *"] # * * * * * = run every minute
11
11
 
12
+ # Automatically place your workloads in an optimal location to minimize latency.
13
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
14
+ # rather than the end user may result in better performance.
15
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
16
+ # [placement]
17
+ # mode = "smart"
18
+
12
19
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
13
20
  # Docs:
14
21
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -9,6 +9,13 @@ compatibility_date = "<TBD>"
9
9
  [triggers]
10
10
  crons = ["* * * * *"] # * * * * * = run every minute
11
11
 
12
+ # Automatically place your workloads in an optimal location to minimize latency.
13
+ # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
14
+ # rather than the end user may result in better performance.
15
+ # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
16
+ # [placement]
17
+ # mode = "smart"
18
+
12
19
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
13
20
  # Docs:
14
21
  # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
@@ -4,6 +4,13 @@ compatibility_date = "<TBD>"
4
4
  compatibility_flags = ["nodejs_compat"]
5
5
  pages_build_output_dir = "./dist"
6
6
 
7
+ # Automatically place your workloads in an optimal location to minimize latency.
8
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
9
+ # rather than the end user may result in better performance.
10
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
11
+ # [placement]
12
+ # mode = "smart"
13
+
7
14
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
8
15
  # Note: Use secrets to store sensitive data.
9
16
  # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = ".svelte-kit/cloudflare"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
@@ -3,6 +3,13 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  pages_build_output_dir = ".svelte-kit/cloudflare"
5
5
 
6
+ # Automatically place your workloads in an optimal location to minimize latency.
7
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
8
+ # rather than the end user may result in better performance.
9
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
10
+ # [placement]
11
+ # mode = "smart"
12
+
6
13
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
14
  # Docs:
8
15
  # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables