summaryrefslogtreecommitdiff
path: root/node_modules/wrangler/templates/pages-dev-pipeline.ts
diff options
context:
space:
mode:
authorakiyamn2023-09-24 23:22:21 +1000
committerakiyamn2023-09-24 23:22:21 +1000
commit4e87195739f2a5d9a05451b48773c8afdc680765 (patch)
tree9cba501844a4a11dcbdffc4050ed8189561c55ed /node_modules/wrangler/templates/pages-dev-pipeline.ts
downloadprice-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.tar.gz
price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.zip
Initial commit (by create-cloudflare CLI)
Diffstat (limited to 'node_modules/wrangler/templates/pages-dev-pipeline.ts')
-rw-r--r--node_modules/wrangler/templates/pages-dev-pipeline.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/wrangler/templates/pages-dev-pipeline.ts b/node_modules/wrangler/templates/pages-dev-pipeline.ts
new file mode 100644
index 0000000..27fa4e1
--- /dev/null
+++ b/node_modules/wrangler/templates/pages-dev-pipeline.ts
@@ -0,0 +1,31 @@
+// @ts-ignore entry point will get replaced
+import worker from "__ENTRY_POINT__";
+// @ts-ignore entry point will get replaced
+export * from "__ENTRY_POINT__";
+import { isRoutingRuleMatch } from "./pages-dev-util";
+
+// @ts-ignore routes are injected
+const routes = __ROUTES__;
+
+export default <ExportedHandler<{ ASSETS: Fetcher }>>{
+ fetch(request, env, context) {
+ const { pathname } = new URL(request.url);
+
+ for (const exclude of routes.exclude) {
+ if (isRoutingRuleMatch(pathname, exclude)) {
+ return env.ASSETS.fetch(request);
+ }
+ }
+
+ for (const include of routes.include) {
+ if (isRoutingRuleMatch(pathname, include)) {
+ if (worker.fetch === undefined) {
+ throw new TypeError("Entry point missing `fetch` handler");
+ }
+ return worker.fetch(request, env, context);
+ }
+ }
+
+ return env.ASSETS.fetch(request);
+ },
+};