wrangler 0.0.0-adae8e8 → 0.0.0-aeb0fe0

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 (104) hide show
  1. package/README.md +51 -0
  2. package/bin/wrangler.js +4 -4
  3. package/package.json +70 -33
  4. package/pages/functions/buildWorker.ts +62 -0
  5. package/pages/functions/filepath-routing.test.ts +223 -0
  6. package/pages/functions/filepath-routing.ts +181 -0
  7. package/pages/functions/identifiers.ts +78 -0
  8. package/pages/functions/routes.ts +151 -0
  9. package/pages/functions/template-worker.ts +130 -0
  10. package/src/__tests__/configuration.test.ts +2598 -0
  11. package/src/__tests__/dev.test.tsx +445 -0
  12. package/src/__tests__/dev2.test.tsx +154 -0
  13. package/src/__tests__/guess-worker-format.test.ts +58 -0
  14. package/src/__tests__/helpers/clipboardy-mock.js +4 -0
  15. package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
  16. package/src/__tests__/helpers/faye-websocket.d.ts +6 -0
  17. package/src/__tests__/helpers/mock-account-id.ts +48 -0
  18. package/src/__tests__/helpers/mock-bin.ts +36 -0
  19. package/src/__tests__/helpers/mock-cfetch.ts +207 -0
  20. package/src/__tests__/helpers/mock-console.ts +70 -0
  21. package/src/__tests__/helpers/mock-dialogs.ts +65 -0
  22. package/src/__tests__/helpers/mock-kv.ts +33 -0
  23. package/src/__tests__/helpers/mock-stdin.ts +103 -0
  24. package/src/__tests__/helpers/mock-web-socket.ts +29 -0
  25. package/src/__tests__/helpers/run-in-tmp.ts +32 -0
  26. package/src/__tests__/helpers/run-wrangler.ts +16 -0
  27. package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
  28. package/src/__tests__/https-options.test.ts +127 -0
  29. package/src/__tests__/index.test.ts +957 -88
  30. package/src/__tests__/jest.setup.ts +69 -0
  31. package/src/__tests__/kv.test.ts +1382 -0
  32. package/src/__tests__/logout.test.ts +52 -0
  33. package/src/__tests__/package-manager.test.ts +206 -0
  34. package/src/__tests__/pages.test.ts +44 -0
  35. package/src/__tests__/parse.test.ts +322 -0
  36. package/src/__tests__/publish.test.ts +2635 -0
  37. package/src/__tests__/r2.test.ts +198 -0
  38. package/src/__tests__/route.test.ts +45 -0
  39. package/src/__tests__/secret.test.ts +425 -0
  40. package/src/__tests__/sentry.test.ts +146 -0
  41. package/src/__tests__/tail.test.ts +564 -0
  42. package/src/__tests__/whoami.test.tsx +100 -0
  43. package/src/bundle.ts +142 -0
  44. package/src/cfetch/index.ts +104 -0
  45. package/src/cfetch/internal.ts +139 -0
  46. package/src/cli.ts +19 -0
  47. package/src/config/README.md +107 -0
  48. package/src/config/config.ts +279 -0
  49. package/src/config/diagnostics.ts +80 -0
  50. package/src/config/environment.ts +305 -0
  51. package/src/config/index.ts +52 -0
  52. package/src/config/validation-helpers.ts +468 -0
  53. package/src/config/validation.ts +1057 -0
  54. package/src/create-worker-preview.ts +166 -0
  55. package/src/create-worker-upload-form.ts +217 -0
  56. package/src/dev/dev.tsx +362 -0
  57. package/src/dev/local.tsx +247 -0
  58. package/src/dev/remote.tsx +203 -0
  59. package/src/dev/use-esbuild.ts +100 -0
  60. package/src/dialogs.tsx +77 -0
  61. package/src/entry.ts +159 -0
  62. package/src/environment-variables.ts +33 -0
  63. package/src/https-options.ts +122 -0
  64. package/src/index.tsx +1505 -851
  65. package/src/inspect.ts +617 -0
  66. package/src/kv.ts +339 -0
  67. package/src/module-collection.ts +258 -0
  68. package/src/open-in-browser.ts +25 -0
  69. package/src/package-manager.ts +126 -0
  70. package/src/pages.tsx +916 -211
  71. package/src/parse.ts +183 -0
  72. package/src/paths.ts +26 -0
  73. package/src/proxy.ts +440 -0
  74. package/src/publish.ts +306 -231
  75. package/src/r2.ts +50 -0
  76. package/src/reporting.ts +131 -0
  77. package/src/selfsigned.d.ts +29 -0
  78. package/src/sites.tsx +217 -59
  79. package/src/tail/filters.ts +279 -0
  80. package/src/tail/index.ts +299 -0
  81. package/src/tail/printing.ts +62 -0
  82. package/src/user.tsx +297 -189
  83. package/src/whoami.tsx +69 -0
  84. package/src/worker.ts +163 -0
  85. package/templates/new-worker.js +15 -0
  86. package/templates/new-worker.ts +15 -0
  87. package/{static-asset-facade.js → templates/static-asset-facade.js} +0 -0
  88. package/templates/tsconfig.json +105 -0
  89. package/wrangler-dist/{index_node.js → cli.js} +136704 -126939
  90. package/wrangler-dist/cli.js.map +7 -0
  91. package/src/__tests__/fixtures/init/.gitkeep +0 -0
  92. package/src/api/form_data.ts +0 -125
  93. package/src/api/inspect.ts +0 -441
  94. package/src/api/preview.ts +0 -123
  95. package/src/api/worker.ts +0 -140
  96. package/src/cfetch.ts +0 -72
  97. package/src/config.ts +0 -96
  98. package/src/dev.tsx +0 -670
  99. package/src/index_node.ts +0 -10
  100. package/src/kv.tsx +0 -211
  101. package/src/secret.tsx +0 -40
  102. package/src/tail.tsx +0 -71
  103. package/src/util/fetch.ts +0 -74
  104. package/wrangler-dist/index_node.js.map +0 -7
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ ## 🤠 wrangler
2
+
3
+ `wrangler` is a command line tool for building [Cloudflare Workers](https://workers.cloudflare.com/).
4
+
5
+ [(Read the full stack week launch blog post.)](https://blog.cloudflare.com/wrangler-v2-beta/)
6
+
7
+ **DISCLAIMER**: This is a work in progress, and is NOT recommended for use in production. We are opening this preview for feedback from the community, and to openly share our [roadmap](https://github.com/cloudflare/wrangler2/issues/12) for the future. As such, expect APIs and documentation to change before the end of the preview.
8
+
9
+ Further, we will NOT do a general release until we are both feature complete, and have a full backward compatibility and incremental migration plan in place. For more details, follow the [parent roadmap issue](https://github.com/cloudflare/wrangler2/issues/12).
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Make a javascript file
15
+ $ echo "export default { fetch() { return new Response('hello world') } }" > index.js
16
+ # try it out
17
+ $ npx wrangler@beta dev index.js
18
+ # and then publish it
19
+ $ npx wrangler@beta publish index.js --name my-worker
20
+ # visit https://my-worker.<your workers subdomain>.workers.dev
21
+ ```
22
+
23
+ ## Installation:
24
+
25
+ ```bash
26
+ $ npm install wrangler@beta
27
+ ```
28
+
29
+ ## Commands
30
+
31
+ ### `wrangler init [name]`
32
+
33
+ Creates a `wrangler.toml` configuration file. For more details on the configuration keys and values, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration).
34
+
35
+ ### `wrangler dev [script]`
36
+
37
+ Start a local development server, with live reloading and devtools.
38
+
39
+ ### `wrangler publish [script] --name [name]`
40
+
41
+ Publish the given script to the worldwide Cloudflare network.
42
+
43
+ For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/commands).
44
+
45
+ ### `wrangler pages dev [directory] [-- command]`
46
+
47
+ Either serves a static build asset directory, or proxies itself in front of a command.
48
+
49
+ Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory.
50
+
51
+ For more commands and options, refer to the [documentation](https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally) or run `wrangler pages dev --help`.
package/bin/wrangler.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- const { spawn } = require("child_process");
3
- const { join } = require("path");
2
+ const { spawn } = require("node:child_process");
3
+ const { join } = require("node:path");
4
4
  const semiver = require("semiver");
5
5
 
6
6
  const MIN_NODE_VERSION = "16.7.0";
@@ -10,7 +10,7 @@ async function main() {
10
10
  // Note Volta and nvm are also recommended in the official docs:
11
11
  // https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
12
12
  console.error(
13
- `Wrangler requires at least Node.js ${MIN_NODE_VERSION}.
13
+ `Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}.
14
14
  You should use the latest Node.js version if possible, as Cloudflare Workers use a very up-to-date version of V8.
15
15
  Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
16
16
  );
@@ -24,7 +24,7 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
24
24
  "--no-warnings",
25
25
  "--experimental-vm-modules",
26
26
  ...process.execArgv,
27
- join(__dirname, "../wrangler-dist/index_node.js"),
27
+ join(__dirname, "../wrangler-dist/cli.js"),
28
28
  ...process.argv.slice(2),
29
29
  ],
30
30
  { stdio: "inherit" }
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "0.0.0-adae8e8",
3
+ "version": "0.0.0-aeb0fe0",
4
4
  "author": "wrangler@cloudflare.com",
5
5
  "description": "Command-line interface for all things Cloudflare Workers",
6
- "bin": "./bin/wrangler.js",
6
+ "bin": {
7
+ "wrangler": "./bin/wrangler.js",
8
+ "wrangler2": "./bin/wrangler.js"
9
+ },
7
10
  "license": "MIT OR Apache-2.0",
8
11
  "bugs": {
9
12
  "url": "https://github.com/cloudflare/wrangler/issues"
@@ -33,75 +36,109 @@
33
36
  "cli"
34
37
  ],
35
38
  "dependencies": {
36
- "esbuild": "0.13.12",
37
- "miniflare": "2.0.0-rc.1",
38
- "semiver": "^1.1.0"
39
+ "esbuild": "0.14.23",
40
+ "miniflare": "2.3.0",
41
+ "path-to-regexp": "^6.2.0",
42
+ "selfsigned": "^2.0.0",
43
+ "semiver": "^1.1.0",
44
+ "xxhash-wasm": "^1.0.1"
39
45
  },
40
46
  "optionalDependencies": {
41
47
  "fsevents": "~2.3.2"
42
48
  },
43
49
  "devDependencies": {
44
- "@cloudflare/pages-functions-compiler": "^0.3.3",
45
50
  "@iarna/toml": "^2.2.5",
46
- "@types/cloudflare": "^2.7.6",
47
- "@types/express": "^4.17.13",
48
- "@types/react": "^17.0.34",
51
+ "@sentry/cli": "^1.71.0",
52
+ "@sentry/integrations": "^6.17.6",
53
+ "@sentry/node": "^6.17.6",
54
+ "@types/command-exists": "^1.2.0",
55
+ "@types/glob-to-regexp": "0.4.1",
56
+ "@types/mime": "^2.0.3",
57
+ "@types/prompts": "^2.0.14",
58
+ "@types/react": "^17.0.37",
59
+ "@types/react-test-renderer": "^17.0.1",
60
+ "@types/serve-static": "^1.13.10",
49
61
  "@types/signal-exit": "^3.0.1",
50
- "@types/ws": "^8.2.0",
51
- "@types/yargs": "^17.0.5",
62
+ "@types/supports-color": "^8.1.1",
63
+ "@types/ws": "^8.2.1",
64
+ "@types/yargs": "^17.0.7",
65
+ "chokidar": "^3.5.2",
52
66
  "clipboardy": "^3.0.0",
67
+ "cmd-shim": "^4.1.0",
53
68
  "command-exists": "^1.2.9",
54
- "execa": "^5.1.1",
55
- "express": "^4.17.1",
69
+ "devtools-protocol": "^0.0.955664",
70
+ "execa": "^6.0.0",
71
+ "faye-websocket": "^0.11.4",
56
72
  "finalhandler": "^1.1.2",
57
73
  "find-up": "^6.2.0",
58
- "formdata-node": "^4.3.1",
59
- "http-proxy": "^1.18.1",
60
- "http-proxy-middleware": "^2.0.1",
74
+ "get-port": "^6.1.2",
75
+ "glob-to-regexp": "0.4.1",
76
+ "ignore": "^5.2.0",
61
77
  "ink": "^3.2.0",
62
- "ink-select-input": "^4.2.0",
78
+ "ink-select-input": "^4.2.1",
63
79
  "ink-table": "^3.0.0",
64
- "ink-text-input": "^4.0.1",
65
- "node-fetch": "github:tekwiz/node-fetch#fix/redirect-with-empty-chunked-transfer-encoding",
80
+ "ink-testing-library": "^2.1.0",
81
+ "ink-text-input": "^4.0.2",
82
+ "jest-fetch-mock": "^3.0.3",
83
+ "jest-websocket-mock": "^2.3.0",
84
+ "mime": "^3.0.0",
66
85
  "open": "^8.4.0",
86
+ "prompts": "^2.4.2",
67
87
  "react": "^17.0.2",
68
- "serve": "^13.0.2",
88
+ "react-error-boundary": "^3.1.4",
89
+ "react-test-renderer": "^17.0.2",
69
90
  "serve-static": "^1.14.1",
70
- "signal-exit": "^3.0.5",
91
+ "signal-exit": "^3.0.6",
92
+ "supports-color": "^9.2.1",
71
93
  "tmp-promise": "^3.0.3",
72
- "ws": "^8.2.3",
73
- "yargs": "^17.2.1"
94
+ "undici": "^4.15.1",
95
+ "ws": "^8.3.0",
96
+ "yargs": "^17.3.0"
74
97
  },
75
98
  "files": [
76
99
  "src",
77
100
  "bin",
101
+ "pages",
78
102
  "miniflare-config-stubs",
79
103
  "wrangler-dist",
80
- "static-asset-facade.js",
104
+ "templates",
81
105
  "vendor",
82
106
  "import_meta_url.js"
83
107
  ],
84
108
  "scripts": {
85
109
  "clean": "rm -rf wrangler-dist",
110
+ "check:type": "tsc",
86
111
  "bundle": "node -r esbuild-register scripts/bundle.ts",
87
112
  "build": "npm run clean && npm run bundle",
113
+ "prepublishOnly": "npm run build",
88
114
  "start": "npm run bundle && NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
89
- "test": "npm run build && NODE_OPTIONS=--enable-source-maps jest --silent=false"
115
+ "test": "jest --silent=false --verbose=true",
116
+ "test-watch": "npm run test -- --runInBand --testTimeout=50000 --watch"
90
117
  },
91
118
  "engines": {
92
- "node": ">=16.0.0"
119
+ "node": ">=16.7.0"
93
120
  },
94
121
  "jest": {
122
+ "restoreMocks": true,
123
+ "testTimeout": 30000,
124
+ "testRegex": ".*.(test|spec)\\.[jt]sx?$",
125
+ "transformIgnorePatterns": [
126
+ "node_modules/(?!find-up|locate-path|p-locate|p-limit|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color)"
127
+ ],
128
+ "moduleNameMapper": {
129
+ "clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
130
+ "miniflare/cli": "<rootDir>/../../node_modules/miniflare/dist/src/cli.js"
131
+ },
95
132
  "transform": {
96
- "^.+\\.tsx?$": [
133
+ "^.+\\.c?(t|j)sx?$": [
97
134
  "esbuild-jest",
98
135
  {
99
- "sourcemap": true,
100
- "loaders": {
101
- ".spec.ts": "tsx"
102
- }
136
+ "sourcemap": true
103
137
  }
104
138
  ]
105
- }
139
+ },
140
+ "setupFilesAfterEnv": [
141
+ "<rootDir>/src/__tests__/jest.setup.ts"
142
+ ]
106
143
  }
107
- }
144
+ }
@@ -0,0 +1,62 @@
1
+ import path from "node:path";
2
+ import { build } from "esbuild";
3
+
4
+ type Options = {
5
+ routesModule: string;
6
+ outfile: string;
7
+ minify?: boolean;
8
+ sourcemap?: boolean;
9
+ fallbackService?: string;
10
+ watch?: boolean;
11
+ onEnd?: () => void;
12
+ };
13
+
14
+ export function buildWorker({
15
+ routesModule,
16
+ outfile = "bundle.js",
17
+ minify = false,
18
+ sourcemap = false,
19
+ fallbackService = "ASSETS",
20
+ watch = false,
21
+ onEnd = () => {},
22
+ }: Options) {
23
+ return build({
24
+ entryPoints: [
25
+ path.resolve(__dirname, "../pages/functions/template-worker.ts"),
26
+ ],
27
+ inject: [routesModule],
28
+ bundle: true,
29
+ format: "esm",
30
+ target: "esnext",
31
+ outfile,
32
+ minify,
33
+ sourcemap,
34
+ watch,
35
+ allowOverwrite: true,
36
+ define: {
37
+ __FALLBACK_SERVICE__: JSON.stringify(fallbackService),
38
+ },
39
+ plugins: [
40
+ {
41
+ name: "wrangler notifier and monitor",
42
+ setup(pluginBuild) {
43
+ pluginBuild.onEnd((result) => {
44
+ if (result.errors.length > 0) {
45
+ console.error(
46
+ `${result.errors.length} error(s) and ${result.warnings.length} warning(s) when compiling Worker.`
47
+ );
48
+ } else if (result.warnings.length > 0) {
49
+ console.warn(
50
+ `${result.warnings.length} warning(s) when compiling Worker.`
51
+ );
52
+ onEnd();
53
+ } else {
54
+ console.log("Compiled Worker successfully.");
55
+ onEnd();
56
+ }
57
+ });
58
+ },
59
+ },
60
+ ],
61
+ });
62
+ }
@@ -0,0 +1,223 @@
1
+ import { writeFileSync, mkdirSync } from "fs";
2
+ import { runInTempDir } from "../../src/__tests__/helpers/run-in-tmp";
3
+ import { toUrlPath } from "../../src/paths";
4
+ import { compareRoutes, generateConfigFromFileTree } from "./filepath-routing";
5
+ import type { UrlPath } from "../../src/paths";
6
+ import type { HTTPMethod, RouteConfig } from "./routes";
7
+
8
+ describe("filepath-routing", () => {
9
+ describe("compareRoutes()", () => {
10
+ test("routes / last", () => {
11
+ expect(
12
+ compareRoutes(routeConfig("/"), routeConfig("/foo"))
13
+ ).toBeGreaterThanOrEqual(1);
14
+ expect(
15
+ compareRoutes(routeConfig("/"), routeConfig("/:foo"))
16
+ ).toBeGreaterThanOrEqual(1);
17
+ expect(
18
+ compareRoutes(routeConfig("/"), routeConfig("/:foo*"))
19
+ ).toBeGreaterThanOrEqual(1);
20
+ });
21
+
22
+ test("routes with fewer segments come after those with more segments", () => {
23
+ expect(
24
+ compareRoutes(routeConfig("/foo"), routeConfig("/foo/bar"))
25
+ ).toBeGreaterThanOrEqual(1);
26
+ expect(
27
+ compareRoutes(routeConfig("/foo"), routeConfig("/foo/bar/cat"))
28
+ ).toBeGreaterThanOrEqual(1);
29
+ });
30
+
31
+ test("routes with wildcard segments come after those without", () => {
32
+ expect(compareRoutes(routeConfig("/:foo*"), routeConfig("/foo"))).toBe(1);
33
+ expect(compareRoutes(routeConfig("/:foo*"), routeConfig("/:foo"))).toBe(
34
+ 1
35
+ );
36
+ });
37
+
38
+ test("routes with dynamic segments come after those without", () => {
39
+ expect(compareRoutes(routeConfig("/:foo"), routeConfig("/foo"))).toBe(1);
40
+ });
41
+
42
+ test("routes with dynamic segments occurring earlier come after those with dynamic segments in later positions", () => {
43
+ expect(
44
+ compareRoutes(routeConfig("/foo/:id/bar"), routeConfig("/foo/bar/:id"))
45
+ ).toBe(1);
46
+ });
47
+
48
+ test("routes with no HTTP method come after those specifying a method", () => {
49
+ expect(
50
+ compareRoutes(routeConfig("/foo"), routeConfig("/foo", "GET"))
51
+ ).toBe(1);
52
+ });
53
+
54
+ test("two equal routes are sorted according to their original position in the list", () => {
55
+ expect(
56
+ compareRoutes(routeConfig("/foo", "GET"), routeConfig("/foo", "GET"))
57
+ ).toBe(0);
58
+ });
59
+
60
+ test("it returns -1 if the first argument should appear first in the list", () => {
61
+ expect(
62
+ compareRoutes(routeConfig("/foo", "GET"), routeConfig("/foo"))
63
+ ).toBe(-1);
64
+ });
65
+ });
66
+
67
+ describe("generateConfigFromFileTree", () => {
68
+ runInTempDir();
69
+
70
+ it("should generate a route entry for each file in the tree", async () => {
71
+ writeFileSync(
72
+ "foo.ts",
73
+ `
74
+ export function onRequestGet() {}
75
+ export function onRequestPost() {}
76
+ `
77
+ );
78
+ writeFileSync(
79
+ "bar.ts",
80
+ `
81
+ export function onRequestPut() {}
82
+ export function onRequestDelete() {}
83
+ `
84
+ );
85
+
86
+ mkdirSync("todos");
87
+
88
+ writeFileSync(
89
+ "todos/[id].ts",
90
+ `
91
+ export function onRequestPost() {}
92
+ export function onRequestDelete() {}
93
+ `
94
+ );
95
+
96
+ mkdirSync("authors");
97
+ mkdirSync("authors/[authorId]");
98
+ mkdirSync("authors/[authorId]/todos");
99
+
100
+ writeFileSync(
101
+ "authors/[authorId]/todos/[todoId].ts",
102
+ `
103
+ export function onRequestPost() {}
104
+ `
105
+ );
106
+
107
+ mkdirSync("books");
108
+
109
+ writeFileSync(
110
+ "books/[[title]].ts",
111
+ `
112
+ export function onRequestPost() {}
113
+ `
114
+ );
115
+
116
+ mkdirSync("cats");
117
+ mkdirSync("cats/[[breed]]");
118
+
119
+ writeFileSync(
120
+ "cats/[[breed]]/blah.ts",
121
+ `
122
+ export function onRequestPost() {}
123
+ `
124
+ );
125
+
126
+ // This won't actually work at runtime.
127
+ writeFileSync(
128
+ "cats/[[breed]]/[[name]].ts",
129
+ `
130
+ export function onRequestPost() {}
131
+ `
132
+ );
133
+
134
+ const entries = await generateConfigFromFileTree({
135
+ baseDir: ".",
136
+ baseURL: "/base" as UrlPath,
137
+ });
138
+ expect(entries).toMatchInlineSnapshot(`
139
+ Object {
140
+ "routes": Array [
141
+ Object {
142
+ "method": "POST",
143
+ "module": Array [
144
+ "authors/[authorId]/todos/[todoId].ts:onRequestPost",
145
+ ],
146
+ "routePath": "/base/authors/:authorId/todos/:todoId",
147
+ },
148
+ Object {
149
+ "method": "POST",
150
+ "module": Array [
151
+ "cats/[[breed]]/blah.ts:onRequestPost",
152
+ ],
153
+ "routePath": "/base/cats/:breed*/blah",
154
+ },
155
+ Object {
156
+ "method": "POST",
157
+ "module": Array [
158
+ "cats/[[breed]]/[[name]].ts:onRequestPost",
159
+ ],
160
+ "routePath": "/base/cats/:breed*/:name*",
161
+ },
162
+ Object {
163
+ "method": "DELETE",
164
+ "module": Array [
165
+ "todos/[id].ts:onRequestDelete",
166
+ ],
167
+ "routePath": "/base/todos/:id",
168
+ },
169
+ Object {
170
+ "method": "POST",
171
+ "module": Array [
172
+ "todos/[id].ts:onRequestPost",
173
+ ],
174
+ "routePath": "/base/todos/:id",
175
+ },
176
+ Object {
177
+ "method": "POST",
178
+ "module": Array [
179
+ "books/[[title]].ts:onRequestPost",
180
+ ],
181
+ "routePath": "/base/books/:title*",
182
+ },
183
+ Object {
184
+ "method": "DELETE",
185
+ "module": Array [
186
+ "bar.ts:onRequestDelete",
187
+ ],
188
+ "routePath": "/base/bar",
189
+ },
190
+ Object {
191
+ "method": "PUT",
192
+ "module": Array [
193
+ "bar.ts:onRequestPut",
194
+ ],
195
+ "routePath": "/base/bar",
196
+ },
197
+ Object {
198
+ "method": "GET",
199
+ "module": Array [
200
+ "foo.ts:onRequestGet",
201
+ ],
202
+ "routePath": "/base/foo",
203
+ },
204
+ Object {
205
+ "method": "POST",
206
+ "module": Array [
207
+ "foo.ts:onRequestPost",
208
+ ],
209
+ "routePath": "/base/foo",
210
+ },
211
+ ],
212
+ }
213
+ `);
214
+ });
215
+ });
216
+ });
217
+
218
+ function routeConfig(routePath: string, method?: string): RouteConfig {
219
+ return {
220
+ routePath: toUrlPath(routePath),
221
+ method: method as HTTPMethod,
222
+ };
223
+ }