create-cloudflare 0.0.0-99bf5f86 → 0.0.0-9a8d36f1

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 (57) hide show
  1. package/dist/cli.js +21679 -20427
  2. package/package.json +6 -6
  3. package/templates/angular/c3.ts +7 -9
  4. package/templates/astro/c3.ts +77 -16
  5. package/templates/astro/snippets/runtimeDeclaration.ts +4 -0
  6. package/templates/astro/templates/wrangler.toml +50 -0
  7. package/templates/common/c3.ts +7 -6
  8. package/templates/docusaurus/c3.ts +3 -4
  9. package/templates/gatsby/c3.ts +5 -3
  10. package/templates/hello-world/c3.ts +7 -6
  11. package/templates/hello-world-durable-object/c3.ts +7 -6
  12. package/templates/hono/c3.ts +2 -2
  13. package/templates/next/README.md +58 -0
  14. package/templates/next/app/js/app/api/hello/route.js +21 -0
  15. package/templates/next/app/js/app/not-found.js +58 -0
  16. package/templates/next/app/ts/app/api/hello/route.ts +22 -0
  17. package/templates/next/app/ts/app/not-found.tsx +58 -0
  18. package/templates/next/c3.ts +76 -71
  19. package/templates/next/env.d.ts +7 -0
  20. package/templates/next/pages/js/pages/api/hello.js +23 -0
  21. package/templates/next/pages/ts/pages/api/hello.ts +24 -0
  22. package/templates/next/wrangler.toml +57 -0
  23. package/templates/nuxt/c3.ts +91 -17
  24. package/templates/nuxt/templates/env.d.ts +14 -0
  25. package/templates/nuxt/templates/worker-configuration.d.ts +3 -0
  26. package/templates/nuxt/templates/wrangler.toml +50 -0
  27. package/templates/openapi/c3.ts +0 -1
  28. package/templates/pre-existing/c3.ts +2 -4
  29. package/templates/queues/c3.ts +7 -6
  30. package/templates/qwik/c3.ts +114 -4
  31. package/templates/qwik/snippets/getPlatformProxy.ts +6 -0
  32. package/templates/qwik/templates/worker-configuration.d.ts +3 -0
  33. package/templates/qwik/templates/wrangler.toml +50 -0
  34. package/templates/react/c3.ts +5 -3
  35. package/templates/remix/c3.ts +38 -5
  36. package/templates/remix/templates/worker-configuration.d.ts +3 -0
  37. package/templates/remix/templates/wrangler.toml +50 -0
  38. package/templates/scheduled/c3.ts +7 -6
  39. package/templates/solid/c3.ts +51 -18
  40. package/templates/svelte/c3.ts +81 -27
  41. package/templates/svelte/js/src/hooks.server.js +25 -0
  42. package/templates/svelte/js/wrangler.toml +50 -0
  43. package/templates/svelte/ts/src/hooks.server.ts +24 -0
  44. package/templates/svelte/ts/wrangler.toml +50 -0
  45. package/templates/vue/c3.ts +5 -4
  46. package/templates/chatgptPlugin/c3.ts +0 -10
  47. package/templates/chatgptPlugin/ts/.assets/example.png +0 -0
  48. package/templates/chatgptPlugin/ts/README.md +0 -25
  49. package/templates/chatgptPlugin/ts/__dot__gitignore +0 -171
  50. package/templates/chatgptPlugin/ts/package.json +0 -16
  51. package/templates/chatgptPlugin/ts/src/index.ts +0 -33
  52. package/templates/chatgptPlugin/ts/src/search.ts +0 -59
  53. package/templates/chatgptPlugin/ts/wrangler.toml +0 -3
  54. package/templates/next/templates.ts +0 -281
  55. package/templates/solid/js/vite.config.js +0 -7
  56. package/templates/solid/ts/vite.config.ts +0 -7
  57. package/templates/svelte/templates.ts +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-99bf5f86",
3
+ "version": "0.0.0-9a8d36f1",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -40,7 +40,6 @@
40
40
  "@types/esprima": "^4.0.3",
