create-cloudflare 0.0.0-e4ef867c → 0.0.0-e6ddf8a7

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/README.md +1 -52
  2. package/dist/angular/templates/{src/main.server.ts → server.ts} +14 -15
  3. package/dist/angular/templates/tools/alter-polyfills.mjs +27 -0
  4. package/dist/angular/templates/tools/copy-files.mjs +9 -0
  5. package/dist/cli.js +43018 -41717
  6. package/package.json +85 -73
  7. package/templates/chatgptPlugin/ts/README.md +2 -2
  8. package/templates/chatgptPlugin/ts/__dot__gitignore +171 -0
  9. package/templates/chatgptPlugin/ts/package.json +2 -1
  10. package/templates/chatgptPlugin/ts/src/search.ts +3 -7
  11. package/templates/common/js/__dot__gitignore +172 -0
  12. package/templates/common/js/package.json +1 -0
  13. package/templates/common/js/wrangler.toml +2 -2
  14. package/templates/common/ts/__dot__gitignore +172 -0
  15. package/templates/common/ts/package.json +1 -0
  16. package/templates/common/ts/wrangler.toml +2 -2
  17. package/templates/hello-world/js/__dot__gitignore +172 -0
  18. package/templates/hello-world/js/package.json +1 -0
  19. package/templates/hello-world/js/wrangler.toml +2 -2
  20. package/templates/hello-world/ts/__dot__gitignore +172 -0
  21. package/templates/hello-world/ts/package.json +1 -0
  22. package/templates/hello-world/ts/wrangler.toml +2 -2
  23. package/templates/openapi/ts/README.md +25 -0
  24. package/templates/openapi/ts/__dot__gitignore +171 -0
  25. package/templates/openapi/ts/package.json +19 -0
  26. package/templates/openapi/ts/src/endpoints/taskCreate.ts +48 -0
  27. package/templates/openapi/ts/src/endpoints/taskDelete.ts +55 -0
  28. package/templates/openapi/ts/src/endpoints/taskFetch.ts +74 -0
  29. package/templates/openapi/ts/src/endpoints/taskList.ts +66 -0
  30. package/templates/openapi/ts/src/index.ts +29 -0
  31. package/templates/openapi/ts/src/types.ts +9 -0
  32. package/templates/openapi/ts/tsconfig.json +32 -0
  33. package/templates/openapi/ts/wrangler.toml +3 -0
  34. package/templates/queues/js/__dot__gitignore +172 -0
  35. package/templates/queues/js/package.json +1 -0
  36. package/templates/queues/js/wrangler.toml +3 -3
  37. package/templates/queues/ts/__dot__gitignore +172 -0
  38. package/templates/queues/ts/package.json +1 -0
  39. package/templates/queues/ts/wrangler.toml +3 -3
  40. package/templates/scheduled/js/__dot__gitignore +172 -0
  41. package/templates/scheduled/js/package.json +1 -0
  42. package/templates/scheduled/js/wrangler.toml +1 -1
  43. package/templates/scheduled/ts/__dot__gitignore +172 -0
  44. package/templates/scheduled/ts/package.json +1 -0
  45. package/templates/scheduled/ts/wrangler.toml +2 -2
  46. package/dist/angular/templates/tools/bundle.mjs +0 -77
  47. package/dist/angular/templates/tools/copy-client-files.mjs +0 -4
  48. package/dist/angular/templates/tools/copy-worker-files.mjs +0 -10
  49. package/dist/angular/templates/tsconfig.server.json +0 -5
  50. /package/templates/common/js/src/{worker.js → index.js} +0 -0
  51. /package/templates/common/ts/src/{worker.ts → index.ts} +0 -0
  52. /package/templates/hello-world/js/src/{worker.js → index.js} +0 -0
  53. /package/templates/hello-world/ts/src/{worker.ts → index.ts} +0 -0
  54. /package/templates/queues/js/src/{worker.js → index.js} +0 -0
  55. /package/templates/queues/ts/src/{worker.ts → index.ts} +0 -0
  56. /package/templates/scheduled/js/src/{worker.js → index.js} +0 -0
  57. /package/templates/scheduled/ts/src/{worker.ts → index.ts} +0 -0
