diff options
Diffstat (limited to 'node_modules/wrangler/templates/pages-dev-pipeline.ts')
| -rw-r--r-- | node_modules/wrangler/templates/pages-dev-pipeline.ts | 31 |
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); + }, +}; |