41
41
  "@types/node": "^18.15.3",
42
42
  "@types/semver": "^7.5.1",
43
- "@types/shell-quote": "^1.7.2",
44
43
  "@types/which-pm-runs": "^1.0.0",
45
44
  "@types/yargs": "^17.0.22",
46
45
  "@typescript-eslint/eslint-plugin": "^5.55.0",
@@ -51,6 +50,7 @@
51
50
  "deepmerge": "^4.3.1",
52
51
  "degit": "^2.8.4",
53
52
  "dns2": "^2.1.0",
53
+ "dotenv": "^16.0.0",
54
54
  "esbuild": "^0.17.12",
55
55
  "execa": "^7.1.1",
56
56
  "glob": "^10.3.3",
@@ -60,16 +60,15 @@
60
60
  "pnpm": "^8.10.0",
61
61
  "recast": "^0.22.0",
62
62
  "semver": "^7.5.1",
63
- "shell-quote": "^1.8.1",
64
63
  "typescript": "^5.0.2",
65
- "undici": "5.28.2",
64
+ "undici": "5.28.3",
66
65
  "vite-tsconfig-paths": "^4.0.8",
67
66
  "which-pm-runs": "^1.1.0",
68
67
  "yargs": "^17.7.1",
69
68
  "yarn": "^1.22.19",
70
69
  "@cloudflare/cli": "1.1.1",
71
- "@cloudflare/workers-tsconfig": "0.0.0",
72
- "wrangler": "3.24.0"
70
+ "wrangler": "3.32.0",
71
+ "@cloudflare/workers-tsconfig": "0.0.0"
73
72
  },
74
73
  "engines": {
75
74
  "node": ">=18.14.1"
@@ -79,6 +78,7 @@
79
78
  },