@@ -0,0 +1,171 @@
1
+ # Logs
2
+
3
+ logs
4
+ _.log
5
+ npm-debug.log_
6
+ yarn-debug.log*
7
+ yarn-error.log*
8
+ lerna-debug.log*
9
+ .pnpm-debug.log*
10
+
11
+ # Diagnostic reports (https://nodejs.org/api/report.html)
12
+
13
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14
+
15
+ # Runtime data
16
+
17
+ pids
18
+ _.pid
19
+ _.seed
20
+ \*.pid.lock
21
+
22
+ # Directory for instrumented libs generated by jscoverage/JSCover
23
+
24
+ lib-cov
25
+
26
+ # Coverage directory used by tools like istanbul
27
+
28
+ coverage
29
+ \*.lcov
30
+
31
+ # nyc test coverage
32
+
33
+ .nyc_output
34
+
35
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36
+
37
+ .grunt
38
+
39
+ # Bower dependency directory (https://bower.io/)
40
+
41
+ bower_components
42
+
43
+ # node-waf configuration
44
+
45
+ .lock-wscript
46
+
47
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
48
+
49
+ build/Release
50
+
51
+ # Dependency directories
52
+
53
+ node_modules/
54
+ jspm_packages/
55
+
56
+ # Snowpack dependency directory (https://snowpack.dev/)
57
+
58
+ web_modules/
59
+
60
+ # TypeScript cache
61
+
62
+ \*.tsbuildinfo
63
+
64
+ # Optional npm cache directory
65
+
66
+ .npm
67
+
68
+ # Optional eslint cache
69
+
70
+ .eslintcache
71
+
72
+ # Optional stylelint cache
73
+
74
+ .stylelintcache
75
+
76
+ # Microbundle cache
77
+
78
+ .rpt2_cache/
79
+ .rts2_cache_cjs/
80
+ .rts2_cache_es/
81
+ .rts2_cache_umd/
82
+
83
+ # Optional REPL history
84
+
85
+ .node_repl_history
86
+
87
+ # Output of 'npm pack'
88
+
89
+ \*.tgz
90
+
91
+ # Yarn Integrity file
92
+
93
+ .yarn-integrity
94
+
95
+ # dotenv environment variable files
96
+
97
+ .env
98
+ .env.development.local
99
+ .env.test.local
100
+ .env.production.local
101
+ .env.local
102
+
103
+ # parcel-bundler cache (https://parceljs.org/)
104
+
105
+ .cache
106
+ .parcel-cache
107
+
108
+ # Next.js build output
109
+
110
+ .next
111
+ out
112
+
113
+ # Nuxt.js build / generate output
114
+
115
+ .nuxt
116
+ dist
117
+
118
+ # Gatsby files
119
+
120
+ .cache/
121
+
122
+ # Comment in the public line in if your project uses Gatsby and not Next.js
123
+
124
+ # https://nextjs.org/blog/next-9-1#public-directory-support
125
+
126
+ # public
127
+
128
+ # vuepress build output
129
+
130
+ .vuepress/dist
131
+
132
+ # vuepress v2.x temp and cache directory
133
+
134
+ .temp
135
+ .cache
136
+
137
+ # Docusaurus cache and generated files
138
+
139
+ .docusaurus
140
+
141
+ # Serverless directories
142
+
143
+ .serverless/
144
+
145
+ # FuseBox cache
146
+
147
+ .fusebox/
148
+
149
+ # DynamoDB Local files
150
+
151
+ .dynamodb/
152
+
153
+ # TernJS port file
154
+
155
+ .tern-port
156
+
157
+ # Stores VSCode versions used for testing VSCode extensions
158
+
159
+ .vscode-test
160
+
161
+ # yarn v2
162
+
163
+ .yarn/cache
164
+ .yarn/unplugged
165
+ .yarn/build-state.yml
166
+ .yarn/install-state.gz
167
+ .pnp.\*
168
+
169
+ # wrangler project
170
+
171
+ .dev.vars
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "cloudflare-workers-openapi",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "deploy": "wrangler deploy",
7
+ "dev": "wrangler dev",
8
+ "start": "wrangler dev"
9
+ },
10
+ "dependencies": {
11
+ "@cloudflare/itty-router-openapi": "^1.0.1"
12
+ },
13
+ "devDependencies": {
14
+ "@cloudflare/workers-types": "^4.20230821.0",
15
+ "@types/node": "^20.5.7",
16
+ "@types/service-worker-mock": "^2.0.1",
17
+ "wrangler": "^3.0.0"
18
+ }
19
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ OpenAPIRoute,
3
+ OpenAPIRouteSchema,
4
+ } from "@cloudflare/itty-router-openapi";
5
+ import { Task } from "../types";
6
+
7
+ export class TaskCreate extends OpenAPIRoute {
8
+ static schema: OpenAPIRouteSchema = {
9
+ tags: ["Tasks"],
10
+ summary: "Create a new Task",
11
+ requestBody: Task,
12
+ responses: {
13
+ "200": {
14
+ description: "Returns the created task",
15
+ schema: {
16
+ success: Boolean,
17
+ result: {
18
+ task: Task,
19
+ },
20
+ },
21
+ },
22
+ },
23
+ };
24
+
25
+ async handle(
26
+ request: Request,
27
+ env: any,
28
+ context: any,
29
+ data: Record<string, any>
30
+ ) {
31
+ // Retrieve the validated request body
32
+ const taskToCreate = data.body;
33
+
34
+ // Implement your own object insertion here
35
+
36
+ // return the new task
37
+ return {
38
+ success: true,
39
+ task: {
40
+ name: taskToCreate.name,
41
+ slug: taskToCreate.slug,
42
+ description: taskToCreate.description,
43
+ completed: taskToCreate.completed,
44
+ due_date: taskToCreate.due_date,
45
+ },
46
+ };
47
+ }
48
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ OpenAPIRoute,
3
+ OpenAPIRouteSchema,
4
+ Path,
5
+ } from "@cloudflare/itty-router-openapi";
6
+ import { Task } from "../types";
7
+
8
+ export class TaskDelete extends OpenAPIRoute {
9
+ static schema: OpenAPIRouteSchema = {
10
+ tags: ["Tasks"],
11
+ summary: "Delete a Task",
12
+ parameters: {
13
+ taskSlug: Path(String, {
14
+ description: "Task slug",
15
+ }),
16
+ },
17
+ responses: {
18
+ "200": {
19
+ description: "Returns if the task was deleted successfully",
20
+ schema: {
21
+ success: Boolean,
22
+ result: {
23
+ task: Task,
24
+ },
25
+ },
26
+ },
27
+ },
28
+ };
29
+
30
+ async handle(
31
+ request: Request,
32
+ env: any,
33
+ context: any,
34
+ data: Record<string, any>
35
+ ) {
36
+ // Retrieve the validated slug
37
+ const { taskSlug } = data.params;
38
+
39
+ // Implement your own object deletion here
40
+
41
+ // Return the deleted task for confirmation
42
+ return {
43
+ result: {
44
+ task: {
45
+ name: "Build something awesome with Cloudflare Workers",
46
+ slug: taskSlug,
47
+ description: "Lorem Ipsum",
48
+ completed: true,
49
+ due_date: "2022-12-24",
50
+ },
51
+ },
52
+ success: true,
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,74 @@
1
+ import {
2
+ OpenAPIRoute,
3
+ OpenAPIRouteSchema,
4
+ Path,
5
+ } from "@cloudflare/itty-router-openapi";
6
+ import { Task } from "../types";
7
+
8
+ export class TaskFetch extends OpenAPIRoute {
9
+ static schema: OpenAPIRouteSchema = {
10
+ tags: ["Tasks"],
11
+ summary: "Get a single Task by slug",
12
+ parameters: {
13
+ taskSlug: Path(String, {
14
+ description: "Task slug",
15
+ }),
16
+ },
17
+ responses: {
18
+ "200": {
19
+ description: "Returns a single task if found",
20
+ schema: {
21
+ success: Boolean,
22
+ result: {
23
+ task: Task,
24
+ },
25
+ },
26
+ },
27
+ "404": {
28
+ description: "Task not found",
29
+ schema: {
30
+ success: Boolean,
31
+ error: String,
32
+ },
33
+ },
34
+ },
35
+ };
36
+
37
+ async handle(
38
+ request: Request,
39
+ env: any,
40
+ context: any,
41
+ data: Record<string, any>
42
+ ) {
43
+ // Retrieve the validated slug
44
+ const { taskSlug } = data.params;
45
+
46
+ // Implement your own object fetch here
47
+
48
+ const exists = true;
49
+
50
+ // @ts-ignore: check if the object exists
51
+ if (exists === false) {
52
+ return Response.json(
53
+ {
54
+ success: false,
55
+ error: "Object not found",
56
+ },
57
+ {
58
+ status: 404,
59
+ }
60
+ );
61
+ }
62
+
63
+ return {
64
+ success: true,
65
+ task: {
66
+ name: "my task",
67
+ slug: taskSlug,
68
+ description: "this needs to be done",
69
+ completed: false,
70
+ due_date: new Date().toISOString().slice(0, 10),
71
+ },
72
+ };
73
+ }
74
+ }
@@ -0,0 +1,66 @@
1
+ import { Task } from "../types";
2
+ import {
3
+ OpenAPIRoute,
4
+ OpenAPIRouteSchema,
5
+ Query,
6
+ } from "@cloudflare/itty-router-openapi";
7
+
8
+ export class TaskList extends OpenAPIRoute {
9
+ static schema: OpenAPIRouteSchema = {
10
+ tags: ["Tasks"],
11
+ summary: "List Tasks",
12
+ parameters: {
13
+ page: Query(Number, {
14
+ description: "Page number",
15
+ default: 0,
16
+ }),
17
+ isCompleted: Query(Boolean, {
18
+ description: "Filter by completed flag",
19
+ required: false,
20
+ }),
21
+ },
22
+ responses: {
23
+ "200": {
24
+ description: "Returns a list of tasks",
25
+ schema: {
26
+ success: Boolean,
27
+ result: {
28
+ tasks: [Task],
29
+ },
30
+ },
31
+ },
32
+ },
33
+ };
34
+
35
+ async handle(
36
+ request: Request,
37
+ env: any,
38
+ context: any,
39
+ data: Record<string, any>
40
+ ) {
41
+ // Retrieve the validated parameters
42
+ const { page, isCompleted } = data.query;
43
+
44
+ // Implement your own object list here
45
+
46
+ return {
47
+ success: true,
48
+ tasks: [
49
+ {
50
+ name: "Clean my room",
51
+ slug: "clean-room",
52
+ description: null,
53
+ completed: false,
54
+ due_date: "2025-01-05",
55
+ },
56
+ {
57
+ name: "Build something awesome with Cloudflare Workers",
58
+ slug: "cloudflare-workers",
59
+ description: "Lorem Ipsum",
60
+ completed: true,
61
+ due_date: "2022-12-24",
62
+ },
63
+ ],
64
+ };
65
+ }
66
+ }
@@ -0,0 +1,29 @@
1
+ import { OpenAPIRouter } from "@cloudflare/itty-router-openapi";
2
+ import { TaskList } from "./endpoints/taskList";
3
+ import { TaskCreate } from "./endpoints/taskCreate";
4
+ import { TaskFetch } from "./endpoints/taskFetch";
5
+ import { TaskDelete } from "./endpoints/taskDelete";
6
+
7
+ export const router = OpenAPIRouter({
8
+ docs_url: "/",
9
+ });
10
+
11
+ router.get("/api/tasks/", TaskList);
12
+ router.post("/api/tasks/", TaskCreate);
13
+ router.get("/api/tasks/:taskSlug/", TaskFetch);
14
+ router.delete("/api/tasks/:taskSlug/", TaskDelete);
15
+
16
+ // 404 for everything else
17
+ router.all("*", () =>
18
+ Response.json(
19
+ {
20
+ success: false,
21
+ error: "Route not found",
22
+ },
23
+ { status: 404 }
24
+ )
25
+ );
26
+
27
+ export default {
28
+ fetch: router.handle,
29
+ };
@@ -0,0 +1,9 @@
1
+ import { DateTime, Str } from "@cloudflare/itty-router-openapi";
2
+
3
+ export const Task = {
4
+ name: new Str({ example: "lorem" }),
5
+ slug: String,
6
+ description: new Str({ required: false }),
7
+ completed: Boolean,
8
+ due_date: new DateTime(),
9
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "allowSyntheticDefaultImports": true,
5
+ "baseUrl": "src",
6
+ "declaration": true,
7
+ "sourceMap": true,
8
+ "esModuleInterop": true,
9
+ "inlineSourceMap": false,
10
+ "lib": ["esnext"],
11
+ "listEmittedFiles": false,
12
+ "listFiles": false,
13
+ "moduleResolution": "node",
14
+ "noFallthroughCasesInSwitch": true,
15
+ "pretty": true,
16
+ "resolveJsonModule": true,
17
+ "rootDir": ".",
18
+ "skipLibCheck": true,
19
+ "strict": false,
20
+ "traceResolution": false,
21
+ "outDir": "",
22
+ "target": "esnext",
23
+ "module": "esnext",
24
+ "types": [
25
+ "@types/node",
26
+ "@types/service-worker-mock",
27
+ "@cloudflare/workers-types"
28
+ ]
29
+ },
30
+ "exclude": ["node_modules", "dist", "tests"],
31
+ "include": ["src", "scripts"]
32
+ }
@@ -0,0 +1,3 @@
1
+ name = "<TBD>"
2
+ main = "src/index.ts"
3
+ compatibility_date = "<TBD>"
@@ -0,0 +1,172 @@
1
+ # Logs
2
+
3
+ logs
4
+ _.log
5
+ npm-debug.log_
6
+ yarn-debug.log*
7
+ yarn-error.log*
8
+ lerna-debug.log*
9
+ .pnpm-debug.log*
10
+
11
+ # Diagnostic reports (https://nodejs.org/api/report.html)
12
+
13
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14
+
15
+ # Runtime data
16
+
17
+ pids
18
+ _.pid
19
+ _.seed
20
+ \*.pid.lock
21
+
22
+ # Directory for instrumented libs generated by jscoverage/JSCover
23
+
24
+ lib-cov
25
+
26
+ # Coverage directory used by tools like istanbul
27
+
28
+ coverage
29
+ \*.lcov
30
+
31
+ # nyc test coverage
32
+
33
+ .nyc_output
34
+
35
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36
+
37
+ .grunt
38
+
39
+ # Bower dependency directory (https://bower.io/)
40
+
41
+ bower_components
42
+
43
+ # node-waf configuration
44
+
45
+ .lock-wscript
46
+
47
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
48
+
49
+ build/Release
50
+
51
+ # Dependency directories
52
+
53
+ node_modules/
54
+ jspm_packages/
55
+
56
+ # Snowpack dependency directory (https://snowpack.dev/)
57
+
58
+ web_modules/
59
+
60
+ # TypeScript cache
61
+
62
+ \*.tsbuildinfo
63
+
64
+ # Optional npm cache directory
65
+
66
+ .npm
67
+
68
+ # Optional eslint cache
69
+
70
+ .eslintcache
71
+
72
+ # Optional stylelint cache
73
+
74
+ .stylelintcache
75
+
76
+ # Microbundle cache
77
+
78
+ .rpt2_cache/
79
+ .rts2_cache_cjs/
80
+ .rts2_cache_es/
81
+ .rts2_cache_umd/
82
+
83
+ # Optional REPL history
84
+
85
+ .node_repl_history
86
+
87
+ # Output of 'npm pack'
88
+
89
+ \*.tgz
90
+
91
+ # Yarn Integrity file
92
+
93
+ .yarn-integrity
94
+
95
+ # dotenv environment variable files
96
+
97
+ .env
98
+ .env.development.local
99
+ .env.test.local
100
+ .env.production.local
101
+ .env.local
102
+
103
+ # parcel-bundler cache (https://parceljs.org/)
104
+
105
+ .cache
106
+ .parcel-cache
107
+
108
+ # Next.js build output
109
+
110
+ .next
111
+ out
112
+
113
+ # Nuxt.js build / generate output
114
+
115
+ .nuxt
116
+ dist
117
+
118
+ # Gatsby files
119
+
120
+ .cache/
121
+
122
+ # Comment in the public line in if your project uses Gatsby and not Next.js
123
+
124
+ # https://nextjs.org/blog/next-9-1#public-directory-support
125
+
126
+ # public
127
+
128
+ # vuepress build output
129
+
130
+ .vuepress/dist
131
+
132
+ # vuepress v2.x temp and cache directory
133
+
134
+ .temp
135
+ .cache
136
+
137
+ # Docusaurus cache and generated files
138
+
139
+ .docusaurus
140
+
141
+ # Serverless directories
142
+
143
+ .serverless/
144
+
145
+ # FuseBox cache
146
+
147
+ .fusebox/
148
+
149
+ # DynamoDB Local files
150
+
151
+ .dynamodb/
152
+
153
+ # TernJS port file
154
+
155
+ .tern-port
156
+
157
+ # Stores VSCode versions used for testing VSCode extensions
158
+
159
+ .vscode-test
160
+
161
+ # yarn v2
162
+
163
+ .yarn/cache
164
+ .yarn/unplugged
165
+ .yarn/build-state.yml
166
+ .yarn/install-state.gz
167
+ .pnp.\*
168
+
169
+ # wrangler project
170
+
171
+ .dev.vars
172
+ .wrangler/
@@ -4,6 +4,7 @@
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "deploy": "wrangler deploy",
7
+ "dev": "wrangler dev",
7
8
  "start": "wrangler dev"
8
9
  },
9
10
  "devDependencies": {
@@ -1,16 +1,16 @@
1
1
  name = "<TBD>"
2
- main = "src/worker.js"
2
+ main = "src/index.js"
3
3
  compatibility_date = "<TBD>"
4
4
 
5
5
  # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
6
6
  # Docs: https://developers.cloudflare.com/queues/get-started
7
- # [[queues.producers]]
7
+ [[queues.producers]]
8
8
  binding = "MY_QUEUE"
9
9
  queue = "my-queue"
10
10
 
11
11
  # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
12
12
  # Docs: https://developers.cloudflare.com/queues/get-started
13
- # [[queues.consumers]]
13
+ [[queues.consumers]]
14
14
  queue = "my-queue"
15
15
  # Optional: Configure batching and retries: https://developers.cloudflare.com/queues/learning/batching-retries/
16
16
  # max_batch_size = 10