80
79
  "scripts": {
81
80
  "build": "node -r esbuild-register scripts/build.ts",
81
+ "dev:codemod": "node -r esbuild-register scripts/codemodDev.ts",
82
82
  "check:lint": "eslint .",
83
83
  "check:type": "tsc",
84
84
  "lint": "eslint",
@@ -1,4 +1,3 @@
1
- import { cp } from "node:fs/promises";
2
1
  import { resolve } from "node:path";
3
2
  import { logRaw } from "@cloudflare/cli";
4
3
  import { brandColor, dim } from "@cloudflare/cli/colors";
@@ -19,10 +18,10 @@ const generate = async (ctx: C3Context) => {
19
18
  const configure = async (ctx: C3Context) => {
20
19
  updateAngularJson(ctx);
21
20
  await updateAppCode();
22
- await installCFWorker(ctx);
21
+ await installCFWorker();
23
22
  };
24
23
 
25
- async function installCFWorker(ctx: C3Context) {
24
+ async function installCFWorker() {
26
25
  await installPackages(
27
26
  ["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
28
27
  {
@@ -82,19 +81,18 @@ const config: TemplateConfig = {
82
81
  copyFiles: {
83
82
  path: "./templates",
84
83
  },
84
+ devScript: "start",
85
+ deployScript: "deploy",
85
86
  generate,
86
87
  configure,
87
88
  transformPackageJson: async () => ({
88
89
  scripts: {
89
- start: `${npm} run pages:build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
90
+ start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
91
+ build: `ng build && ${npm} run process`,
90
92
  process:
91
93
  "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
92
- "pages:build": `ng build && ${npm} run process`,
93
- deploy: `${npm} run pages:build && wrangler pages deploy dist/cloudflare`,
94
+ deploy: `${npm} run build && wrangler pages deploy dist/cloudflare`,
94
95
  },
95
96
  }),
96
- deployCommand: ["deploy"],
97
- devCommand: ["start"],
98
- testFlags: ["--style", "sass"],
99
97
  };
100
98
  export default config;
@@ -1,10 +1,12 @@
1
- import { logRaw } from "@cloudflare/cli";
2
- import { brandColor, dim } from "@cloudflare/cli/colors";
1
+ import { logRaw, updateStatus } from "@cloudflare/cli";
2
+ import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { loadTemplateSnippets, transformFile } from "helpers/codemod";
3
4
  import { runCommand, runFrameworkGenerator } from "helpers/command";
4
- import { compatDateFlag } from "helpers/files";
5
+ import { usesTypescript } from "helpers/files";
5
6
  import { detectPackageManager } from "helpers/packages";
7
+ import * as recast from "recast";
6
8
  import type { TemplateConfig } from "../../src/templates";
7
- import type { C3Context } from "types";
9
+ import type { C3Context, PackageJson } from "types";
8
10
 
9
11
  const { npx } = detectPackageManager();
10
12
 
@@ -22,6 +24,67 @@ const configure = async (ctx: C3Context) => {
22
24
  `via \`${npx} astro add cloudflare\``
23
25
  )}`,
24
26
  });
27
+
28
+ updateAstroConfig();
29
+ updateEnvDeclaration(ctx);
30
+ };
31
+
32
+ const updateAstroConfig = () => {
33
+ const filePath = "astro.config.mjs";
34
+
35
+ updateStatus(`Updating configuration in ${blue(filePath)}`);
36
+
37
+ transformFile(filePath, {
38
+ visitCallExpression: function (n) {
39
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
40
+ if (callee.name !== "cloudflare") {
41
+ return this.traverse(n);
42
+ }
43
+
44
+ const b = recast.types.builders;
45
+ n.node.arguments = [
46
+ b.objectExpression([
47
+ b.objectProperty(
48
+ b.identifier("runtime"),
49
+ b.objectExpression([
50
+ b.objectProperty(b.identifier("mode"), b.stringLiteral("local")),
51
+ ])
52
+ ),
53
+ ]),
54
+ ];
55
+
56
+ return false;
57
+ },
58
+ });
59
+ };
60
+
61
+ const updateEnvDeclaration = (ctx: C3Context) => {
62
+ if (!usesTypescript(ctx)) {
63
+ return;
64
+ }
65
+
66
+ const filePath = "src/env.d.ts";
67
+
68
+ updateStatus(`Adding type declarations in ${blue(filePath)}`);
69
+
70
+ transformFile(filePath, {
71
+ visitProgram: function (n) {
72
+ const snippets = loadTemplateSnippets(ctx);
73
+ const patch = snippets.runtimeDeclarationTs;
74
+ const b = recast.types.builders;
75
+
76
+ // Preserve comments with the new body
77
+ const comments = n.get("comments").value;
78
+ n.node.comments = comments.map((c: recast.types.namedTypes.CommentLine) =>
79
+ b.commentLine(c.value)
80
+ );
81
+
82
+ // Add the patch
83
+ n.get("body").push(...patch);
84
+
85
+ return false;
86
+ },
87
+ });
25
88
  };
26
89
 
27
90
  const config: TemplateConfig = {
@@ -29,22 +92,20 @@ const config: TemplateConfig = {
29
92
  id: "astro",
30
93
  platform: "pages",
31
94
  displayName: "Astro",
95
+ copyFiles: {
96
+ path: "./templates",
97
+ },
98
+ devScript: "dev",
99
+ deployScript: "deploy",
100
+ previewScript: "preview",
32
101
  generate,
33
102
  configure,
34
- transformPackageJson: async () => ({
103
+ transformPackageJson: async (pkgJson: PackageJson, ctx: C3Context) => ({
35
104
  scripts: {
36
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} -- astro dev`,
37
- "pages:deploy": `astro build && wrangler pages deploy ./dist`,
105
+ deploy: `astro build && wrangler pages deploy ./dist`,
106
+ preview: `astro build && wrangler pages dev ./dist`,
107
+ ...(usesTypescript(ctx) && { "build-cf-types": `wrangler types` }),
38
108
  },
39
109
  }),
40
- testFlags: [
41
- "--skip-houston",
42
- "--no-install",
43
- "--no-git",
44
- "--template",
45
- "blog",
46
- "--typescript",
47
- "strict",
48
- ],
49
110
  };
50
111
  export default config;
@@ -0,0 +1,4 @@
1
+ type Runtime = import("@astrojs/cloudflare").DirectoryRuntime<Env>;
2
+ declare namespace App {
3
+ interface Locals extends Runtime {}
4
+ }
@@ -0,0 +1,50 @@
1
+ name = "<TBD>"
2
+ compatibility_date = "<TBD>"
3
+
4
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
5
+ # Note: Use secrets to store sensitive data.
6
+ # Docs: https://developers.cloudflare.com/workers/platform/environment-variables
7
+ # [vars]
8
+ # MY_VARIABLE = "production_value"
9
+
10
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
11
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
12
+ # [[kv_namespaces]]
13
+ # binding = "MY_KV_NAMESPACE"
14
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
15
+
16
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
17
+ # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
18
+ # [[r2_buckets]]
19
+ # binding = "MY_BUCKET"
20
+ # bucket_name = "my-bucket"
21
+
22
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
23
+ # Docs: https://developers.cloudflare.com/queues/get-started
24
+ # [[queues.producers]]
25
+ # binding = "MY_QUEUE"
26
+ # queue = "my-queue"
27
+
28
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
29
+ # Docs: https://developers.cloudflare.com/queues/get-started
30
+ # [[queues.consumers]]
31
+ # queue = "my-queue"
32
+
33
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
34
+ # Docs: https://developers.cloudflare.com/workers/platform/services
35
+ # [[services]]
36
+ # binding = "MY_SERVICE"
37
+ # service = "my-service"
38
+
39
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
40
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
41
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
42
+ # [[durable_objects.bindings]]
43
+ # name = "MY_DURABLE_OBJECT"
44
+ # class_name = "MyDurableObject"
45
+
46
+ # Durable Object migrations.
47
+ # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
48
+ # [[migrations]]
49
+ # tag = "v1"
50
+ # new_classes = ["MyDurableObject"]
@@ -3,13 +3,14 @@ export default {
3
3
  id: "common",
4
4
  displayName: "Example router & proxy Worker",
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
- js: {
9
- path: "./js",
10
- },
11
- ts: {
12
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
13
14
  },
14
15
  },
15
16
  };
@@ -1,5 +1,4 @@
1
1
  import { runFrameworkGenerator } from "helpers/command";
2
- import { compatDateFlag } from "helpers/files";
3
2
  import { detectPackageManager } from "helpers/packages";
4
3
  import type { TemplateConfig } from "../../src/templates";
5
4
  import type { C3Context } from "types";
@@ -18,10 +17,10 @@ const config: TemplateConfig = {
18
17
  generate,
19
18
  transformPackageJson: async () => ({
20
19
  scripts: {
21
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm} run start`,
22
- "pages:deploy": `${npm} run build && wrangler pages deploy ./build`,
20
+ deploy: `${npm} run build && wrangler pages deploy ./build`,
23
21
  },
24
22
  }),
25
- testFlags: [`--package-manager`, npm],
23
+ devScript: "start",
24
+ deployScript: "deploy",
26
25
  };
27
26
  export default config;
@@ -1,6 +1,5 @@
1
1
  import { inputPrompt } from "@cloudflare/cli/interactive";
2
2
  import { runFrameworkGenerator } from "helpers/command";
3
- import { compatDateFlag } from "helpers/files";
4
3
  import { detectPackageManager } from "helpers/packages";
5
4
  import type { TemplateConfig } from "../../src/templates";
6
5
  import type { C3Context } from "types";
@@ -38,9 +37,12 @@ const config: TemplateConfig = {
38
37
  generate,
39
38
  transformPackageJson: async () => ({
40
39
  scripts: {
41
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 8000 -- ${npm} run develop`,
42
- "pages:deploy": `${npm} run build && wrangler pages deploy ./public`,
40
+ deploy: `${npm} run build && wrangler pages deploy ./public`,
41
+ preview: `${npm} run build && wrangler pages dev ./public`,
43
42
  },
44
43
  }),
44
+ devScript: "develop",
45
+ deployScript: "deploy",
46
+ previewScript: "preview",
45
47
  };
46
48
  export default config;
@@ -3,13 +3,14 @@ export default {
3
3
  id: "hello-world",
4
4
  displayName: '"Hello World" Worker',
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
- js: {
9
- path: "./js",
10
- },
11
- ts: {
12
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
13
14
  },
14
15
  },
15
16
  };
@@ -3,13 +3,14 @@ export default {
3
3
  id: "hello-world-durable-object",
4
4
  displayName: '"Hello World" Durable Object',
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
- js: {
9
- path: "./js",
10
- },
11
- ts: {
12
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
13
14
  },
14
15
  },
15
16
  };
@@ -19,7 +19,7 @@ const config: TemplateConfig = {
19
19
  displayName: "Hono",
20
20
  platform: "workers",
21
21
  generate,
22
- devCommand: ["dev"],
23
- deployCommand: ["deploy"],
22
+ devScript: "dev",
23
+ deployScript: "deploy",
24
24
  };
25
25
  export default config;
@@ -0,0 +1,58 @@
1
+ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`c3`](https://developers.cloudflare.com/pages/get-started/c3).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ ## Cloudflare integration
20
+
21
+ Besides the `dev` script mentioned above `c3` has added a few extra scripts that allow you to integrate the application with the [Cloudflare Pages](https://pages.cloudflare.com/) environment, these are:
22
+ - `pages:build` to build the application for Pages using the [`@cloudflare/next-on-pages`](https://github.com/cloudflare/next-on-pages) CLI
23
+ - `preview` to locally preview your Pages application using the [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI
24
+ - `deploy` to deploy your Pages application using the [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI
25
+
26
+ > __Note:__ while the `dev` script is optimal for local development you should preview your Pages application as well (periodically or before deployments) in order to make sure that it can properly work in the Pages environment (for more details see the [`@cloudflare/next-on-pages` recommended workflow](https://github.com/cloudflare/next-on-pages/blob/05b6256/internal-packages/next-dev/README.md#recommended-workflow))
27
+
28
+ ### Bindings
29
+
30
+ Cloudflare [Bindings](https://developers.cloudflare.com/pages/functions/bindings/) are what allows you to interact with resources available in the Cloudflare Platform.
31
+
32
+ You can use bindings during development, when previewing locally your application and of course in the deployed application:
33
+
34
+ - To use bindings in dev mode you need to define them in the `next.config.js` file under `setupDevBindings`, this mode uses the `next-dev` `@cloudflare/next-on-pages` submodule. For more details see its [documentation](https://github.com/cloudflare/next-on-pages/blob/05b6256/internal-packages/next-dev/README.md).
35
+
36
+ - To use bindings in the preview mode you need to add them to the `pages:preview` script accordingly to the `wrangler pages dev` command. For more details see its [documentation](https://developers.cloudflare.com/workers/wrangler/commands/#dev-1) or the [Pages Bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).
37
+
38
+ - To use bindings in the deployed application you will need to configure them in the Cloudflare [dashboard](https://dash.cloudflare.com/). For more details see the [Pages Bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).
39
+
40
+ #### KV Example
41
+
42
+ `c3` has added for you an example showing how you can use a KV binding.
43
+
44
+ In order to enable the example:
45
+ - Search for javascript/typescript lines containing the following comment:
46
+ ```ts
47
+ // KV Example:
48
+ ```
49
+ and uncomment the commented lines below it.
50
+ - Do the same in the `wrangler.toml` file, where
51
+ the comment is:
52
+ ```
53
+ # KV Example:
54
+ ```
55
+
56
+ After doing this you can run the `dev` or `preview` script and visit the `/api/hello` route to see the example in action.
57
+
58
+ Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.
@@ -0,0 +1,21 @@
1
+ import { getRequestContext } from '@cloudflare/next-on-pages'
2
+
3
+ export const runtime = 'edge'
4
+
5
+ export async function GET(request) {
6
+ let responseText = 'Hello World'
7
+
8
+ // In the edge runtime you can use Bindings that are available in your application
9
+ // (for more details see:
10
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
11
+ // - https://developers.cloudflare.com/pages/functions/bindings/
12
+ // )
13
+ //
14
+ // KV Example:
15
+ // const myKv = getRequestContext().env.MY_KV
16
+ // await myKv.put('suffix', ' from a KV store!')
17
+ // const suffix = await myKv.get('suffix')
18
+ // responseText += suffix
19
+
20
+ return new Response(responseText)
21
+ }
@@ -0,0 +1,58 @@
1
+ export const runtime = "edge";
2
+
3
+ export default function NotFound() {
4
+ return (
5
+ <>
6
+ <title>404: This page could not be found.</title>
7
+ <div style={styles.error}>
8
+ <div>
9
+ <style
10
+ dangerouslySetInnerHTML={{
11
+ __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`,
12
+ }}
13
+ />
14
+ <h1 className="next-error-h1" style={styles.h1}>
15
+ 404
16
+ </h1>
17
+ <div style={styles.desc}>
18
+ <h2 style={styles.h2}>This page could not be found.</h2>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </>
23
+ );
24
+ }
25
+
26
+ const styles = {
27
+ error: {
28
+ fontFamily:
29
+ 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
30
+ height: "100vh",
31
+ textAlign: "center",
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ alignItems: "center",
35
+ justifyContent: "center",
36
+ },
37
+
38
+ desc: {
39
+ display: "inline-block",
40
+ },
41
+
42
+ h1: {
43
+ display: "inline-block",
44
+ margin: "0 20px 0 0",
45
+ padding: "0 23px 0 0",
46
+ fontSize: 24,
47
+ fontWeight: 500,
48
+ verticalAlign: "top",
49
+ lineHeight: "49px",
50
+ },
51
+
52
+ h2: {
53
+ fontSize: 14,
54
+ fontWeight: 400,
55
+ lineHeight: "49px",
56
+ margin: 0,
57
+ },
58
+ };
@@ -0,0 +1,22 @@
1
+ import type { NextRequest } from 'next/server'
2
+ import { getRequestContext } from '@cloudflare/next-on-pages'
3
+
4
+ export const runtime = 'edge'
5
+
6
+ export async function GET(request: NextRequest) {
7
+ let responseText = 'Hello World'
8
+
9
+ // In the edge runtime you can use Bindings that are available in your application
10
+ // (for more details see:
11
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
12
+ // - https://developers.cloudflare.com/pages/functions/bindings/
13
+ // )
14
+ //
15
+ // KV Example:
16
+ // const myKv = getRequestContext().env.MY_KV
17
+ // await myKv.put('suffix', ' from a KV store!')
18
+ // const suffix = await myKv.get('suffix')
19
+ // responseText += suffix
20
+
21
+ return new Response(responseText)
22
+ }
@@ -0,0 +1,58 @@
1
+ export const runtime = "edge";
2
+
3
+ export default function NotFound() {
4
+ return (
5
+ <>
6
+ <title>404: This page could not be found.</title>
7
+ <div style={styles.error}>
8
+ <div>
9
+ <style
10
+ dangerouslySetInnerHTML={{
11
+ __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`,
12
+ }}
13
+ />
14
+ <h1 className="next-error-h1" style={styles.h1}>
15
+ 404
16
+ </h1>
17
+ <div style={styles.desc}>
18
+ <h2 style={styles.h2}>This page could not be found.</h2>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </>
23
+ );
24
+ }
25
+
26
+ const styles = {
27
+ error: {
28
+ fontFamily:
29
+ 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
30
+ height: "100vh",
31
+ textAlign: "center",
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ alignItems: "center",
35
+ justifyContent: "center",
36
+ },
37
+
38
+ desc: {
39
+ display: "inline-block",
40
+ },
41
+
42
+ h1: {
43
+ display: "inline-block",
44
+ margin: "0 20px 0 0",
45
+ padding: "0 23px 0 0",
46
+ fontSize: 24,
47
+ fontWeight: 500,
48
+ verticalAlign: "top",
49
+ lineHeight: "49px",
50
+ },
51
+
52
+ h2: {
53
+ fontSize: 14,
54
+ fontWeight: 400,
55
+ lineHeight: "49px",
56
+ margin: 0,
57
+ },
58
+ } as const;