@etus/bhono-app 0.1.1
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.
- package/dist/cli.d.ts +13 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.test.d.ts +1 -0
- package/dist/cli.test.js +26 -0
- package/dist/cli.test.js.map +1 -0
- package/dist/generator.d.ts +14 -0
- package/dist/generator.js +142 -0
- package/dist/generator.js.map +1 -0
- package/dist/generator.test.d.ts +1 -0
- package/dist/generator.test.js +127 -0
- package/dist/generator.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +25 -0
- package/dist/prompts.js +83 -0
- package/dist/prompts.js.map +1 -0
- package/dist/prompts.test.d.ts +1 -0
- package/dist/prompts.test.js +24 -0
- package/dist/prompts.test.js.map +1 -0
- package/dist/providers/cloudflare.d.ts +37 -0
- package/dist/providers/cloudflare.js +61 -0
- package/dist/providers/cloudflare.js.map +1 -0
- package/dist/providers/cloudflare.test.d.ts +1 -0
- package/dist/providers/cloudflare.test.js +29 -0
- package/dist/providers/cloudflare.test.js.map +1 -0
- package/dist/providers/github.d.ts +16 -0
- package/dist/providers/github.js +57 -0
- package/dist/providers/github.js.map +1 -0
- package/dist/providers/github.test.d.ts +1 -0
- package/dist/providers/github.test.js +16 -0
- package/dist/providers/github.test.js.map +1 -0
- package/dist/templates.d.ts +8 -0
- package/dist/templates.js +88 -0
- package/dist/templates.js.map +1 -0
- package/dist/templates.test.d.ts +1 -0
- package/dist/templates.test.js +26 -0
- package/dist/templates.test.js.map +1 -0
- package/package.json +36 -0
- package/templates/base/.claude/agents/architect-review.md +160 -0
- package/templates/base/.claude/agents/backend-architect.md +308 -0
- package/templates/base/.claude/agents/code-reviewer.md +170 -0
- package/templates/base/.claude/agents/performance-engineer.md +166 -0
- package/templates/base/.claude/agents/test-automator.md +219 -0
- package/templates/base/.claude/commands/check-skill-rules.md +53 -0
- package/templates/base/.claude/commands/claude-md.md +250 -0
- package/templates/base/.claude/commands/code-prompt.md +212 -0
- package/templates/base/.claude/commands/explain-code.md +194 -0
- package/templates/base/.claude/commands/init-projec.md +89 -0
- package/templates/base/.claude/commands/linear/README.md +297 -0
- package/templates/base/.claude/commands/linear/create-issue.md +190 -0
- package/templates/base/.claude/commands/linear/implement-issue.md +248 -0
- package/templates/base/.claude/commands/linear/process-triage.md +399 -0
- package/templates/base/.claude/commands/linear/setup.md +180 -0
- package/templates/base/.claude/commands/prime.md +9 -0
- package/templates/base/.claude/commands/review-gap.md +10 -0
- package/templates/base/.claude/commands/setup-aa.md +311 -0
- package/templates/base/.claude/commands/ship.md +262 -0
- package/templates/base/.claude/commands/tools.md +3 -0
- package/templates/base/.claude/docs/claude-progress.txt +107 -0
- package/templates/base/.claude/hooks/package-lock.json +556 -0
- package/templates/base/.claude/hooks/package.json +16 -0
- package/templates/base/.claude/hooks/skill-activation-prompt.sh +7 -0
- package/templates/base/.claude/hooks/skill-activation-prompt.ts +142 -0
- package/templates/base/.claude/hooks/tsconfig.json +19 -0
- package/templates/base/.claude/scripts/check-updates.sh +85 -0
- package/templates/base/.claude/scripts/install_pkgs.sh +66 -0
- package/templates/base/.claude/scripts/setup-project.sh +177 -0
- package/templates/base/.claude/scripts/validate-skill-rules.sh +94 -0
- package/templates/base/.claude/settings.json +113 -0
- package/templates/base/.claude/settings.local.json +11 -0
- package/templates/base/.claude/skills/architecture-analyzer/SKILL.md +531 -0
- package/templates/base/.claude/skills/architecture-analyzer/assets/report-template.md +215 -0
- package/templates/base/.claude/skills/architecture-analyzer/references/c4-templates.md +234 -0
- package/templates/base/.claude/skills/architecture-analyzer/references/confidence-levels.md +203 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/analyze_structure.py +266 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/analyze_tech_debt.py +776 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/extract_apis.py +338 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/generate_c4.py +283 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/generate_erd.py +935 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/map_dependencies.py +555 -0
- package/templates/base/.claude/skills/dev-browser/SKILL.md +318 -0
- package/templates/base/.claude/skills/dev-browser/bun.lock +443 -0
- package/templates/base/.claude/skills/dev-browser/package-lock.json +2927 -0
- package/templates/base/.claude/skills/dev-browser/package.json +27 -0
- package/templates/base/.claude/skills/dev-browser/scripts/start-server.ts +117 -0
- package/templates/base/.claude/skills/dev-browser/server.sh +24 -0
- package/templates/base/.claude/skills/dev-browser/src/client.ts +403 -0
- package/templates/base/.claude/skills/dev-browser/src/index.ts +281 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/browser-script.ts +877 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/index.ts +14 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/inject.ts +13 -0
- package/templates/base/.claude/skills/dev-browser/src/types.ts +27 -0
- package/templates/base/.claude/skills/dev-browser/tsconfig.json +36 -0
- package/templates/base/.claude/skills/dev-browser/vitest.config.ts +12 -0
- package/templates/base/.claude/skills/linear/SKILL.md +440 -0
- package/templates/base/.claude/skills/linear/examples.md +262 -0
- package/templates/base/.claude/skills/linear/lib/client.ts +51 -0
- package/templates/base/.claude/skills/linear/lib/config.ts +106 -0
- package/templates/base/.claude/skills/linear/lib/output.ts +34 -0
- package/templates/base/.claude/skills/linear/package-lock.json +698 -0
- package/templates/base/.claude/skills/linear/package.json +27 -0
- package/templates/base/.claude/skills/linear/reference.md +263 -0
- package/templates/base/.claude/skills/linear/scripts/comments/create.ts +47 -0
- package/templates/base/.claude/skills/linear/scripts/comments/list.ts +47 -0
- package/templates/base/.claude/skills/linear/scripts/issues/archive.ts +30 -0
- package/templates/base/.claude/skills/linear/scripts/issues/create.ts +279 -0
- package/templates/base/.claude/skills/linear/scripts/issues/get.ts +68 -0
- package/templates/base/.claude/skills/linear/scripts/issues/list.ts +67 -0
- package/templates/base/.claude/skills/linear/scripts/issues/update.ts +281 -0
- package/templates/base/.claude/skills/linear/scripts/labels/add-to-issue.ts +63 -0
- package/templates/base/.claude/skills/linear/scripts/labels/create.ts +45 -0
- package/templates/base/.claude/skills/linear/scripts/labels/list.ts +30 -0
- package/templates/base/.claude/skills/linear/scripts/list-teams.ts +52 -0
- package/templates/base/.claude/skills/linear/scripts/setup/setup-credentials.ts +96 -0
- package/templates/base/.claude/skills/linear/scripts/status/list.ts +31 -0
- package/templates/base/.claude/skills/linear/scripts/status/set-by-name.ts +78 -0
- package/templates/base/.claude/skills/linear/scripts/status/update.ts +44 -0
- package/templates/base/.claude/skills/linear/scripts/users/list.ts +59 -0
- package/templates/base/.claude/skills/linear/scripts/users/me.ts +20 -0
- package/templates/base/.claude/skills/linear/templates/README.md +203 -0
- package/templates/base/.claude/skills/linear/templates/api-reference.md +258 -0
- package/templates/base/.claude/skills/linear/templates/bug-report.md +99 -0
- package/templates/base/.claude/skills/linear/templates/feature-request.md +118 -0
- package/templates/base/.claude/skills/linear/templates/security-issue.md +162 -0
- package/templates/base/.claude/skills/linear/templates/sprint-task.md +175 -0
- package/templates/base/.claude/skills/linear/templates/tech-debt.md +137 -0
- package/templates/base/.claude/skills/linear/tsconfig.json +17 -0
- package/templates/base/.claude/skills/linear/workflows/issue-lifecycle.md +317 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/SKILL.md +113 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/global-setup.template.js +97 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/playwright.config.template.js +171 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/test-template.spec.js +163 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/README.md +26 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/ads.email-deeplink.spec.ts +12 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/mobile.realism.spec.ts +16 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/smoke.home.spec.ts +6 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/architecture.md +578 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/best-practices.md +260 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/ci-reporting.md +86 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/debugging.md +629 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/mobile-realism.md +50 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/optimization.md +488 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/patterns.md +513 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/resources.md +44 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/visual-a11y.md +66 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/auth-setup.js +202 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/performance-analyzer.js +240 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/trace-url.js +132 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/ci/github-actions.playwright.yml +78 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/fixtures.ts +44 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/global-setup.template.js +97 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/global.setup.ts +35 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/helpers/ad-gpt-observer.ts +80 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/helpers/chromium-mobile-profile.ts +93 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/playwright.config.template.js +171 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/playwright.config.ts +126 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/test-template.spec.js +163 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/tests/email-deeplink.ads.spec.ts +44 -0
- package/templates/base/.claude/skills/skill-rules.json +184 -0
- package/templates/base/.claude/skills/wrangler/SKILL.md +209 -0
- package/templates/base/.claude/skills/wrangler/resources/api.md +494 -0
- package/templates/base/.claude/skills/wrangler/resources/bundling.md +83 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/cert.md +64 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/check.md +66 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/containers.md +157 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/d1.md +843 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/delete.md +27 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/deploy.md +139 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/deployments.md +56 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/dev.md +157 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/dispatch-namespace.md +69 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/docs.md +61 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/how-to-run.md +62 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/hyperdrive.md +425 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/init.md +31 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-bulk.md +265 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-key.md +353 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-namespace.md +265 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/login.md +23 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/logout.md +19 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/mtls-certificate.md +69 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/pages.md +175 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/pipelines.md +76 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/queues.md +132 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-bucket.md +342 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-object.md +267 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-sql.md +65 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/rollback.md +40 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secret.md +308 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secrets-store-secret.md +100 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secrets-store-store.md +60 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/setup.md +67 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/tail.md +37 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/telemetry.md +64 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/triggers.md +39 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/types.md +73 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/vectorize.md +941 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/versions.md +95 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/whoami.md +49 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/workflows.md +117 -0
- package/templates/base/.claude/skills/wrangler/resources/commands.md +138 -0
- package/templates/base/.claude/skills/wrangler/resources/configuration.md +2176 -0
- package/templates/base/.claude/skills/wrangler/resources/custom-builds.md +55 -0
- package/templates/base/.claude/skills/wrangler/resources/deprecations.md +279 -0
- package/templates/base/.claude/skills/wrangler/resources/enviroments.md +416 -0
- package/templates/base/.claude/skills/wrangler/resources/extract_sections.py +119 -0
- package/templates/base/.claude/skills/wrangler/resources/process_content.py +94 -0
- package/templates/base/.claude/skills/wrangler/resources/system-enviroments-variables.md +120 -0
- package/templates/base/.dev.vars.example +15 -0
- package/templates/base/.env.example +29 -0
- package/templates/base/.github/workflows/test.yml +127 -0
- package/templates/base/.nycrc.json +16 -0
- package/templates/base/CLAUDE.md +218 -0
- package/templates/base/README.md +670 -0
- package/templates/base/auth-setup-error.png +0 -0
- package/templates/base/config/drizzle.config.ts +10 -0
- package/templates/base/config/eslint.config.js +364 -0
- package/templates/base/config/wrangler.json +76 -0
- package/templates/base/docs/app_spec.txt +879 -0
- package/templates/base/docs/app_spec_template.md +681 -0
- package/templates/base/docs/architecture/README.md +8 -0
- package/templates/base/docs/architecture/data-requirements.md +109 -0
- package/templates/base/docs/architecture/erd.md +91 -0
- package/templates/base/docs/features/feature_list.json +3128 -0
- package/templates/base/docs/hono-boilerplate-plan.md +1774 -0
- package/templates/base/docs/test-coverage-gap-analysis.md +242 -0
- package/templates/base/docs/testing.md +188 -0
- package/templates/base/index.html +16 -0
- package/templates/base/package.json +115 -0
- package/templates/base/playwright.config.ts +158 -0
- package/templates/base/pnpm-lock.yaml +8175 -0
- package/templates/base/scripts/capture-prod-session.ts +250 -0
- package/templates/base/scripts/generate-openapi.ts +23 -0
- package/templates/base/scripts/init.sh +121 -0
- package/templates/base/src/client/__tests__/button.test.tsx +30 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-dashboard-stats-cards-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-quick-action-cards-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-recent-activity-section-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-user-first-name-in-welcome-message-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-user-information-in-sidebar-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-render-dashboard-when-authenticated-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-show-navigation-sidebar-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-unauthenticated-should-redirect-to-login-when-not-authenticated-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-display-Google-OAuth-login-button-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-have-a-link-back-to-home-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-content-without-waiting-for-authentication-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-page-at--login-route-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-show-Terms-of-Service-and-Privacy-Policy-links-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-trigger-OAuth-flow-when-clicking-login-button-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-display-404-text-on-not-found-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-have-navigation-options-on-404-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-render-404-page-for-unknown-routes-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-account-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-integrations-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-settings-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-team-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-home-page-navigation-should-display-navigation-links-on-home-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-home-page-navigation-should-have-correct-link-destinations-on-home-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-allow-access-to-home-page-without-authentication-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-allow-access-to-login-page-without-authentication-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-dashboard-to-login-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-settings-to-login-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-team-to-login-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/authenticated-layout.test.tsx +252 -0
- package/templates/base/src/client/__tests__/routes/dashboard.test.tsx +136 -0
- package/templates/base/src/client/__tests__/routes/error-components.test.tsx +186 -0
- package/templates/base/src/client/__tests__/routes/login.test.tsx +112 -0
- package/templates/base/src/client/__tests__/routes/navigation.test.tsx +272 -0
- package/templates/base/src/client/__tests__/routes/root-layout.test.tsx +65 -0
- package/templates/base/src/client/__tests__/setup-browser.ts +15 -0
- package/templates/base/src/client/__tests__/setup.ts +32 -0
- package/templates/base/src/client/__tests__/test-utils.tsx +135 -0
- package/templates/base/src/client/api/.gitkeep +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-can-be-collapsed-by-default-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-expands-when-collapsed-and-expand-button-is-clicked-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-handles-logout-button-click-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-handles-navigation-clicks-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-hides-navigation-labels-when-collapsed-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-highlights-active-route-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-renders-sidebar-navigation-items-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-keyboard-shortcut-hint-when-expanded-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-info-when-authenticated-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-initials-in-avatar-fallback-1.png +0 -0
- package/templates/base/src/client/components/__tests__/error-boundary.test.tsx +97 -0
- package/templates/base/src/client/components/__tests__/sidebar.test.tsx +281 -0
- package/templates/base/src/client/components/error-boundary.tsx +68 -0
- package/templates/base/src/client/components/icons.tsx +106 -0
- package/templates/base/src/client/components/layout/.gitkeep +0 -0
- package/templates/base/src/client/components/sidebar.tsx +267 -0
- package/templates/base/src/client/components/ui/.gitkeep +0 -0
- package/templates/base/src/client/components/ui/__tests__/avatar.test.tsx +308 -0
- package/templates/base/src/client/components/ui/__tests__/card.test.tsx +214 -0
- package/templates/base/src/client/components/ui/__tests__/dialog.test.tsx +297 -0
- package/templates/base/src/client/components/ui/__tests__/error-fallback.test.tsx +145 -0
- package/templates/base/src/client/components/ui/__tests__/input.test.tsx +98 -0
- package/templates/base/src/client/components/ui/__tests__/loading-skeleton.test.tsx +139 -0
- package/templates/base/src/client/components/ui/__tests__/skeleton.test.tsx +44 -0
- package/templates/base/src/client/components/ui/__tests__/sonner.test.tsx +28 -0
- package/templates/base/src/client/components/ui/__tests__/tabs.test.tsx +233 -0
- package/templates/base/src/client/components/ui/avatar.tsx +101 -0
- package/templates/base/src/client/components/ui/badge.tsx +46 -0
- package/templates/base/src/client/components/ui/button.tsx +72 -0
- package/templates/base/src/client/components/ui/card.tsx +86 -0
- package/templates/base/src/client/components/ui/dialog.tsx +140 -0
- package/templates/base/src/client/components/ui/error-fallback.tsx +179 -0
- package/templates/base/src/client/components/ui/form.tsx +172 -0
- package/templates/base/src/client/components/ui/input.tsx +24 -0
- package/templates/base/src/client/components/ui/label.tsx +22 -0
- package/templates/base/src/client/components/ui/loading-skeleton.tsx +154 -0
- package/templates/base/src/client/components/ui/separator.tsx +33 -0
- package/templates/base/src/client/components/ui/skeleton.tsx +16 -0
- package/templates/base/src/client/components/ui/sonner.tsx +29 -0
- package/templates/base/src/client/components/ui/tabs.tsx +121 -0
- package/templates/base/src/client/hooks/.gitkeep +0 -0
- package/templates/base/src/client/hooks/__tests__/use-auth.test.tsx +306 -0
- package/templates/base/src/client/hooks/__tests__/use-theme.test.tsx +172 -0
- package/templates/base/src/client/hooks/use-auth.ts +53 -0
- package/templates/base/src/client/hooks/use-theme.tsx +78 -0
- package/templates/base/src/client/index.css +881 -0
- package/templates/base/src/client/lib/query-client.ts +11 -0
- package/templates/base/src/client/lib/utils.ts +7 -0
- package/templates/base/src/client/main.tsx +26 -0
- package/templates/base/src/client/routeTree.gen.ts +258 -0
- package/templates/base/src/client/router.ts +15 -0
- package/templates/base/src/client/routes/$.tsx +77 -0
- package/templates/base/src/client/routes/.gitkeep +0 -0
- package/templates/base/src/client/routes/__root.tsx +34 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-accept-invitation-button-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-decline-button-linking-to-homepage-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-invitation-details--email--workspace--role--1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-have-a-logo-link-to-homepage-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-render-invitation-page-with-inviter-name-and-workspace-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-show-terms-of-service-and-privacy-policy-links-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/invite.test.tsx +138 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-render-Active-Sessions-section-with-session-cards-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-render-page-with-correct-title--Account--1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-API-Access-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-Connected-Accounts-section-with-Google-connected-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-Danger-Zone-section-with-delete-button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-Security-section-with-Two-Factor-Authentication-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-API-documentation-section-should-display-API-documentation-link-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-Create-Webhook-Dialog-should-have-Add-Webhook-trigger-button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-category-filters-should-display-all-category-buttons-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-display-all-integration-cards-with-names-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-display-category-badges-on-cards-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Configure-button-for-connected-integrations-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Connect-button-for-not-connected-integrations-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Connected-badge-for-connected-integrations-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Available-Integrations-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Webhooks-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-connected-count-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-page-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-search-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-render-with-correct-title--Integrations--1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-filter-integrations-based-on-search-query-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-search-by-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-show-no-results-message-when-search-has-no-matches-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-existing-webhook-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-events-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-last-delivery-info-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-success-status-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-have-Add-Webhook-button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Account-tab-should-display-connected-accounts-section-with-Google-provider-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Account-tab-should-display-sessions-and-danger-zone-sections-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-all-notification-toggle-options-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-email-notifications-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-toggle-switches-for-notification-options-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-have-toggles-checked-by-default-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display--Save-Changes--button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-personal-information-form-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-profile-picture-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-email-in-disabled-email-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-initials-in-avatar-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-name-in-the-name-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-all-three-tabs-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-page-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-render-with-correct-title--Settings--1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-show-Profile-tab-as-default-active-tab-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-switch-to-Account-tab-when-clicked-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-switch-to-Notifications-tab-when-clicked-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-display-Active-Members-section-with-member-count-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-display-Pending-Invitations-section-with-invitation-details-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-have-invite-member-button-that-can-be-clicked-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-render-page-with-correct-title-and-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-render-search-input-that-filters-team-members-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-show-current-user-with---you---indicator-and-role-badge-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/account.test.tsx +324 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/integrations.test.tsx +520 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/settings.test.tsx +414 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/team.test.tsx +374 -0
- package/templates/base/src/client/routes/_authenticated/account.tsx +416 -0
- package/templates/base/src/client/routes/_authenticated/dashboard.tsx +151 -0
- package/templates/base/src/client/routes/_authenticated/integrations.tsx +553 -0
- package/templates/base/src/client/routes/_authenticated/settings.tsx +310 -0
- package/templates/base/src/client/routes/_authenticated/team.tsx +395 -0
- package/templates/base/src/client/routes/_authenticated.tsx +69 -0
- package/templates/base/src/client/routes/index.tsx +155 -0
- package/templates/base/src/client/routes/invite.$token.tsx +191 -0
- package/templates/base/src/client/routes/login.tsx +92 -0
- package/templates/base/src/server/__tests__/fixtures.ts +461 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/db.test.ts +239 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/kv.test.ts +293 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/r2.test.ts +363 -0
- package/templates/base/src/server/__tests__/mocks/db.ts +186 -0
- package/templates/base/src/server/__tests__/mocks/index.ts +33 -0
- package/templates/base/src/server/__tests__/mocks/kv.ts +286 -0
- package/templates/base/src/server/__tests__/mocks/r2.ts +397 -0
- package/templates/base/src/server/__tests__/setup.ts +281 -0
- package/templates/base/src/server/auth/__tests__/guards.test.ts +162 -0
- package/templates/base/src/server/auth/guards.ts +92 -0
- package/templates/base/src/server/auth/permissions.test.ts +45 -0
- package/templates/base/src/server/auth/permissions.ts +139 -0
- package/templates/base/src/server/auth/roles.test.ts +169 -0
- package/templates/base/src/server/auth/roles.ts +141 -0
- package/templates/base/src/server/db/client.ts +12 -0
- package/templates/base/src/server/db/schema/accounts.ts +20 -0
- package/templates/base/src/server/db/schema/audit-logs.ts +26 -0
- package/templates/base/src/server/db/schema/index.ts +7 -0
- package/templates/base/src/server/db/schema/invitations.ts +30 -0
- package/templates/base/src/server/db/schema/refresh-tokens.ts +22 -0
- package/templates/base/src/server/db/schema/user-accounts.ts +25 -0
- package/templates/base/src/server/db/schema/users.ts +33 -0
- package/templates/base/src/server/db/seed.ts +267 -0
- package/templates/base/src/server/env.test.ts +84 -0
- package/templates/base/src/server/env.ts +78 -0
- package/templates/base/src/server/index.ts +82 -0
- package/templates/base/src/server/lib/audit.ts +73 -0
- package/templates/base/src/server/lib/audited-db.test.ts +107 -0
- package/templates/base/src/server/lib/audited-db.ts +154 -0
- package/templates/base/src/server/lib/email.test.ts +116 -0
- package/templates/base/src/server/lib/email.ts +82 -0
- package/templates/base/src/server/lib/errors.test.ts +49 -0
- package/templates/base/src/server/lib/errors.ts +64 -0
- package/templates/base/src/server/lib/oauth.test.ts +238 -0
- package/templates/base/src/server/lib/oauth.ts +113 -0
- package/templates/base/src/server/lib/pagination.test.ts +52 -0
- package/templates/base/src/server/lib/pagination.ts +32 -0
- package/templates/base/src/server/lib/password.test.ts +151 -0
- package/templates/base/src/server/lib/password.ts +151 -0
- package/templates/base/src/server/lib/providers.test.ts +105 -0
- package/templates/base/src/server/lib/providers.ts +62 -0
- package/templates/base/src/server/lib/r2-storage.test.ts +202 -0
- package/templates/base/src/server/lib/r2-storage.ts +107 -0
- package/templates/base/src/server/lib/schema-helpers.ts +16 -0
- package/templates/base/src/server/lib/session.test.ts +758 -0
- package/templates/base/src/server/lib/session.ts +267 -0
- package/templates/base/src/server/lib/tokens.test.ts +208 -0
- package/templates/base/src/server/lib/tokens.ts +65 -0
- package/templates/base/src/server/lib/transaction.test.ts +45 -0
- package/templates/base/src/server/lib/transaction.ts +24 -0
- package/templates/base/src/server/middleware/account.test.ts +201 -0
- package/templates/base/src/server/middleware/account.ts +66 -0
- package/templates/base/src/server/middleware/auth.test.ts +345 -0
- package/templates/base/src/server/middleware/auth.ts +146 -0
- package/templates/base/src/server/middleware/cors.test.ts +88 -0
- package/templates/base/src/server/middleware/cors.ts +26 -0
- package/templates/base/src/server/middleware/error-handler.test.ts +69 -0
- package/templates/base/src/server/middleware/error-handler.ts +43 -0
- package/templates/base/src/server/middleware/index.ts +8 -0
- package/templates/base/src/server/middleware/rate-limit.test.ts +472 -0
- package/templates/base/src/server/middleware/rate-limit.ts +294 -0
- package/templates/base/src/server/middleware/request-context.test.ts +175 -0
- package/templates/base/src/server/middleware/request-context.ts +28 -0
- package/templates/base/src/server/middleware/request-logger.test.ts +92 -0
- package/templates/base/src/server/middleware/request-logger.ts +50 -0
- package/templates/base/src/server/routes/accounts/__tests__/handlers.test.ts +460 -0
- package/templates/base/src/server/routes/accounts/handlers.ts +179 -0
- package/templates/base/src/server/routes/accounts/index.ts +55 -0
- package/templates/base/src/server/routes/accounts/routes.ts +205 -0
- package/templates/base/src/server/routes/accounts/schemas.ts +31 -0
- package/templates/base/src/server/routes/api.ts +37 -0
- package/templates/base/src/server/routes/audits/__tests__/handlers.test.ts +349 -0
- package/templates/base/src/server/routes/audits/handlers.ts +37 -0
- package/templates/base/src/server/routes/audits/index.ts +14 -0
- package/templates/base/src/server/routes/audits/routes.ts +29 -0
- package/templates/base/src/server/routes/audits/schemas.ts +43 -0
- package/templates/base/src/server/routes/auth/__tests__/handlers.test.ts +381 -0
- package/templates/base/src/server/routes/auth/handlers.ts +222 -0
- package/templates/base/src/server/routes/auth/index.ts +37 -0
- package/templates/base/src/server/routes/auth/routes.ts +136 -0
- package/templates/base/src/server/routes/auth/schemas.ts +48 -0
- package/templates/base/src/server/routes/auth/test-login.ts +156 -0
- package/templates/base/src/server/routes/health/__tests__/handlers.test.ts +237 -0
- package/templates/base/src/server/routes/health/handlers.ts +83 -0
- package/templates/base/src/server/routes/health/index.ts +13 -0
- package/templates/base/src/server/routes/health/routes.ts +90 -0
- package/templates/base/src/server/routes/index.ts +53 -0
- package/templates/base/src/server/routes/invitations/__tests__/handlers.test.ts +473 -0
- package/templates/base/src/server/routes/invitations/handlers.ts +71 -0
- package/templates/base/src/server/routes/invitations/index.ts +25 -0
- package/templates/base/src/server/routes/invitations/routes.ts +69 -0
- package/templates/base/src/server/routes/invitations/schemas.ts +39 -0
- package/templates/base/src/server/routes/openapi.ts +14 -0
- package/templates/base/src/server/routes/schemas.ts +53 -0
- package/templates/base/src/server/routes/storage/__tests__/handlers.test.ts +408 -0
- package/templates/base/src/server/routes/storage/handlers.ts +100 -0
- package/templates/base/src/server/routes/storage/index.ts +42 -0
- package/templates/base/src/server/routes/storage/routes.ts +91 -0
- package/templates/base/src/server/routes/storage/schemas.ts +56 -0
- package/templates/base/src/server/routes/users/__tests__/handlers.test.ts +526 -0
- package/templates/base/src/server/routes/users/handlers.ts +228 -0
- package/templates/base/src/server/routes/users/index.ts +67 -0
- package/templates/base/src/server/routes/users/routes.ts +265 -0
- package/templates/base/src/server/routes/users/schemas.ts +67 -0
- package/templates/base/src/server/services/__tests__/accounts.test.ts +764 -0
- package/templates/base/src/server/services/__tests__/audits.test.ts +235 -0
- package/templates/base/src/server/services/__tests__/auth.test.ts +765 -0
- package/templates/base/src/server/services/__tests__/invitations.test.ts +704 -0
- package/templates/base/src/server/services/__tests__/users.test.ts +755 -0
- package/templates/base/src/server/services/accounts.ts +269 -0
- package/templates/base/src/server/services/audits.ts +82 -0
- package/templates/base/src/server/services/auth.ts +225 -0
- package/templates/base/src/server/services/index.ts +6 -0
- package/templates/base/src/server/services/invitations.ts +306 -0
- package/templates/base/src/server/services/users.ts +350 -0
- package/templates/base/src/server/types/auth.ts +36 -0
- package/templates/base/src/server/types/index.ts +117 -0
- package/templates/base/src/shared/schemas/.gitkeep +0 -0
- package/templates/base/src/shared/schemas/__tests__/schemas.test.ts +547 -0
- package/templates/base/src/shared/schemas/account.ts +15 -0
- package/templates/base/src/shared/schemas/index.ts +6 -0
- package/templates/base/src/shared/schemas/invitation.ts +9 -0
- package/templates/base/src/shared/schemas/profile.ts +10 -0
- package/templates/base/src/shared/schemas/user.ts +16 -0
- package/templates/base/src/shared/schemas/webhook.ts +12 -0
- package/templates/base/src/shared/types/.gitkeep +0 -0
- package/templates/base/src/shared/types/account.ts +12 -0
- package/templates/base/src/shared/types/api.ts +1399 -0
- package/templates/base/src/shared/types/auth.ts +24 -0
- package/templates/base/src/shared/types/index.ts +5 -0
- package/templates/base/src/shared/types/user.ts +31 -0
- package/templates/base/src/test/vitest-zod-matcher.ts +37 -0
- package/templates/base/src/test/vitest.d.ts +19 -0
- package/templates/base/tests/e2e/README.md +141 -0
- package/templates/base/tests/e2e/a11y/accessibility.spec.ts +925 -0
- package/templates/base/tests/e2e/a11y/keyboard-navigation.spec.ts +610 -0
- package/templates/base/tests/e2e/api/accounts.spec.ts +148 -0
- package/templates/base/tests/e2e/api/audit-logs.spec.ts +130 -0
- package/templates/base/tests/e2e/api/authenticated-api.spec.ts +311 -0
- package/templates/base/tests/e2e/api/storage.spec.ts +109 -0
- package/templates/base/tests/e2e/auth-flows.unauth.spec.ts +117 -0
- package/templates/base/tests/e2e/auth-logout.unauth.spec.ts +103 -0
- package/templates/base/tests/e2e/auth.setup.ts +115 -0
- package/templates/base/tests/e2e/auth.spec.ts +146 -0
- package/templates/base/tests/e2e/compatibility/cross-browser.spec.ts +152 -0
- package/templates/base/tests/e2e/compatibility/cross-browser.spec.ts-snapshots/login-chromium-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/crud/account.spec.ts +356 -0
- package/templates/base/tests/e2e/crud/integrations.spec.ts +419 -0
- package/templates/base/tests/e2e/crud/team.spec.ts +287 -0
- package/templates/base/tests/e2e/crud/users.spec.ts +239 -0
- package/templates/base/tests/e2e/errors/error-boundary.spec.ts +428 -0
- package/templates/base/tests/e2e/errors/error-handling.spec.ts +47 -0
- package/templates/base/tests/e2e/errors/error-handling.unauth.spec.ts +205 -0
- package/templates/base/tests/e2e/fixtures.ts +266 -0
- package/templates/base/tests/e2e/forms/validation.spec.ts +569 -0
- package/templates/base/tests/e2e/invitations/invite-flow.unauth.spec.ts +204 -0
- package/templates/base/tests/e2e/journeys/account-lifecycle.spec.ts +314 -0
- package/templates/base/tests/e2e/journeys/audit-investigation.spec.ts +299 -0
- package/templates/base/tests/e2e/journeys/auth-onboarding.spec.ts +232 -0
- package/templates/base/tests/e2e/journeys/critical-flows.spec.ts +281 -0
- package/templates/base/tests/e2e/journeys/error-recovery.spec.ts +354 -0
- package/templates/base/tests/e2e/journeys/file-management.spec.ts +307 -0
- package/templates/base/tests/e2e/journeys/integrations.spec.ts +372 -0
- package/templates/base/tests/e2e/journeys/multi-account.spec.ts +317 -0
- package/templates/base/tests/e2e/journeys/rbac-enforcement.spec.ts +389 -0
- package/templates/base/tests/e2e/journeys/settings-profile.spec.ts +400 -0
- package/templates/base/tests/e2e/journeys/team-collaboration.spec.ts +410 -0
- package/templates/base/tests/e2e/mobile/responsive.spec.ts +178 -0
- package/templates/base/tests/e2e/navigation/routing.spec.ts +371 -0
- package/templates/base/tests/e2e/navigation/sidebar.spec.ts +425 -0
- package/templates/base/tests/e2e/pages/ui-features.spec.ts +393 -0
- package/templates/base/tests/e2e/performance/baselines.spec.ts +162 -0
- package/templates/base/tests/e2e/performance/benchmarks.spec.ts +371 -0
- package/templates/base/tests/e2e/smoke.unauth.spec.ts +196 -0
- package/templates/base/tests/e2e/visual/components.spec.ts +650 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/confirmation-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-background-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-card-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-sidebar-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dashboard-card-single-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dialog-content-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dialog-with-backdrop-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/empty-search-results-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/input-default-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/input-focus-ring-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-focus-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-hover-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-active-nav-item-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-collapsed-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-navigation-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts +192 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/account-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/create-webhook-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/dashboard-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/delete-account-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/integrations-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/invite-member-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/login-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/settings-account-tab-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/settings-profile-tab-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/sidebar-navigation-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/team-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts +230 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/404-page-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/404-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/account-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/login-page-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/login-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/settings-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/team-invite-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/team-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/webhook-create-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/theme-colors.spec.ts +293 -0
- package/templates/base/tests/e2e/visual/ui-components.spec.ts +502 -0
- package/templates/base/tests/integration/accounts/crud.test.ts +1402 -0
- package/templates/base/tests/integration/audits/list.test.ts +1133 -0
- package/templates/base/tests/integration/auth/auth-service.test.ts +415 -0
- package/templates/base/tests/integration/auth/invitation-token.test.ts +529 -0
- package/templates/base/tests/integration/auth/logout.test.ts +524 -0
- package/templates/base/tests/integration/auth/oauth.test.ts +768 -0
- package/templates/base/tests/integration/auth/refresh-token.test.ts +364 -0
- package/templates/base/tests/integration/auth/session-expiry.test.ts +569 -0
- package/templates/base/tests/integration/auth/session.test.ts +520 -0
- package/templates/base/tests/integration/auth/super-admin.test.ts +451 -0
- package/templates/base/tests/integration/authorization/analytics-role.test.ts +1026 -0
- package/templates/base/tests/integration/authorization/billing-role.test.ts +776 -0
- package/templates/base/tests/integration/authorization/guards-roles.test.ts +539 -0
- package/templates/base/tests/integration/authorization/multi-tenancy.test.ts +1112 -0
- package/templates/base/tests/integration/authorization/role-hierarchy.test.ts +931 -0
- package/templates/base/tests/integration/authorization/roles.test.ts +1347 -0
- package/templates/base/tests/integration/config/production-behavior.test.ts +536 -0
- package/templates/base/tests/integration/db/constraints.test.ts +695 -0
- package/templates/base/tests/integration/fixtures/accounts.ts +136 -0
- package/templates/base/tests/integration/fixtures/index.ts +232 -0
- package/templates/base/tests/integration/fixtures/invitations.ts +195 -0
- package/templates/base/tests/integration/fixtures/users.ts +144 -0
- package/templates/base/tests/integration/health/health.test.ts +351 -0
- package/templates/base/tests/integration/invitations/crud.test.ts +1457 -0
- package/templates/base/tests/integration/invitations/email.test.ts +506 -0
- package/templates/base/tests/integration/lib/email.test.ts +174 -0
- package/templates/base/tests/integration/lib/oauth.test.ts +368 -0
- package/templates/base/tests/integration/lib/password.test.ts +192 -0
- package/templates/base/tests/integration/lib/schema-helpers.test.ts +129 -0
- package/templates/base/tests/integration/lib/tokens.test.ts +304 -0
- package/templates/base/tests/integration/middleware/auth.test.ts +499 -0
- package/templates/base/tests/integration/middleware/cors.test.ts +334 -0
- package/templates/base/tests/integration/middleware/request-context.test.ts +156 -0
- package/templates/base/tests/integration/middleware/request-logger.test.ts +313 -0
- package/templates/base/tests/integration/performance/response-times.test.ts +509 -0
- package/templates/base/tests/integration/security/cookie-security.test.ts +567 -0
- package/templates/base/tests/integration/security/csrf-protection.test.ts +542 -0
- package/templates/base/tests/integration/security/jwt-validation.test.ts +209 -0
- package/templates/base/tests/integration/security/log-sanitization.test.ts +658 -0
- package/templates/base/tests/integration/security/rate-limiting.test.ts +1251 -0
- package/templates/base/tests/integration/security/sql-injection.test.ts +663 -0
- package/templates/base/tests/integration/security/token-hashing.test.ts +371 -0
- package/templates/base/tests/integration/security/xss-prevention.test.ts +541 -0
- package/templates/base/tests/integration/setup.ts +834 -0
- package/templates/base/tests/integration/smoke.test.ts +288 -0
- package/templates/base/tests/integration/storage/upload.test.ts +1162 -0
- package/templates/base/tests/integration/storage/validation.test.ts +746 -0
- package/templates/base/tests/integration/users/crud.test.ts +1297 -0
- package/templates/base/tests/integration/users/list.test.ts +698 -0
- package/templates/base/tests/integration/vitest.config.ts +80 -0
- package/templates/base/tsconfig.app.json +18 -0
- package/templates/base/tsconfig.json +39 -0
- package/templates/base/tsconfig.node.json +16 -0
- package/templates/base/tsconfig.server.json +26 -0
- package/templates/base/tsconfig.tsbuildinfo +1 -0
- package/templates/base/vite.config.ts +46 -0
- package/templates/base/vitest.config.browser.ts +47 -0
- package/templates/base/vitest.config.frontend.ts +47 -0
- package/templates/base/vitest.config.ts +82 -0
- package/templates/base/vitest.workspace.ts +22 -0
- package/templates/modules/audit-logs/.gitkeep +0 -0
- package/templates/modules/billing/.gitkeep +0 -0
- package/templates/modules/invitations/.gitkeep +0 -0
- package/templates/modules/storage/.gitkeep +0 -0
- package/templates/modules/webhooks/.gitkeep +0 -0
- package/templates/providers/auth-email/.gitkeep +0 -0
- package/templates/providers/auth-github/.gitkeep +0 -0
- package/templates/providers/auth-google/.gitkeep +0 -0
- package/templates/providers/email-resend/.gitkeep +0 -0
- package/templates/providers/email-sendgrid/.gitkeep +0 -0
|
@@ -0,0 +1,2176 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configuration - Wrangler · Cloudflare Workers docs
|
|
3
|
+
description: Use a configuration file to customize the development and
|
|
4
|
+
deployment setup for your Worker project and other Developer Platform
|
|
5
|
+
products.
|
|
6
|
+
lastUpdated: 2025-11-10T15:01:11.000Z
|
|
7
|
+
chatbotDeprioritize: false
|
|
8
|
+
source_url:
|
|
9
|
+
html: https://developers.cloudflare.com/workers/wrangler/configuration/
|
|
10
|
+
md: https://developers.cloudflare.com/workers/wrangler/configuration/index.md
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
Wrangler optionally uses a configuration file to customize the development and deployment setup for a Worker.
|
|
14
|
+
|
|
15
|
+
Note
|
|
16
|
+
|
|
17
|
+
As of Wrangler v3.91.0 Wrangler supports both JSON (`wrangler.json` or `wrangler.jsonc`) and TOML (`wrangler.toml`) for its configuration file. Prior to that version, only `wrangler.toml` was supported.
|
|
18
|
+
|
|
19
|
+
Cloudflare recommends using `wrangler.jsonc` for new projects, and some newer Wrangler features will only be available to projects using a JSON config file.
|
|
20
|
+
|
|
21
|
+
The format of Wrangler's configuration file is exactly the same across both languages, only the syntax differs.
|
|
22
|
+
|
|
23
|
+
You can use one of the many available online converters to easily switch between the two.
|
|
24
|
+
|
|
25
|
+
Throughout this page and the rest of Cloudflare's documentation, configuration snippets are provided as both JSON and TOML.
|
|
26
|
+
|
|
27
|
+
It is best practice to treat Wrangler's configuration file as the [source of truth](#source-of-truth) for configuring a Worker.
|
|
28
|
+
|
|
29
|
+
## Sample Wrangler configuration
|
|
30
|
+
|
|
31
|
+
- wrangler.jsonc
|
|
32
|
+
|
|
33
|
+
```jsonc
|
|
34
|
+
{
|
|
35
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
36
|
+
"name": "my-worker",
|
|
37
|
+
"main": "src/index.js",
|
|
38
|
+
"compatibility_date": "2022-07-12",
|
|
39
|
+
"workers_dev": false,
|
|
40
|
+
"route": {
|
|
41
|
+
"pattern": "example.org/*",
|
|
42
|
+
"zone_name": "example.org"
|
|
43
|
+
},
|
|
44
|
+
"kv_namespaces": [
|
|
45
|
+
{
|
|
46
|
+
"binding": "<MY_NAMESPACE>",
|
|
47
|
+
"id": "<KV_ID>"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"env": {
|
|
51
|
+
"staging": {
|
|
52
|
+
"name": "my-worker-staging",
|
|
53
|
+
"route": {
|
|
54
|
+
"pattern": "staging.example.org/*",
|
|
55
|
+
"zone_name": "example.org"
|
|
56
|
+
},
|
|
57
|
+
"kv_namespaces": [
|
|
58
|
+
{
|
|
59
|
+
"binding": "<MY_NAMESPACE>",
|
|
60
|
+
"id": "<STAGING_KV_ID>"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- wrangler.toml
|
|
69
|
+
|
|
70
|
+
```toml
|
|
71
|
+
# Top-level configuration
|
|
72
|
+
name = "my-worker"
|
|
73
|
+
main = "src/index.js"
|
|
74
|
+
compatibility_date = "2022-07-12"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
workers_dev = false
|
|
78
|
+
route = { pattern = "example.org/*", zone_name = "example.org" }
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
kv_namespaces = [
|
|
82
|
+
{ binding = "<MY_NAMESPACE>", id = "<KV_ID>" }
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
[env.staging]
|
|
87
|
+
name = "my-worker-staging"
|
|
88
|
+
route = { pattern = "staging.example.org/*", zone_name = "example.org" }
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
kv_namespaces = [
|
|
92
|
+
{ binding = "<MY_NAMESPACE>", id = "<STAGING_KV_ID>" }
|
|
93
|
+
]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Environments
|
|
97
|
+
|
|
98
|
+
You can define different configurations for a Worker using Wrangler [environments](https://developers.cloudflare.com/workers/wrangler/environments/). There is a default (top-level) environment and you can create named environments that provide environment-specific configuration.
|
|
99
|
+
|
|
100
|
+
These are defined under `[env.<name>]` keys, such as `[env.staging]` which you can then preview or deploy with the `-e` / `--env` flag in the `wrangler` commands like `npx wrangler deploy --env staging`.
|
|
101
|
+
|
|
102
|
+
The majority of keys are inheritable, meaning that top-level configuration can be used in environments. [Bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/), such as `vars` or `kv_namespaces`, are not inheritable and need to be defined explicitly.
|
|
103
|
+
|
|
104
|
+
Further, there are a few keys that can _only_ appear at the top-level.
|
|
105
|
+
|
|
106
|
+
Note
|
|
107
|
+
|
|
108
|
+
If you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), you select the environment at dev or build time via the `CLOUDFLARE_ENV` environment variable rather than the `--env` flag. Otherwise, environments are defined in your Worker config file as usual. For more detail on using environments with the Cloudflare Vite plugin, refer to the [plugin documentation](https://developers.cloudflare.com/workers/vite-plugin/reference/cloudflare-environments/).
|
|
109
|
+
|
|
110
|
+
## Automatic provisioning
|
|
111
|
+
|
|
112
|
+
[Beta](https://developers.cloudflare.com/changelog/2025-10-24-automatic-resource-provisioning/)
|
|
113
|
+
|
|
114
|
+
Wrangler can automatically provision resources for you when you deploy your Worker without you having to create them ahead of time.
|
|
115
|
+
|
|
116
|
+
This currently works for KV, R2, and D1 bindings.
|
|
117
|
+
|
|
118
|
+
To use this feature, add bindings to your configuration file _without_ adding resource IDs, or in the case of R2, a bucket name. Resources will be created with the name of your worker as the prefix.
|
|
119
|
+
|
|
120
|
+
- wrangler.jsonc
|
|
121
|
+
|
|
122
|
+
```jsonc
|
|
123
|
+
{
|
|
124
|
+
"kv_namespaces": [
|
|
125
|
+
{
|
|
126
|
+
"binding": "<MY_KV_NAMESPACE>"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- wrangler.toml
|
|
133
|
+
|
|
134
|
+
```toml
|
|
135
|
+
kv_namespaces = [
|
|
136
|
+
{ binding = "<MY_KV_NAMESPACE>" }
|
|
137
|
+
]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
When you run `wrangler dev`, local resources will automatically be created which persist between runs. When you run `wrangler deploy`, resources will be created for you, and their IDs will be written back to your configuration file.
|
|
141
|
+
|
|
142
|
+
If you deploy a worker with resources and no resource IDs from the dashboard (for example, via GitHub), resources will be created, but their IDs will only be accessible via the dashboard. Currently, these resource IDs will not be written back to your repository.
|
|
143
|
+
|
|
144
|
+
## Top-level only keys
|
|
145
|
+
|
|
146
|
+
Top-level keys apply to the Worker as a whole (and therefore all environments). They cannot be defined within named environments.
|
|
147
|
+
|
|
148
|
+
- `keep_vars` boolean optional
|
|
149
|
+
|
|
150
|
+
- Whether Wrangler should keep variables configured in the dashboard on deploy. Refer to [source of truth](#source-of-truth).
|
|
151
|
+
|
|
152
|
+
- `migrations` object\[] optional
|
|
153
|
+
|
|
154
|
+
- When making changes to your Durable Object classes, you must perform a migration. Refer to [Durable Object migrations](https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/).
|
|
155
|
+
|
|
156
|
+
- `send_metrics` boolean optional
|
|
157
|
+
|
|
158
|
+
- Whether Wrangler should send usage data to Cloudflare for this project. Defaults to `true`. You can learn more about this in our [data policy](https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md).
|
|
159
|
+
|
|
160
|
+
- `site` object optional deprecated
|
|
161
|
+
|
|
162
|
+
- See the [Workers Sites](#workers-sites) section below for more information. Cloudflare Pages and Workers Assets is preferred over this approach.
|
|
163
|
+
- This is not supported by the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
164
|
+
|
|
165
|
+
## Inheritable keys
|
|
166
|
+
|
|
167
|
+
Inheritable keys are configurable at the top-level, and can be inherited (or overridden) by environment-specific configuration.
|
|
168
|
+
|
|
169
|
+
Note
|
|
170
|
+
|
|
171
|
+
At a minimum, the `name`, `main` and `compatibility_date` keys are required to deploy a Worker.
|
|
172
|
+
|
|
173
|
+
The `main` key is optional for assets-only Workers.
|
|
174
|
+
|
|
175
|
+
- `name` string required
|
|
176
|
+
|
|
177
|
+
- The name of your Worker. Alphanumeric characters (`a`,`b`,`c`, etc.) and dashes (`-`) only. Do not use underscores (`_`). Worker names can be up to 255 characters. If you plan to use a [`workers.dev` subdomain](https://developers.cloudflare.com/workers/configuration/routing/workers-dev/), the name must be 63 characters or less and cannot start or end with a dash.
|
|
178
|
+
|
|
179
|
+
- `main` string required
|
|
180
|
+
|
|
181
|
+
- The path to the entrypoint of your Worker that will be executed. For example: `./src/index.ts`.
|
|
182
|
+
|
|
183
|
+
- `compatibility_date` string required
|
|
184
|
+
|
|
185
|
+
- A date in the form `yyyy-mm-dd`, which will be used to determine which version of the Workers runtime is used. Refer to [Compatibility dates](https://developers.cloudflare.com/workers/configuration/compatibility-dates/).
|
|
186
|
+
|
|
187
|
+
- `account_id` string optional
|
|
188
|
+
|
|
189
|
+
- This is the ID of the account associated with your zone. You might have more than one account, so make sure to use the ID of the account associated with the zone/route you provide, if you provide one. It can also be specified through the `CLOUDFLARE_ACCOUNT_ID` environment variable.
|
|
190
|
+
|
|
191
|
+
- `compatibility_flags` string\[] optional
|
|
192
|
+
|
|
193
|
+
- A list of flags that enable features from upcoming features of the Workers runtime, usually used together with `compatibility_date`. Refer to [compatibility dates](https://developers.cloudflare.com/workers/configuration/compatibility-dates/).
|
|
194
|
+
|
|
195
|
+
- `workers_dev` boolean optional
|
|
196
|
+
|
|
197
|
+
- Enables use of `*.workers.dev` subdomain to deploy your Worker. If you have a Worker that is only for `scheduled` events, you can set this to `false`. Defaults to `true`. Refer to [types of routes](#types-of-routes).
|
|
198
|
+
|
|
199
|
+
- `preview_urls` boolean optional
|
|
200
|
+
|
|
201
|
+
- Enables use of Preview URLs to test your Worker. Defaults to value of `workers_dev`. Refer to [Preview URLs](https://developers.cloudflare.com/workers/configuration/previews).
|
|
202
|
+
|
|
203
|
+
- `route` Route optional
|
|
204
|
+
|
|
205
|
+
- A route that your Worker should be deployed to. Only one of `routes` or `route` is required. Refer to [types of routes](#types-of-routes).
|
|
206
|
+
|
|
207
|
+
- `routes` Route\[] optional
|
|
208
|
+
|
|
209
|
+
- An array of routes that your Worker should be deployed to. Only one of `routes` or `route` is required. Refer to [types of routes](#types-of-routes).
|
|
210
|
+
|
|
211
|
+
- `tsconfig` string optional
|
|
212
|
+
|
|
213
|
+
- Path to a custom `tsconfig`.
|
|
214
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
215
|
+
|
|
216
|
+
- `triggers` object optional
|
|
217
|
+
|
|
218
|
+
- Cron definitions to trigger a Worker's `scheduled` function. Refer to [triggers](#triggers).
|
|
219
|
+
|
|
220
|
+
- `rules` Rule optional
|
|
221
|
+
|
|
222
|
+
- An ordered list of rules that define which modules to import, and what type to import them as. You will need to specify rules to use `Text`, `Data` and `CompiledWasm` modules, or when you wish to have a `.js` file be treated as an `ESModule` instead of `CommonJS`.
|
|
223
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
224
|
+
|
|
225
|
+
- `build` Build optional
|
|
226
|
+
|
|
227
|
+
- Configures a custom build step to be run by Wrangler when building your Worker. Refer to [Custom builds](#custom-builds).
|
|
228
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
229
|
+
|
|
230
|
+
- `no_bundle` boolean optional
|
|
231
|
+
|
|
232
|
+
- Skip internal build steps and directly deploy your Worker script. You must have a plain JavaScript Worker with no dependencies.
|
|
233
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
234
|
+
|
|
235
|
+
- `find_additional_modules` boolean optional
|
|
236
|
+
|
|
237
|
+
- If true then Wrangler will traverse the file tree below `base_dir`. Any files that match `rules` will be included in the deployed Worker. Defaults to true if `no_bundle` is true, otherwise false. Can only be used with Module format Workers (not Service Worker format).
|
|
238
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
239
|
+
|
|
240
|
+
- `base_dir` string optional
|
|
241
|
+
|
|
242
|
+
- The directory in which module "rules" should be evaluated when including additional files (via `find_additional_modules`) into a Worker deployment. Defaults to the directory containing the `main` entry point of the Worker if not specified.
|
|
243
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
244
|
+
|
|
245
|
+
- `preserve_file_names` boolean optional
|
|
246
|
+
|
|
247
|
+
- Determines whether Wrangler will preserve the file names of additional modules bundled with the Worker. The default is to prepend filenames with a content hash. For example, `34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico`.
|
|
248
|
+
- Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
249
|
+
|
|
250
|
+
- `minify` boolean optional
|
|
251
|
+
|
|
252
|
+
- Minify the Worker script before uploading.
|
|
253
|
+
- If you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), `minify` is replaced by Vite's [`build.minify`](https://vite.dev/config/build-options.html#build-minify).
|
|
254
|
+
|
|
255
|
+
- `keep_names` boolean optional
|
|
256
|
+
|
|
257
|
+
- Wrangler uses esbuild to process the Worker code for development and deployment. This option allows you to specify whether esbuild should apply its [keepNames](https://esbuild.github.io/api/#keep-names) logic to the code or not. Defaults to `true`.
|
|
258
|
+
|
|
259
|
+
- `logpush` boolean optional
|
|
260
|
+
|
|
261
|
+
- Enables Workers Trace Events Logpush for a Worker. Any scripts with this property will automatically get picked up by the Workers Logpush job configured for your account. Defaults to `false`. Refer to [Workers Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/).
|
|
262
|
+
|
|
263
|
+
- `limits` Limits optional
|
|
264
|
+
|
|
265
|
+
- Configures limits to be imposed on execution at runtime. Refer to [Limits](#limits).
|
|
266
|
+
|
|
267
|
+
* `observability` object optional
|
|
268
|
+
|
|
269
|
+
- Configures automatic observability settings for telemetry data emitted from your Worker. Refer to [Observability](#observability).
|
|
270
|
+
|
|
271
|
+
* `assets` Assets optional
|
|
272
|
+
|
|
273
|
+
- Configures static assets that will be served. Refer to [Assets](https://developers.cloudflare.com/workers/static-assets/binding/) for more details.
|
|
274
|
+
|
|
275
|
+
* `migrations` object optional
|
|
276
|
+
|
|
277
|
+
- Maps a Durable Object from a class name to a runtime state. This communicates changes to the Durable Object (creation / deletion / rename / transfer) to the Workers runtime and provides the runtime with instructions on how to deal with those changes. Refer to [Durable Objects migrations](https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/#durable-object-migrations-in-wranglertoml).
|
|
278
|
+
|
|
279
|
+
## Non-inheritable keys
|
|
280
|
+
|
|
281
|
+
Non-inheritable keys are configurable at the top-level, but cannot be inherited by environments and must be specified for each environment.
|
|
282
|
+
|
|
283
|
+
- `define` Record\<string, string> optional
|
|
284
|
+
|
|
285
|
+
- A map of values to substitute when deploying your Worker.
|
|
286
|
+
- If you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), `define` is replaced by Vite's [`define`](https://vite.dev/config/shared-options.html#define).
|
|
287
|
+
|
|
288
|
+
- `vars` object optional
|
|
289
|
+
|
|
290
|
+
- A map of environment variables to set when deploying your Worker. Refer to [Environment variables](https://developers.cloudflare.com/workers/configuration/environment-variables/).
|
|
291
|
+
|
|
292
|
+
- `durable_objects` object optional
|
|
293
|
+
|
|
294
|
+
- A list of Durable Objects that your Worker should be bound to. Refer to [Durable Objects](#durable-objects).
|
|
295
|
+
|
|
296
|
+
- `kv_namespaces` object optional
|
|
297
|
+
|
|
298
|
+
- A list of KV namespaces that your Worker should be bound to. Refer to [KV namespaces](#kv-namespaces).
|
|
299
|
+
|
|
300
|
+
- `r2_buckets` object optional
|
|
301
|
+
|
|
302
|
+
- A list of R2 buckets that your Worker should be bound to. Refer to [R2 buckets](#r2-buckets).
|
|
303
|
+
|
|
304
|
+
- `vectorize` object optional
|
|
305
|
+
|
|
306
|
+
- A list of Vectorize indexes that your Worker should be bound to. Refer to [Vectorize indexes](#vectorize-indexes).
|
|
307
|
+
|
|
308
|
+
- `services` object optional
|
|
309
|
+
|
|
310
|
+
- A list of service bindings that your Worker should be bound to. Refer to [service bindings](#service-bindings).
|
|
311
|
+
|
|
312
|
+
- `tail_consumers` object optional
|
|
313
|
+
|
|
314
|
+
- A list of the Tail Workers your Worker sends data to. Refer to [Tail Workers](https://developers.cloudflare.com/workers/observability/logs/tail-workers/).
|
|
315
|
+
|
|
316
|
+
## Types of routes
|
|
317
|
+
|
|
318
|
+
There are three types of [routes](https://developers.cloudflare.com/workers/configuration/routing/): [Custom Domains](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/), [routes](https://developers.cloudflare.com/workers/configuration/routing/routes/), and [`workers.dev`](https://developers.cloudflare.com/workers/configuration/routing/workers-dev/).
|
|
319
|
+
|
|
320
|
+
### Custom Domains
|
|
321
|
+
|
|
322
|
+
[Custom Domains](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/) allow you to connect your Worker to a domain or subdomain, without having to make changes to your DNS settings or perform any certificate management.
|
|
323
|
+
|
|
324
|
+
- `pattern` string required
|
|
325
|
+
|
|
326
|
+
- The pattern that your Worker should be run on, for example, `"example.com"`.
|
|
327
|
+
|
|
328
|
+
- `custom_domain` boolean optional
|
|
329
|
+
|
|
330
|
+
- Whether the Worker should be on a Custom Domain as opposed to a route. Defaults to `false`.
|
|
331
|
+
|
|
332
|
+
Example:
|
|
333
|
+
|
|
334
|
+
- wrangler.jsonc
|
|
335
|
+
|
|
336
|
+
```jsonc
|
|
337
|
+
{
|
|
338
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
339
|
+
"routes": [
|
|
340
|
+
{
|
|
341
|
+
"pattern": "shop.example.com",
|
|
342
|
+
"custom_domain": true
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
- wrangler.toml
|
|
349
|
+
|
|
350
|
+
```toml
|
|
351
|
+
[[routes]]
|
|
352
|
+
pattern = "shop.example.com"
|
|
353
|
+
custom_domain = true
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Routes
|
|
357
|
+
|
|
358
|
+
[Routes](https://developers.cloudflare.com/workers/configuration/routing/routes/) allow users to map a URL pattern to a Worker. A route can be configured as a zone ID route, a zone name route, or a simple route.
|
|
359
|
+
|
|
360
|
+
#### Zone ID route
|
|
361
|
+
|
|
362
|
+
- `pattern` string required
|
|
363
|
+
|
|
364
|
+
- The pattern that your Worker can be run on, for example,`"example.com/*"`.
|
|
365
|
+
|
|
366
|
+
- `zone_id` string required
|
|
367
|
+
|
|
368
|
+
- The ID of the zone that your `pattern` is associated with. Refer to [Find zone and account IDs](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/).
|
|
369
|
+
|
|
370
|
+
Example:
|
|
371
|
+
|
|
372
|
+
- wrangler.jsonc
|
|
373
|
+
|
|
374
|
+
```jsonc
|
|
375
|
+
{
|
|
376
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
377
|
+
"routes": [
|
|
378
|
+
{
|
|
379
|
+
"pattern": "subdomain.example.com/*",
|
|
380
|
+
"zone_id": "<YOUR_ZONE_ID>"
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
- wrangler.toml
|
|
387
|
+
|
|
388
|
+
```toml
|
|
389
|
+
[[routes]]
|
|
390
|
+
pattern = "subdomain.example.com/*"
|
|
391
|
+
zone_id = "<YOUR_ZONE_ID>"
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### Zone name route
|
|
395
|
+
|
|
396
|
+
- `pattern` string required
|
|
397
|
+
|
|
398
|
+
- The pattern that your Worker should be run on, for example, `"example.com/*"`.
|
|
399
|
+
|
|
400
|
+
- `zone_name` string required
|
|
401
|
+
|
|
402
|
+
- The name of the zone that your `pattern` is associated with. If you are using API tokens, this will require the `Account` scope.
|
|
403
|
+
|
|
404
|
+
Example:
|
|
405
|
+
|
|
406
|
+
- wrangler.jsonc
|
|
407
|
+
|
|
408
|
+
```jsonc
|
|
409
|
+
{
|
|
410
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
411
|
+
"routes": [
|
|
412
|
+
{
|
|
413
|
+
"pattern": "subdomain.example.com/*",
|
|
414
|
+
"zone_name": "example.com"
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
- wrangler.toml
|
|
421
|
+
|
|
422
|
+
```toml
|
|
423
|
+
[[routes]]
|
|
424
|
+
pattern = "subdomain.example.com/*"
|
|
425
|
+
zone_name = "example.com"
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
#### Simple route
|
|
429
|
+
|
|
430
|
+
This is a simple route that only requires a pattern.
|
|
431
|
+
|
|
432
|
+
Example:
|
|
433
|
+
|
|
434
|
+
- wrangler.jsonc
|
|
435
|
+
|
|
436
|
+
```jsonc
|
|
437
|
+
{
|
|
438
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
439
|
+
"route": "example.com/*"
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
- wrangler.toml
|
|
444
|
+
|
|
445
|
+
```toml
|
|
446
|
+
route = "example.com/*"
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### `workers.dev`
|
|
450
|
+
|
|
451
|
+
Cloudflare Workers accounts come with a `workers.dev` subdomain that is configurable in the Cloudflare dashboard.
|
|
452
|
+
|
|
453
|
+
- `workers_dev` boolean optional
|
|
454
|
+
- Whether the Worker runs on a custom `workers.dev` account subdomain. Defaults to `true`.
|
|
455
|
+
|
|
456
|
+
* wrangler.jsonc
|
|
457
|
+
|
|
458
|
+
```jsonc
|
|
459
|
+
{
|
|
460
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
461
|
+
"workers_dev": false
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
* wrangler.toml
|
|
466
|
+
|
|
467
|
+
```toml
|
|
468
|
+
workers_dev = false
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Triggers
|
|
472
|
+
|
|
473
|
+
Triggers allow you to define the `cron` expression to invoke your Worker's `scheduled` function. Refer to [Supported cron expressions](https://developers.cloudflare.com/workers/configuration/cron-triggers/#supported-cron-expressions).
|
|
474
|
+
|
|
475
|
+
- `crons` string\[] required
|
|
476
|
+
|
|
477
|
+
- An array of `cron` expressions.
|
|
478
|
+
- To disable a Cron Trigger, set `crons = []`. Commenting out the `crons` key will not disable a Cron Trigger.
|
|
479
|
+
|
|
480
|
+
Example:
|
|
481
|
+
|
|
482
|
+
- wrangler.jsonc
|
|
483
|
+
|
|
484
|
+
```jsonc
|
|
485
|
+
{
|
|
486
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
487
|
+
"triggers": {
|
|
488
|
+
"crons": ["* * * * *"]
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
- wrangler.toml
|
|
494
|
+
|
|
495
|
+
```toml
|
|
496
|
+
[triggers]
|
|
497
|
+
crons = ["* * * * *"]
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
## Observability
|
|
501
|
+
|
|
502
|
+
The [Observability](https://developers.cloudflare.com/workers/observability/logs/workers-logs) setting allows you to automatically ingest, store, filter, and analyze logging data emitted from Cloudflare Workers directly from your Cloudflare Worker's dashboard.
|
|
503
|
+
|
|
504
|
+
- `enabled` boolean required
|
|
505
|
+
|
|
506
|
+
- When set to `true` on a Worker, logs for the Worker are persisted. Defaults to `true` for all new Workers.
|
|
507
|
+
|
|
508
|
+
- `head_sampling_rate` number optional
|
|
509
|
+
|
|
510
|
+
- A number between 0 and 1, where 0 indicates zero out of one hundred requests are logged, and 1 indicates every request is logged. If `head_sampling_rate` is unspecified, it is configured to a default value of 1 (100%). Read more about [head-based sampling](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#head-based-sampling).
|
|
511
|
+
|
|
512
|
+
Example:
|
|
513
|
+
|
|
514
|
+
- wrangler.jsonc
|
|
515
|
+
|
|
516
|
+
```jsonc
|
|
517
|
+
{
|
|
518
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
519
|
+
"observability": {
|
|
520
|
+
"enabled": true,
|
|
521
|
+
"head_sampling_rate": 0.1
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
- wrangler.toml
|
|
527
|
+
|
|
528
|
+
```toml
|
|
529
|
+
[observability]
|
|
530
|
+
enabled = true
|
|
531
|
+
head_sampling_rate = 0.1 # 10% of requests are logged
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## Custom builds
|
|
535
|
+
|
|
536
|
+
Note
|
|
537
|
+
|
|
538
|
+
Not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
539
|
+
|
|
540
|
+
You can configure a custom build step that will be run before your Worker is deployed. Refer to [Custom builds](https://developers.cloudflare.com/workers/wrangler/custom-builds/).
|
|
541
|
+
|
|
542
|
+
- `command` string optional
|
|
543
|
+
|
|
544
|
+
- The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used.
|
|
545
|
+
|
|
546
|
+
- `cwd` string optional
|
|
547
|
+
|
|
548
|
+
- The directory in which the command is executed.
|
|
549
|
+
|
|
550
|
+
- `watch_dir` string | string\[] optional
|
|
551
|
+
|
|
552
|
+
- The directory to watch for changes while using `wrangler dev`. Defaults to the current working directory.
|
|
553
|
+
|
|
554
|
+
Example:
|
|
555
|
+
|
|
556
|
+
- wrangler.jsonc
|
|
557
|
+
|
|
558
|
+
```jsonc
|
|
559
|
+
{
|
|
560
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
561
|
+
"build": {
|
|
562
|
+
"command": "npm run build",
|
|
563
|
+
"cwd": "build_cwd",
|
|
564
|
+
"watch_dir": "build_watch_dir"
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
- wrangler.toml
|
|
570
|
+
|
|
571
|
+
```toml
|
|
572
|
+
[build]
|
|
573
|
+
command = "npm run build"
|
|
574
|
+
cwd = "build_cwd"
|
|
575
|
+
watch_dir = "build_watch_dir"
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
## Limits
|
|
579
|
+
|
|
580
|
+
You can impose limits on your Worker's behavior at runtime. Limits are only supported for the [Standard Usage Model](https://developers.cloudflare.com/workers/platform/pricing/#example-pricing-standard-usage-model). Limits are only enforced when deployed to Cloudflare's network, not in local development. The CPU limit can be set to a maximum of 300,000 milliseconds (5 minutes).
|
|
581
|
+
|
|
582
|
+
Each [isolate](https://developers.cloudflare.com/workers/reference/how-workers-works/#isolates) has some built-in flexibility to allow for cases where your Worker infrequently runs over the configured limit. If your Worker starts hitting the limit consistently, its execution will be terminated according to the limit configured.
|
|
583
|
+
|
|
584
|
+
- `cpu_ms` number optional
|
|
585
|
+
- The maximum CPU time allowed per invocation, in milliseconds.
|
|
586
|
+
|
|
587
|
+
Example:
|
|
588
|
+
|
|
589
|
+
- wrangler.jsonc
|
|
590
|
+
|
|
591
|
+
```jsonc
|
|
592
|
+
{
|
|
593
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
594
|
+
"limits": {
|
|
595
|
+
"cpu_ms": 100
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
- wrangler.toml
|
|
601
|
+
|
|
602
|
+
```toml
|
|
603
|
+
[limits]
|
|
604
|
+
cpu_ms = 100
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
## Bindings
|
|
608
|
+
|
|
609
|
+
### Browser Rendering
|
|
610
|
+
|
|
611
|
+
The [Workers Browser Rendering API](https://developers.cloudflare.com/browser-rendering/) allows developers to programmatically control and interact with a headless browser instance and create automation flows for their applications and products.
|
|
612
|
+
|
|
613
|
+
A [browser binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/) will provide your Worker with an authenticated endpoint to interact with a dedicated Chromium browser instance.
|
|
614
|
+
|
|
615
|
+
- `binding` string required
|
|
616
|
+
- The binding name used to refer to the browser binding. The value (string) you set will be used to reference this headless browser in your Worker. The binding must be [a valid JavaScript variable name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#variables). For example, `binding = "HEAD_LESS"` or `binding = "simulatedBrowser"` would both be valid names for the binding.
|
|
617
|
+
|
|
618
|
+
Example:
|
|
619
|
+
|
|
620
|
+
- wrangler.jsonc
|
|
621
|
+
|
|
622
|
+
```jsonc
|
|
623
|
+
{
|
|
624
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
625
|
+
"browser": {
|
|
626
|
+
"binding": "<BINDING_NAME>"
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
- wrangler.toml
|
|
632
|
+
|
|
633
|
+
```toml
|
|
634
|
+
[browser]
|
|
635
|
+
binding = "<BINDING_NAME>"
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### D1 databases
|
|
639
|
+
|
|
640
|
+
[D1](https://developers.cloudflare.com/d1/) is Cloudflare's serverless SQL database. A Worker can query a D1 database (or databases) by creating a [binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/) to each database for [D1 Workers Binding API](https://developers.cloudflare.com/d1/worker-api/).
|
|
641
|
+
|
|
642
|
+
To bind D1 databases to your Worker, assign an array of the below object to the `[[d1_databases]]` key.
|
|
643
|
+
|
|
644
|
+
- `binding` string required
|
|
645
|
+
|
|
646
|
+
- The binding name used to refer to the D1 database. The value (string) you set will be used to reference this database in your Worker. The binding must be [a valid JavaScript variable name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#variables). For example, `binding = "MY_DB"` or `binding = "productionDB"` would both be valid names for the binding.
|
|
647
|
+
|
|
648
|
+
- `database_name` string required
|
|
649
|
+
|
|
650
|
+
- The name of the database. This is a human-readable name that allows you to distinguish between different databases, and is set when you first create the database.
|
|
651
|
+
|
|
652
|
+
- `database_id` string required
|
|
653
|
+
|
|
654
|
+
- The ID of the database. The database ID is available when you first use `wrangler d1 create` or when you call `wrangler d1 list`, and uniquely identifies your database.
|
|
655
|
+
|
|
656
|
+
- `preview_database_id` string optional
|
|
657
|
+
|
|
658
|
+
- The preview ID of this D1 database. If provided, `wrangler dev` uses this ID. Otherwise, it uses `database_id`. This option is required when using `wrangler dev --remote`.
|
|
659
|
+
|
|
660
|
+
- `migrations_dir` string optional
|
|
661
|
+
|
|
662
|
+
- The migration directory containing the migration files. By default, `wrangler d1 migrations create` creates a folder named `migrations`. You can use `migrations_dir` to specify a different folder containing the migration files (for example, if you have a mono-repo setup, and want to use a single D1 instance across your apps/packages).
|
|
663
|
+
- For more information, refer to [D1 Wrangler `migrations` commands](https://developers.cloudflare.com/workers/wrangler/commands/#migrations-create) and [D1 migrations](https://developers.cloudflare.com/d1/reference/migrations/).
|
|
664
|
+
|
|
665
|
+
Note
|
|
666
|
+
|
|
667
|
+
When using Wrangler in the default local development mode, files will be written to local storage instead of the preview or production database. Refer to [Local development and testing](https://developers.cloudflare.com/workers/development-testing/) for more details.
|
|
668
|
+
|
|
669
|
+
Example:
|
|
670
|
+
|
|
671
|
+
- wrangler.jsonc
|
|
672
|
+
|
|
673
|
+
```jsonc
|
|
674
|
+
{
|
|
675
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
676
|
+
"d1_databases": [
|
|
677
|
+
{
|
|
678
|
+
"binding": "<BINDING_NAME>",
|
|
679
|
+
"database_name": "<DATABASE_NAME>",
|
|
680
|
+
"database_id": "<DATABASE_ID>"
|
|
681
|
+
}
|
|
682
|
+
]
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
- wrangler.toml
|
|
687
|
+
|
|
688
|
+
```toml
|
|
689
|
+
[[d1_databases]]
|
|
690
|
+
binding = "<BINDING_NAME>"
|
|
691
|
+
database_name = "<DATABASE_NAME>"
|
|
692
|
+
database_id = "<DATABASE_ID>"
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### Dispatch namespace bindings (Workers for Platforms)
|
|
696
|
+
|
|
697
|
+
Dispatch namespace bindings allow for communication between a [dynamic dispatch Worker](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#dynamic-dispatch-worker) and a [dispatch namespace](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#dispatch-namespace). Dispatch namespace bindings are used in [Workers for Platforms](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/). Workers for Platforms helps you deploy serverless functions programmatically on behalf of your customers.
|
|
698
|
+
|
|
699
|
+
- `binding` string required
|
|
700
|
+
|
|
701
|
+
- The binding name. The value (string) you set will be used to reference this database in your Worker. The binding must be [a valid JavaScript variable name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#variables). For example, `binding = "MY_NAMESPACE"` or `binding = "productionNamespace"` would both be valid names for the binding.
|
|
702
|
+
|
|
703
|
+
- `namespace` string required
|
|
704
|
+
|
|
705
|
+
- The name of the [dispatch namespace](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#dispatch-namespace).
|
|
706
|
+
|
|
707
|
+
- `outbound` object optional
|
|
708
|
+
|
|
709
|
+
- `service` string required The name of the [outbound Worker](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/configuration/outbound-workers/) to bind to.
|
|
710
|
+
- `parameters` array optional A list of parameters to pass data from your [dynamic dispatch Worker](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#dynamic-dispatch-worker) to the [outbound Worker](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/configuration/outbound-workers/).
|
|
711
|
+
|
|
712
|
+
* wrangler.jsonc
|
|
713
|
+
|
|
714
|
+
```jsonc
|
|
715
|
+
{
|
|
716
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
717
|
+
"dispatch_namespaces": [
|
|
718
|
+
{
|
|
719
|
+
"binding": "<BINDING_NAME>",
|
|
720
|
+
"namespace": "<NAMESPACE_NAME>",
|
|
721
|
+
"outbound": {
|
|
722
|
+
"service": "<WORKER_NAME>",
|
|
723
|
+
"parameters": ["params_object"]
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
]
|
|
727
|
+
}
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
* wrangler.toml
|
|
731
|
+
|
|
732
|
+
```toml
|
|
733
|
+
[[dispatch_namespaces]]
|
|
734
|
+
binding = "<BINDING_NAME>"
|
|
735
|
+
namespace = "<NAMESPACE_NAME>"
|
|
736
|
+
outbound = {service = "<WORKER_NAME>", parameters = ["params_object"]}
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
### Durable Objects
|
|
740
|
+
|
|
741
|
+
[Durable Objects](https://developers.cloudflare.com/durable-objects/) provide low-latency coordination and consistent storage for the Workers platform.
|
|
742
|
+
|
|
743
|
+
To bind Durable Objects to your Worker, assign an array of the below object to the `durable_objects.bindings` key.
|
|
744
|
+
|
|
745
|
+
- `name` string required
|
|
746
|
+
|
|
747
|
+
- The name of the binding used to refer to the Durable Object.
|
|
748
|
+
|
|
749
|
+
- `class_name` string required
|
|
750
|
+
|
|
751
|
+
- The exported class name of the Durable Object.
|
|
752
|
+
|
|
753
|
+
- `script_name` string optional
|
|
754
|
+
|
|
755
|
+
- The name of the Worker where the Durable Object is defined, if it is external to this Worker. This option can be used both in local and remote development. In local development, you must run the external Worker in a separate process (via `wrangler dev`). In remote development, the appropriate remote binding must be used.
|
|
756
|
+
|
|
757
|
+
- `environment` string optional
|
|
758
|
+
|
|
759
|
+
- The environment of the `script_name` to bind to.
|
|
760
|
+
|
|
761
|
+
Example:
|
|
762
|
+
|
|
763
|
+
- wrangler.jsonc
|
|
764
|
+
|
|
765
|
+
```jsonc
|
|
766
|
+
{
|
|
767
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
768
|
+
"durable_objects": {
|
|
769
|
+
"bindings": [
|
|
770
|
+
{
|
|
771
|
+
"name": "<BINDING_NAME>",
|
|
772
|
+
"class_name": "<CLASS_NAME>"
|
|
773
|
+
}
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
- wrangler.toml
|
|
780
|
+
|
|
781
|
+
```toml
|
|
782
|
+
[[durable_objects.bindings]]
|
|
783
|
+
name = "<BINDING_NAME>"
|
|
784
|
+
class_name = "<CLASS_NAME>"
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
#### Migrations
|
|
788
|
+
|
|
789
|
+
When making changes to your Durable Object classes, you must perform a migration. Refer to [Durable Object migrations](https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/).
|
|
790
|
+
|
|
791
|
+
- `tag` string required
|
|
792
|
+
|
|
793
|
+
- A unique identifier for this migration.
|
|
794
|
+
|
|
795
|
+
- `new_sqlite_classes` string\[] optional
|
|
796
|
+
|
|
797
|
+
- The new Durable Objects being defined.
|
|
798
|
+
|
|
799
|
+
- `renamed_classes` {from: string, to: string}\[] optional
|
|
800
|
+
|
|
801
|
+
- The Durable Objects being renamed.
|
|
802
|
+
|
|
803
|
+
- `deleted_classes` string\[] optional
|
|
804
|
+
|
|
805
|
+
- The Durable Objects being removed.
|
|
806
|
+
|
|
807
|
+
Example:
|
|
808
|
+
|
|
809
|
+
- wrangler.jsonc
|
|
810
|
+
|
|
811
|
+
```jsonc
|
|
812
|
+
{
|
|
813
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
814
|
+
"migrations": [
|
|
815
|
+
{
|
|
816
|
+
"tag": "v1",
|
|
817
|
+
"new_sqlite_classes": ["DurableObjectExample"]
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
"tag": "v2",
|
|
821
|
+
"renamed_classes": [
|
|
822
|
+
{
|
|
823
|
+
"from": "DurableObjectExample",
|
|
824
|
+
"to": "UpdatedName"
|
|
825
|
+
}
|
|
826
|
+
],
|
|
827
|
+
"deleted_classes": ["DeprecatedClass"]
|
|
828
|
+
}
|
|
829
|
+
]
|
|
830
|
+
}
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
- wrangler.toml
|
|
834
|
+
|
|
835
|
+
```toml
|
|
836
|
+
[[migrations]]
|
|
837
|
+
tag = "v1" # Should be unique for each entry
|
|
838
|
+
new_sqlite_classes = ["DurableObjectExample"] # Array of new classes
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
[[migrations]]
|
|
842
|
+
tag = "v2"
|
|
843
|
+
renamed_classes = [{from = "DurableObjectExample", to = "UpdatedName" }] # Array of rename directives
|
|
844
|
+
deleted_classes = ["DeprecatedClass"] # Array of deleted class names
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### Email bindings
|
|
848
|
+
|
|
849
|
+
You can send an email about your Worker's activity from your Worker to an email address verified on [Email Routing](https://developers.cloudflare.com/email-routing/setup/email-routing-addresses/#destination-addresses). This is useful for when you want to know about certain types of events being triggered, for example.
|
|
850
|
+
|
|
851
|
+
Before you can bind an email address to your Worker, you need to [enable Email Routing](https://developers.cloudflare.com/email-routing/get-started/) and have at least one [verified email address](https://developers.cloudflare.com/email-routing/setup/email-routing-addresses/#destination-addresses). Then, assign an array to the object (send_email) with the type of email binding you need.
|
|
852
|
+
|
|
853
|
+
- `name` string required
|
|
854
|
+
|
|
855
|
+
- The binding name.
|
|
856
|
+
|
|
857
|
+
- `destination_address` string optional
|
|
858
|
+
|
|
859
|
+
- The [chosen email address](https://developers.cloudflare.com/email-routing/email-workers/send-email-workers/#types-of-bindings) you send emails to.
|
|
860
|
+
|
|
861
|
+
- `allowed_destination_addresses` string\[] optional
|
|
862
|
+
|
|
863
|
+
- The [allowlist of email addresses](https://developers.cloudflare.com/email-routing/email-workers/send-email-workers/#types-of-bindings) you send emails to.
|
|
864
|
+
|
|
865
|
+
You can add one or more types of bindings to your Wrangler file. However, each attribute must be on its own line:
|
|
866
|
+
|
|
867
|
+
- wrangler.jsonc
|
|
868
|
+
|
|
869
|
+
```jsonc
|
|
870
|
+
{
|
|
871
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
872
|
+
"send_email": [
|
|
873
|
+
{
|
|
874
|
+
"name": "<NAME_FOR_BINDING1>"
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
"name": "<NAME_FOR_BINDING2>",
|
|
878
|
+
"destination_address": "<YOUR_EMAIL>@example.com"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
"name": "<NAME_FOR_BINDING3>",
|
|
882
|
+
"allowed_destination_addresses": [
|
|
883
|
+
"<YOUR_EMAIL>@example.com",
|
|
884
|
+
"<YOUR_EMAIL2>@example.com"
|
|
885
|
+
]
|
|
886
|
+
}
|
|
887
|
+
]
|
|
888
|
+
}
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
- wrangler.toml
|
|
892
|
+
|
|
893
|
+
```toml
|
|
894
|
+
send_email = [
|
|
895
|
+
{name = "<NAME_FOR_BINDING1>"},
|
|
896
|
+
{name = "<NAME_FOR_BINDING2>", destination_address = "<YOUR_EMAIL>@example.com"},
|
|
897
|
+
{name = "<NAME_FOR_BINDING3>", allowed_destination_addresses = ["<YOUR_EMAIL>@example.com", "<YOUR_EMAIL2>@example.com"]},
|
|
898
|
+
]
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
### Environment variables
|
|
902
|
+
|
|
903
|
+
[Environment variables](https://developers.cloudflare.com/workers/configuration/environment-variables/) are a type of binding that allow you to attach text strings or JSON values to your Worker.
|
|
904
|
+
|
|
905
|
+
Example:
|
|
906
|
+
|
|
907
|
+
- wrangler.jsonc
|
|
908
|
+
|
|
909
|
+
```jsonc
|
|
910
|
+
{
|
|
911
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
912
|
+
"name": "my-worker-dev",
|
|
913
|
+
"vars": {
|
|
914
|
+
"API_HOST": "example.com",
|
|
915
|
+
"API_ACCOUNT_ID": "example_user",
|
|
916
|
+
"SERVICE_X_DATA": {
|
|
917
|
+
"URL": "service-x-api.dev.example",
|
|
918
|
+
"MY_ID": 123
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
- wrangler.toml
|
|
925
|
+
|
|
926
|
+
```toml
|
|
927
|
+
name = "my-worker-dev"
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
[vars]
|
|
931
|
+
API_HOST = "example.com"
|
|
932
|
+
API_ACCOUNT_ID = "example_user"
|
|
933
|
+
SERVICE_X_DATA = { URL = "service-x-api.dev.example", MY_ID = 123 }
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
### Hyperdrive
|
|
937
|
+
|
|
938
|
+
[Hyperdrive](https://developers.cloudflare.com/hyperdrive/) bindings allow you to interact with and query any Postgres database from within a Worker.
|
|
939
|
+
|
|
940
|
+
- `binding` string required
|
|
941
|
+
|
|
942
|
+
- The binding name.
|
|
943
|
+
|
|
944
|
+
- `id` string required
|
|
945
|
+
|
|
946
|
+
- The ID of the Hyperdrive configuration.
|
|
947
|
+
|
|
948
|
+
Example:
|
|
949
|
+
|
|
950
|
+
- wrangler.jsonc
|
|
951
|
+
|
|
952
|
+
```jsonc
|
|
953
|
+
{
|
|
954
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
955
|
+
"compatibility_flags": ["nodejs_compat_v2"],
|
|
956
|
+
"hyperdrive": [
|
|
957
|
+
{
|
|
958
|
+
"binding": "<BINDING_NAME>",
|
|
959
|
+
"id": "<ID>"
|
|
960
|
+
}
|
|
961
|
+
]
|
|
962
|
+
}
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
- wrangler.toml
|
|
966
|
+
|
|
967
|
+
```toml
|
|
968
|
+
# required for database drivers to function
|
|
969
|
+
compatibility_flags = ["nodejs_compat_v2"]
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
[[hyperdrive]]
|
|
973
|
+
binding = "<BINDING_NAME>"
|
|
974
|
+
id = "<ID>"
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
### Images
|
|
978
|
+
|
|
979
|
+
[Cloudflare Images](https://developers.cloudflare.com/images/transform-images/transform-via-workers/) lets you make transformation requests to optimize, resize, and manipulate images stored in remote sources.
|
|
980
|
+
|
|
981
|
+
To bind Images to your Worker, assign an array of the below object to the `images` key.
|
|
982
|
+
|
|
983
|
+
`binding` (required). The name of the binding used to refer to the Images API.
|
|
984
|
+
|
|
985
|
+
- wrangler.jsonc
|
|
986
|
+
|
|
987
|
+
```jsonc
|
|
988
|
+
{
|
|
989
|
+
"images": {
|
|
990
|
+
"binding": "IMAGES" // i.e. available in your Worker on env.IMAGES
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
- wrangler.toml
|
|
996
|
+
|
|
997
|
+
```toml
|
|
998
|
+
[images]
|
|
999
|
+
binding = "IMAGES"
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
### KV namespaces
|
|
1003
|
+
|
|
1004
|
+
[Workers KV](https://developers.cloudflare.com/kv/api/) is a global, low-latency, key-value data store. It stores data in a small number of centralized data centers, then caches that data in Cloudflare’s data centers after access.
|
|
1005
|
+
|
|
1006
|
+
To bind KV namespaces to your Worker, assign an array of the below object to the `kv_namespaces` key.
|
|
1007
|
+
|
|
1008
|
+
- `binding` string required
|
|
1009
|
+
|
|
1010
|
+
- The binding name used to refer to the KV namespace.
|
|
1011
|
+
|
|
1012
|
+
- `id` string required
|
|
1013
|
+
|
|
1014
|
+
- The ID of the KV namespace.
|
|
1015
|
+
|
|
1016
|
+
- `preview_id` string optional
|
|
1017
|
+
|
|
1018
|
+
- The preview ID of this KV namespace. This option is **required** when using `wrangler dev --remote` to develop against remote resources (but is not required with [remote bindings](https://developers.cloudflare.com/workers/development-testing/#remote-bindings)). If developing locally, this is an optional field. `wrangler dev` will use this ID for the KV namespace. Otherwise, `wrangler dev` will use `id`.
|
|
1019
|
+
|
|
1020
|
+
Note
|
|
1021
|
+
|
|
1022
|
+
When using Wrangler in the default local development mode, files will be written to local storage instead of the preview or production namespace. Refer to [Local development and testing](https://developers.cloudflare.com/workers/development-testing/) for more details.
|
|
1023
|
+
|
|
1024
|
+
Example:
|
|
1025
|
+
|
|
1026
|
+
- wrangler.jsonc
|
|
1027
|
+
|
|
1028
|
+
```jsonc
|
|
1029
|
+
{
|
|
1030
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1031
|
+
"kv_namespaces": [
|
|
1032
|
+
{
|
|
1033
|
+
"binding": "<BINDING_NAME1>",
|
|
1034
|
+
"id": "<NAMESPACE_ID1>"
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
"binding": "<BINDING_NAME2>",
|
|
1038
|
+
"id": "<NAMESPACE_ID2>"
|
|
1039
|
+
}
|
|
1040
|
+
]
|
|
1041
|
+
}
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
- wrangler.toml
|
|
1045
|
+
|
|
1046
|
+
```toml
|
|
1047
|
+
[[kv_namespaces]]
|
|
1048
|
+
binding = "<BINDING_NAME1>"
|
|
1049
|
+
id = "<NAMESPACE_ID1>"
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
[[kv_namespaces]]
|
|
1053
|
+
binding = "<BINDING_NAME2>"
|
|
1054
|
+
id = "<NAMESPACE_ID2>"
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
### Queues
|
|
1058
|
+
|
|
1059
|
+
[Queues](https://developers.cloudflare.com/queues/) is Cloudflare's global message queueing service, providing [guaranteed delivery](https://developers.cloudflare.com/queues/reference/delivery-guarantees/) and [message batching](https://developers.cloudflare.com/queues/configuration/batching-retries/). To interact with a queue with Workers, you need a producer Worker to send messages to the queue and a consumer Worker to pull batches of messages out of the Queue. A single Worker can produce to and consume from multiple Queues.
|
|
1060
|
+
|
|
1061
|
+
To bind Queues to your producer Worker, assign an array of the below object to the `[[queues.producers]]` key.
|
|
1062
|
+
|
|
1063
|
+
- `queue` string required
|
|
1064
|
+
|
|
1065
|
+
- The name of the queue, used on the Cloudflare dashboard.
|
|
1066
|
+
|
|
1067
|
+
- `binding` string required
|
|
1068
|
+
|
|
1069
|
+
- The binding name used to refer to the queue in your Worker. The binding must be [a valid JavaScript variable name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#variables). For example, `binding = "MY_QUEUE"` or `binding = "productionQueue"` would both be valid names for the binding.
|
|
1070
|
+
|
|
1071
|
+
- `delivery_delay` number optional
|
|
1072
|
+
|
|
1073
|
+
- The number of seconds to [delay messages sent to a queue](https://developers.cloudflare.com/queues/configuration/batching-retries/#delay-messages) for by default. This can be overridden on a per-message or per-batch basis.
|
|
1074
|
+
|
|
1075
|
+
Example:
|
|
1076
|
+
|
|
1077
|
+
- wrangler.jsonc
|
|
1078
|
+
|
|
1079
|
+
```jsonc
|
|
1080
|
+
{
|
|
1081
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1082
|
+
"queues": {
|
|
1083
|
+
"producers": [
|
|
1084
|
+
{
|
|
1085
|
+
"binding": "<BINDING_NAME>",
|
|
1086
|
+
"queue": "<QUEUE_NAME>",
|
|
1087
|
+
"delivery_delay": 60
|
|
1088
|
+
}
|
|
1089
|
+
]
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
- wrangler.toml
|
|
1095
|
+
|
|
1096
|
+
```toml
|
|
1097
|
+
[[queues.producers]]
|
|
1098
|
+
binding = "<BINDING_NAME>"
|
|
1099
|
+
queue = "<QUEUE_NAME>"
|
|
1100
|
+
delivery_delay = 60 # Delay messages by 60 seconds before they are delivered to a consumer
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
To bind Queues to your consumer Worker, assign an array of the below object to the `[[queues.consumers]]` key.
|
|
1104
|
+
|
|
1105
|
+
- `queue` string required
|
|
1106
|
+
|
|
1107
|
+
- The name of the queue, used on the Cloudflare dashboard.
|
|
1108
|
+
|
|
1109
|
+
- `max_batch_size` number optional
|
|
1110
|
+
|
|
1111
|
+
- The maximum number of messages allowed in each batch.
|
|
1112
|
+
|
|
1113
|
+
- `max_batch_timeout` number optional
|
|
1114
|
+
|
|
1115
|
+
- The maximum number of seconds to wait for messages to fill a batch before the batch is sent to the consumer Worker.
|
|
1116
|
+
|
|
1117
|
+
- `max_retries` number optional
|
|
1118
|
+
|
|
1119
|
+
- The maximum number of retries for a message, if it fails or [`retryAll()`](https://developers.cloudflare.com/queues/configuration/javascript-apis/#messagebatch) is invoked.
|
|
1120
|
+
|
|
1121
|
+
- `dead_letter_queue` string optional
|
|
1122
|
+
|
|
1123
|
+
- The name of another queue to send a message if it fails processing at least `max_retries` times.
|
|
1124
|
+
- If a `dead_letter_queue` is not defined, messages that repeatedly fail processing will be discarded.
|
|
1125
|
+
- If there is no queue with the specified name, it will be created automatically.
|
|
1126
|
+
|
|
1127
|
+
- `max_concurrency` number optional
|
|
1128
|
+
|
|
1129
|
+
- The maximum number of concurrent consumers allowed to run at once. Leaving this unset will mean that the number of invocations will scale to the [currently supported maximum](https://developers.cloudflare.com/queues/platform/limits/).
|
|
1130
|
+
- Refer to [Consumer concurrency](https://developers.cloudflare.com/queues/configuration/consumer-concurrency/) for more information on how consumers autoscale, particularly when messages are retried.
|
|
1131
|
+
|
|
1132
|
+
- `retry_delay` number optional
|
|
1133
|
+
|
|
1134
|
+
- The number of seconds to [delay retried messages](https://developers.cloudflare.com/queues/configuration/batching-retries/#delay-messages) for by default, before they are re-delivered to the consumer. This can be overridden on a per-message or per-batch basis [when retrying messages](https://developers.cloudflare.com/queues/configuration/batching-retries/#explicit-acknowledgement-and-retries).
|
|
1135
|
+
|
|
1136
|
+
Example:
|
|
1137
|
+
|
|
1138
|
+
- wrangler.jsonc
|
|
1139
|
+
|
|
1140
|
+
```jsonc
|
|
1141
|
+
{
|
|
1142
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1143
|
+
"queues": {
|
|
1144
|
+
"consumers": [
|
|
1145
|
+
{
|
|
1146
|
+
"queue": "my-queue",
|
|
1147
|
+
"max_batch_size": 10,
|
|
1148
|
+
"max_batch_timeout": 30,
|
|
1149
|
+
"max_retries": 10,
|
|
1150
|
+
"dead_letter_queue": "my-queue-dlq",
|
|
1151
|
+
"max_concurrency": 5,
|
|
1152
|
+
"retry_delay": 120
|
|
1153
|
+
}
|
|
1154
|
+
]
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
```
|
|
1158
|
+
|
|
1159
|
+
- wrangler.toml
|
|
1160
|
+
|
|
1161
|
+
```toml
|
|
1162
|
+
[[queues.consumers]]
|
|
1163
|
+
queue = "my-queue"
|
|
1164
|
+
max_batch_size = 10
|
|
1165
|
+
max_batch_timeout = 30
|
|
1166
|
+
max_retries = 10
|
|
1167
|
+
dead_letter_queue = "my-queue-dlq"
|
|
1168
|
+
max_concurrency = 5
|
|
1169
|
+
retry_delay = 120 # Delay retried messages by 2 minutes before re-attempting delivery
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
### R2 buckets
|
|
1173
|
+
|
|
1174
|
+
[Cloudflare R2 Storage](https://developers.cloudflare.com/r2) allows developers to store large amounts of unstructured data without the costly egress bandwidth fees associated with typical cloud storage services.
|
|
1175
|
+
|
|
1176
|
+
To bind R2 buckets to your Worker, assign an array of the below object to the `r2_buckets` key.
|
|
1177
|
+
|
|
1178
|
+
- `binding` string required
|
|
1179
|
+
|
|
1180
|
+
- The binding name used to refer to the R2 bucket.
|
|
1181
|
+
|
|
1182
|
+
- `bucket_name` string required
|
|
1183
|
+
|
|
1184
|
+
- The name of this R2 bucket.
|
|
1185
|
+
|
|
1186
|
+
- `jurisdiction` string optional
|
|
1187
|
+
|
|
1188
|
+
- The jurisdiction where this R2 bucket is located, if a jurisdiction has been specified. Refer to [Jurisdictional Restrictions](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions).
|
|
1189
|
+
|
|
1190
|
+
- `preview_bucket_name` string optional
|
|
1191
|
+
|
|
1192
|
+
- The preview name of this R2 bucket. If provided, `wrangler dev` will use this name for the R2 bucket. Otherwise, it will use `bucket_name`. This option is required when using `wrangler dev --remote` (but is not required with [remote bindings](https://developers.cloudflare.com/workers/development-testing/#remote-bindings)).
|
|
1193
|
+
|
|
1194
|
+
Note
|
|
1195
|
+
|
|
1196
|
+
When using Wrangler in the default local development mode, files will be written to local storage instead of the preview or production bucket. Refer to [Local development and testing](https://developers.cloudflare.com/workers/development-testing/) for more details.
|
|
1197
|
+
|
|
1198
|
+
Example:
|
|
1199
|
+
|
|
1200
|
+
- wrangler.jsonc
|
|
1201
|
+
|
|
1202
|
+
```jsonc
|
|
1203
|
+
{
|
|
1204
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1205
|
+
"r2_buckets": [
|
|
1206
|
+
{
|
|
1207
|
+
"binding": "<BINDING_NAME1>",
|
|
1208
|
+
"bucket_name": "<BUCKET_NAME1>"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
"binding": "<BINDING_NAME2>",
|
|
1212
|
+
"bucket_name": "<BUCKET_NAME2>"
|
|
1213
|
+
}
|
|
1214
|
+
]
|
|
1215
|
+
}
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
- wrangler.toml
|
|
1219
|
+
|
|
1220
|
+
```toml
|
|
1221
|
+
[[r2_buckets]]
|
|
1222
|
+
binding = "<BINDING_NAME1>"
|
|
1223
|
+
bucket_name = "<BUCKET_NAME1>"
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
[[r2_buckets]]
|
|
1227
|
+
binding = "<BINDING_NAME2>"
|
|
1228
|
+
bucket_name = "<BUCKET_NAME2>"
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
### Vectorize indexes
|
|
1232
|
+
|
|
1233
|
+
A [Vectorize index](https://developers.cloudflare.com/vectorize/) allows you to insert and query vector embeddings for semantic search, classification and other vector search use-cases.
|
|
1234
|
+
|
|
1235
|
+
To bind Vectorize indexes to your Worker, assign an array of the below object to the `vectorize` key.
|
|
1236
|
+
|
|
1237
|
+
- `binding` string required
|
|
1238
|
+
|
|
1239
|
+
- The binding name used to refer to the bound index from your Worker code.
|
|
1240
|
+
|
|
1241
|
+
- `index_name` string required
|
|
1242
|
+
|
|
1243
|
+
- The name of the index to bind.
|
|
1244
|
+
|
|
1245
|
+
Example:
|
|
1246
|
+
|
|
1247
|
+
- wrangler.jsonc
|
|
1248
|
+
|
|
1249
|
+
```jsonc
|
|
1250
|
+
{
|
|
1251
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1252
|
+
"vectorize": [
|
|
1253
|
+
{
|
|
1254
|
+
"binding": "<BINDING_NAME>",
|
|
1255
|
+
"index_name": "<INDEX_NAME>"
|
|
1256
|
+
}
|
|
1257
|
+
]
|
|
1258
|
+
}
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
- wrangler.toml
|
|
1262
|
+
|
|
1263
|
+
```toml
|
|
1264
|
+
[[vectorize]]
|
|
1265
|
+
binding = "<BINDING_NAME>"
|
|
1266
|
+
index_name = "<INDEX_NAME>"
|
|
1267
|
+
```
|
|
1268
|
+
|
|
1269
|
+
### Service bindings
|
|
1270
|
+
|
|
1271
|
+
A service binding allows you to send HTTP requests to another Worker without those requests going over the Internet. The request immediately invokes the downstream Worker, reducing latency as compared to a request to a third-party service. Refer to [About Service Bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
|
|
1272
|
+
|
|
1273
|
+
To bind other Workers to your Worker, assign an array of the below object to the `services` key.
|
|
1274
|
+
|
|
1275
|
+
- `binding` string required
|
|
1276
|
+
|
|
1277
|
+
- The binding name used to refer to the bound Worker.
|
|
1278
|
+
|
|
1279
|
+
- `service` string required
|
|
1280
|
+
|
|
1281
|
+
- The name of the Worker.
|
|
1282
|
+
- To bind to a Worker in a specific [environment](https://developers.cloudflare.com/workers/wrangler/environments), you need to append the environment name to the Worker name. This should be in the format `<worker-name>-<environment-name>`. For example, to bind to a Worker called `worker-name` in its `staging` environment, `service` should be set to `worker-name-staging`.
|
|
1283
|
+
|
|
1284
|
+
- `entrypoint` string optional
|
|
1285
|
+
|
|
1286
|
+
- The name of the [entrypoint](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/#named-entrypoints) to bind to. If you do not specify an entrypoint, the default export of the Worker will be used.
|
|
1287
|
+
|
|
1288
|
+
Example:
|
|
1289
|
+
|
|
1290
|
+
- wrangler.jsonc
|
|
1291
|
+
|
|
1292
|
+
```jsonc
|
|
1293
|
+
{
|
|
1294
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1295
|
+
"services": [
|
|
1296
|
+
{
|
|
1297
|
+
"binding": "<BINDING_NAME>",
|
|
1298
|
+
"service": "<WORKER_NAME>",
|
|
1299
|
+
"entrypoint": "<ENTRYPOINT_NAME>"
|
|
1300
|
+
}
|
|
1301
|
+
]
|
|
1302
|
+
}
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
- wrangler.toml
|
|
1306
|
+
|
|
1307
|
+
```toml
|
|
1308
|
+
[[services]]
|
|
1309
|
+
binding = "<BINDING_NAME>"
|
|
1310
|
+
service = "<WORKER_NAME>"
|
|
1311
|
+
entrypoint = "<ENTRYPOINT_NAME>"
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
### Static assets
|
|
1315
|
+
|
|
1316
|
+
Refer to [Assets](#assets).
|
|
1317
|
+
|
|
1318
|
+
### Analytics Engine Datasets
|
|
1319
|
+
|
|
1320
|
+
[Workers Analytics Engine](https://developers.cloudflare.com/analytics/analytics-engine/) provides analytics, observability and data logging from Workers. Write data points to your Worker binding then query the data using the [SQL API](https://developers.cloudflare.com/analytics/analytics-engine/sql-api/).
|
|
1321
|
+
|
|
1322
|
+
To bind Analytics Engine datasets to your Worker, assign an array of the below object to the `analytics_engine_datasets` key.
|
|
1323
|
+
|
|
1324
|
+
- `binding` string required
|
|
1325
|
+
|
|
1326
|
+
- The binding name used to refer to the dataset.
|
|
1327
|
+
|
|
1328
|
+
- `dataset` string optional
|
|
1329
|
+
|
|
1330
|
+
- The dataset name to write to. This will default to the same name as the binding if it is not supplied.
|
|
1331
|
+
|
|
1332
|
+
Example:
|
|
1333
|
+
|
|
1334
|
+
- wrangler.jsonc
|
|
1335
|
+
|
|
1336
|
+
```jsonc
|
|
1337
|
+
{
|
|
1338
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1339
|
+
"analytics_engine_datasets": [
|
|
1340
|
+
{
|
|
1341
|
+
"binding": "<BINDING_NAME>",
|
|
1342
|
+
"dataset": "<DATASET_NAME>"
|
|
1343
|
+
}
|
|
1344
|
+
]
|
|
1345
|
+
}
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
- wrangler.toml
|
|
1349
|
+
|
|
1350
|
+
```toml
|
|
1351
|
+
[[analytics_engine_datasets]]
|
|
1352
|
+
binding = "<BINDING_NAME>"
|
|
1353
|
+
dataset = "<DATASET_NAME>"
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
### mTLS Certificates
|
|
1357
|
+
|
|
1358
|
+
To communicate with origins that require client authentication, a Worker can present a certificate for mTLS in subrequests. Wrangler provides the `mtls-certificate` [command](https://developers.cloudflare.com/workers/wrangler/commands#mtls-certificate) to upload and manage these certificates.
|
|
1359
|
+
|
|
1360
|
+
To create a [binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/) to an mTLS certificate for your Worker, assign an array of objects with the following shape to the `mtls_certificates` key.
|
|
1361
|
+
|
|
1362
|
+
- `binding` string required
|
|
1363
|
+
|
|
1364
|
+
- The binding name used to refer to the certificate.
|
|
1365
|
+
|
|
1366
|
+
- `certificate_id` string required
|
|
1367
|
+
|
|
1368
|
+
- The ID of the certificate. Wrangler displays this via the `mtls-certificate upload` and `mtls-certificate list` commands.
|
|
1369
|
+
|
|
1370
|
+
Example of a Wrangler configuration file that includes an mTLS certificate binding:
|
|
1371
|
+
|
|
1372
|
+
- wrangler.jsonc
|
|
1373
|
+
|
|
1374
|
+
```jsonc
|
|
1375
|
+
{
|
|
1376
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1377
|
+
"mtls_certificates": [
|
|
1378
|
+
{
|
|
1379
|
+
"binding": "<BINDING_NAME1>",
|
|
1380
|
+
"certificate_id": "<CERTIFICATE_ID1>"
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
"binding": "<BINDING_NAME2>",
|
|
1384
|
+
"certificate_id": "<CERTIFICATE_ID2>"
|
|
1385
|
+
}
|
|
1386
|
+
]
|
|
1387
|
+
}
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
- wrangler.toml
|
|
1391
|
+
|
|
1392
|
+
```toml
|
|
1393
|
+
[[mtls_certificates]]
|
|
1394
|
+
binding = "<BINDING_NAME1>"
|
|
1395
|
+
certificate_id = "<CERTIFICATE_ID1>"
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
[[mtls_certificates]]
|
|
1399
|
+
binding = "<BINDING_NAME2>"
|
|
1400
|
+
certificate_id = "<CERTIFICATE_ID2>"
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
mTLS certificate bindings can then be used at runtime to communicate with secured origins via their [`fetch` method](https://developers.cloudflare.com/workers/runtime-apis/bindings/mtls).
|
|
1404
|
+
|
|
1405
|
+
### Workers AI
|
|
1406
|
+
|
|
1407
|
+
[Workers AI](https://developers.cloudflare.com/workers-ai/) allows you to run machine learning models, on the Cloudflare network, from your own code – whether that be from Workers, Pages, or anywhere via REST API.
|
|
1408
|
+
|
|
1409
|
+
Workers AI local development usage charges
|
|
1410
|
+
|
|
1411
|
+
Using Workers AI always accesses your Cloudflare account in order to run AI models and will incur usage charges even in local development.
|
|
1412
|
+
|
|
1413
|
+
Unlike other bindings, this binding is limited to one AI binding per Worker project.
|
|
1414
|
+
|
|
1415
|
+
- `binding` string required
|
|
1416
|
+
- The binding name.
|
|
1417
|
+
|
|
1418
|
+
Example:
|
|
1419
|
+
|
|
1420
|
+
- wrangler.jsonc
|
|
1421
|
+
|
|
1422
|
+
```jsonc
|
|
1423
|
+
{
|
|
1424
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1425
|
+
"ai": {
|
|
1426
|
+
"binding": "AI"
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
```
|
|
1430
|
+
|
|
1431
|
+
- wrangler.toml
|
|
1432
|
+
|
|
1433
|
+
```toml
|
|
1434
|
+
[ai]
|
|
1435
|
+
binding = "AI" # available in your Worker code on `env.AI`
|
|
1436
|
+
```
|
|
1437
|
+
|
|
1438
|
+
## Assets
|
|
1439
|
+
|
|
1440
|
+
[Static assets](https://developers.cloudflare.com/workers/static-assets/) allows developers to run front-end websites on Workers. You can configure the directory of assets, an optional runtime binding, and routing configuration options.
|
|
1441
|
+
|
|
1442
|
+
You can only configure one collection of assets per Worker.
|
|
1443
|
+
|
|
1444
|
+
The following options are available under the `assets` key.
|
|
1445
|
+
|
|
1446
|
+
- `directory` string optional
|
|
1447
|
+
|
|
1448
|
+
- Folder of static assets to be served.
|
|
1449
|
+
- Not required if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), which will automatically point to the client build output.
|
|
1450
|
+
|
|
1451
|
+
- `binding` string optional
|
|
1452
|
+
|
|
1453
|
+
- The binding name used to refer to the assets. Optional, and only useful when a Worker script is set with `main`.
|
|
1454
|
+
|
|
1455
|
+
- `run_worker_first` boolean | string\[] optional, defaults to false
|
|
1456
|
+
|
|
1457
|
+
- Controls whether static assets are fetched directly, or a Worker script is invoked. Can be a boolean (`true`/`false`) or an array of route pattern strings with support for glob patterns (`*`) and exception patterns (`!` prefix). Patterns must begin with `/` or `!/`. Learn more about fetching assets when using [`run_worker_first`](https://developers.cloudflare.com/workers/static-assets/routing/worker-script/#run-your-worker-script-first).
|
|
1458
|
+
|
|
1459
|
+
- `html_handling`: "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash" | "none" optional, defaults to "auto-trailing-slash"
|
|
1460
|
+
|
|
1461
|
+
- Determines the redirects and rewrites of requests for HTML content. Learn more about the various options in [assets routing](https://developers.cloudflare.com/workers/static-assets/routing/advanced/html-handling/).
|
|
1462
|
+
|
|
1463
|
+
- `not_found_handling`: "single-page-application" | "404-page" | "none" optional, defaults to "none"
|
|
1464
|
+
|
|
1465
|
+
- Determines the handling of requests that do not map to an asset. Learn more about the various options for [routing behavior](https://developers.cloudflare.com/workers/static-assets/#routing-behavior).
|
|
1466
|
+
|
|
1467
|
+
Example:
|
|
1468
|
+
|
|
1469
|
+
- wrangler.jsonc
|
|
1470
|
+
|
|
1471
|
+
```jsonc
|
|
1472
|
+
{
|
|
1473
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1474
|
+
"assets": {
|
|
1475
|
+
"directory": "./public",
|
|
1476
|
+
"binding": "ASSETS",
|
|
1477
|
+
"html_handling": "force-trailing-slash",
|
|
1478
|
+
"not_found_handling": "404-page"
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
```
|
|
1482
|
+
|
|
1483
|
+
- wrangler.toml
|
|
1484
|
+
|
|
1485
|
+
```toml
|
|
1486
|
+
assets = { directory = "./public", binding = "ASSETS", html_handling = "force-trailing-slash", not_found_handling = "404-page" }
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
You can also configure `run_worker_first` with an array of route patterns:
|
|
1490
|
+
|
|
1491
|
+
- wrangler.jsonc
|
|
1492
|
+
|
|
1493
|
+
```jsonc
|
|
1494
|
+
{
|
|
1495
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1496
|
+
"assets": {
|
|
1497
|
+
"directory": "./public",
|
|
1498
|
+
"binding": "ASSETS",
|
|
1499
|
+
"run_worker_first": ["/api/*", "!/api/docs/*"]
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
- wrangler.toml
|
|
1505
|
+
|
|
1506
|
+
```toml
|
|
1507
|
+
[assets]
|
|
1508
|
+
directory = "./public"
|
|
1509
|
+
binding = "ASSETS"
|
|
1510
|
+
run_worker_first = [
|
|
1511
|
+
"/api/*", # API calls go to Worker first
|
|
1512
|
+
"!/api/docs/*" # EXCEPTION: For /api/docs/*, try static assets first
|
|
1513
|
+
]
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
## Containers
|
|
1517
|
+
|
|
1518
|
+
You can define [Containers](https://developers.cloudflare.com/containers) to run alongside your Worker using the `containers` field.
|
|
1519
|
+
|
|
1520
|
+
Note
|
|
1521
|
+
|
|
1522
|
+
You must also define a Durable Object to communicate with your Container via Workers. This Durable Object's class name must match the `class_name` value in container configuration.
|
|
1523
|
+
|
|
1524
|
+
The following options are available:
|
|
1525
|
+
|
|
1526
|
+
- `image` string required
|
|
1527
|
+
|
|
1528
|
+
- The image to use for the container. This can either be a local path to a `Dockerfile`, in which case `wrangler deploy` will build and push the image, or it can be an image URL. Currently, only the Cloudflare Registry is a supported registry.
|
|
1529
|
+
|
|
1530
|
+
- `class_name` string required
|
|
1531
|
+
|
|
1532
|
+
- The corresponding Durable Object class name. This will make this Durable Object a container-enabled Durable Object and allow each instance to control a container. See [Durable Object Container Methods](https://developers.cloudflare.com/durable-objects/api/container/) for details.
|
|
1533
|
+
|
|
1534
|
+
- `instance_type` string optional
|
|
1535
|
+
|
|
1536
|
+
- The instance type of the container. This determines the amount of memory, CPU, and disk given to the container instance. The current options are `"lite"`, `"basic"`, `"standard-1"`, `"standard-2"`, `"standard-3"`, and `"standard-4"`. The default is `"lite"`. For more information, the see [instance types documentation](https://developers.cloudflare.com/containers/platform-details#instance-types).
|
|
1537
|
+
|
|
1538
|
+
- To specify a custom instance type, see [here](#custom-instance-types).
|
|
1539
|
+
|
|
1540
|
+
- `max_instances` string optional
|
|
1541
|
+
|
|
1542
|
+
- The maximum number of concurrent container instances you want to run at any given moment. Stopped containers do not count towards this - you may have more container instances than this number overall, but only this many actively running containers at once. If a request to start a container will exceed this limit, that request will error.
|
|
1543
|
+
|
|
1544
|
+
- Defaults to 20.
|
|
1545
|
+
|
|
1546
|
+
- This value is only enforced when running in production on Cloudflare's network. This limit does not apply during local development, so you may run more instances than specified.
|
|
1547
|
+
|
|
1548
|
+
- `name` string optional
|
|
1549
|
+
|
|
1550
|
+
- The name of your container. Used as an identifier. This will default to a combination of your Worker name, the class name, and your environment.
|
|
1551
|
+
|
|
1552
|
+
- `image_build_context` string optional
|
|
1553
|
+
|
|
1554
|
+
- The build context of the application, by default it is the directory of `image`.
|
|
1555
|
+
|
|
1556
|
+
- `image_vars` Record\<string, string> optional
|
|
1557
|
+
|
|
1558
|
+
- Build-time variables, equivalent to using `--build-arg` with `docker build`. If you want to provide environment variables to your container at _runtime_, you should [use secret bindings or `envVars` on the Container class](https://developers.cloudflare.com/containers/examples/env-vars-and-secrets/).
|
|
1559
|
+
|
|
1560
|
+
- `rollout_active_grace_period` number optional
|
|
1561
|
+
|
|
1562
|
+
- The minimum number of seconds to wait before an active container instance becomes eligible for updating during a [rollout](https://developers.cloudflare.com/containers/faq#how-do-container-updates-and-rollouts-work). At that point, the container will be sent at `SIGTERM` and still has 15 minutes to shut down before it is forcibly killed and updated.
|
|
1563
|
+
- Defaults to `0`.
|
|
1564
|
+
|
|
1565
|
+
- `rollout_step_percentage` number | number\[] optional
|
|
1566
|
+
|
|
1567
|
+
- Configures what percentage of instances should be updated at each step of a [rollout](https://developers.cloudflare.com/containers/faq#how-do-container-updates-and-rollouts-work).
|
|
1568
|
+
- If this is set to a single number, each step will rollout to that percentage of instances. The options are `5`, `10`, `20`, `25`, `50` or `100`.
|
|
1569
|
+
- If this is an array of numbers, each step specifies the cumulative rollout progress, so the final step must be `100`.
|
|
1570
|
+
- Defaults to `[10, 100]`.
|
|
1571
|
+
- This can be overridden ad hoc by deploying with the `--containers-rollout=immediate` flag, which will roll out to 100% of instances in one step. Note that flag will not override `rollout_active_grace_period`, if configured.
|
|
1572
|
+
|
|
1573
|
+
* wrangler.jsonc
|
|
1574
|
+
|
|
1575
|
+
```jsonc
|
|
1576
|
+
{
|
|
1577
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1578
|
+
"containers": [
|
|
1579
|
+
{
|
|
1580
|
+
"class_name": "MyContainer",
|
|
1581
|
+
"image": "./Dockerfile",
|
|
1582
|
+
"max_instances": 10,
|
|
1583
|
+
"instance_type": "basic",
|
|
1584
|
+
"image_vars": {
|
|
1585
|
+
"FOO": "BAR"
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
],
|
|
1589
|
+
"durable_objects": {
|
|
1590
|
+
"bindings": [
|
|
1591
|
+
{
|
|
1592
|
+
"name": "MY_CONTAINER",
|
|
1593
|
+
"class_name": "MyContainer"
|
|
1594
|
+
}
|
|
1595
|
+
]
|
|
1596
|
+
},
|
|
1597
|
+
"migrations": [
|
|
1598
|
+
{
|
|
1599
|
+
"tag": "v1",
|
|
1600
|
+
"new_sqlite_classes": ["MyContainer"]
|
|
1601
|
+
}
|
|
1602
|
+
]
|
|
1603
|
+
}
|
|
1604
|
+
```
|
|
1605
|
+
|
|
1606
|
+
* wrangler.toml
|
|
1607
|
+
|
|
1608
|
+
```toml
|
|
1609
|
+
[[containers]]
|
|
1610
|
+
class_name = "MyContainer"
|
|
1611
|
+
image = "./Dockerfile"
|
|
1612
|
+
max_instances = 10
|
|
1613
|
+
instance_type = "basic" # Optional, defaults to "lite"
|
|
1614
|
+
image_vars = { FOO = "BAR" }
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
[[durable_objects.bindings]]
|
|
1618
|
+
name = "MY_CONTAINER"
|
|
1619
|
+
class_name = "MyContainer"
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
[[migrations]]
|
|
1623
|
+
tag = "v1"
|
|
1624
|
+
new_sqlite_classes = ["MyContainer"]
|
|
1625
|
+
```
|
|
1626
|
+
|
|
1627
|
+
### Custom Instance Types
|
|
1628
|
+
|
|
1629
|
+
Note
|
|
1630
|
+
|
|
1631
|
+
For Enterprise customers only.
|
|
1632
|
+
|
|
1633
|
+
In place of the [named instance types](https://developers.cloudflare.com/containers/platform-details#instance-types), you can set a custom instance type by individually configuring vCPU, memory, and disk.
|
|
1634
|
+
|
|
1635
|
+
The following options are available:
|
|
1636
|
+
|
|
1637
|
+
- `vcpu` number optional
|
|
1638
|
+
|
|
1639
|
+
- The vCPU to be used by your container. Defaults to `0.0625` (1/16 vCPU).
|
|
1640
|
+
|
|
1641
|
+
- `memory_mib` number optional
|
|
1642
|
+
|
|
1643
|
+
- The memory to be used by your container, in MiB. Defaults to `256`.
|
|
1644
|
+
|
|
1645
|
+
- `disk_mb` number optional
|
|
1646
|
+
|
|
1647
|
+
- The disk to be used by your container, in MB. Defaults to `2000` (2GB).
|
|
1648
|
+
|
|
1649
|
+
* wrangler.jsonc
|
|
1650
|
+
|
|
1651
|
+
```jsonc
|
|
1652
|
+
{
|
|
1653
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1654
|
+
"containers": [
|
|
1655
|
+
{
|
|
1656
|
+
"image": "./Dockerfile",
|
|
1657
|
+
"instance_type": {
|
|
1658
|
+
"vcpu": 1,
|
|
1659
|
+
"memory_mib": 1024,
|
|
1660
|
+
"disk_mb": 4000
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
]
|
|
1664
|
+
}
|
|
1665
|
+
```
|
|
1666
|
+
|
|
1667
|
+
* wrangler.toml
|
|
1668
|
+
|
|
1669
|
+
```toml
|
|
1670
|
+
[[containers]]
|
|
1671
|
+
image = "./Dockerfile"
|
|
1672
|
+
instance_type = { vcpu = 1, memory_mib = 1024, disk_mb = 4000 }
|
|
1673
|
+
```
|
|
1674
|
+
|
|
1675
|
+
## Bundling
|
|
1676
|
+
|
|
1677
|
+
Note
|
|
1678
|
+
|
|
1679
|
+
Wrangler bundling is not applicable if you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
1680
|
+
|
|
1681
|
+
Wrangler can operate in two modes: the default bundling mode and `--no-bundle` mode. In bundling mode, Wrangler will traverse all the imports of your code and generate a single JavaScript "entry-point" file. Imported source code is "inlined/bundled" into this entry-point file.
|
|
1682
|
+
|
|
1683
|
+
It is also possible to include additional modules into your Worker, which are uploaded alongside the entry-point. You specify which additional modules should be included into your Worker using the `rules` key, making these modules available to be imported when your Worker is invoked. The `rules` key will be an array of the below object.
|
|
1684
|
+
|
|
1685
|
+
- `type` string required
|
|
1686
|
+
|
|
1687
|
+
- The type of module. Must be one of: `ESModule`, `CommonJS`, `CompiledWasm`, `Text` or `Data`.
|
|
1688
|
+
|
|
1689
|
+
- `globs` string\[] required
|
|
1690
|
+
|
|
1691
|
+
- An array of glob rules (for example, `["**/*.md"]`). Refer to [glob](https://man7.org/linux/man-pages/man7/glob.7.html).
|
|
1692
|
+
|
|
1693
|
+
- `fallthrough` boolean optional
|
|
1694
|
+
|
|
1695
|
+
- When set to `true` on a rule, this allows you to have multiple rules for the same `Type`.
|
|
1696
|
+
|
|
1697
|
+
Example:
|
|
1698
|
+
|
|
1699
|
+
- wrangler.jsonc
|
|
1700
|
+
|
|
1701
|
+
```jsonc
|
|
1702
|
+
{
|
|
1703
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1704
|
+
"rules": [
|
|
1705
|
+
{
|
|
1706
|
+
"type": "Text",
|
|
1707
|
+
"globs": ["**/*.md"],
|
|
1708
|
+
"fallthrough": true
|
|
1709
|
+
}
|
|
1710
|
+
]
|
|
1711
|
+
}
|
|
1712
|
+
```
|
|
1713
|
+
|
|
1714
|
+
- wrangler.toml
|
|
1715
|
+
|
|
1716
|
+
```toml
|
|
1717
|
+
rules = [
|
|
1718
|
+
{ type = "Text", globs = ["**/*.md"], fallthrough = true }
|
|
1719
|
+
]
|
|
1720
|
+
```
|
|
1721
|
+
|
|
1722
|
+
### Importing modules within a Worker
|
|
1723
|
+
|
|
1724
|
+
You can import and refer to these modules within your Worker, like so:
|
|
1725
|
+
|
|
1726
|
+
```js
|
|
1727
|
+
import markdown from "./example.md";
|
|
1728
|
+
|
|
1729
|
+
export default {
|
|
1730
|
+
async fetch() {
|
|
1731
|
+
return new Response(markdown);
|
|
1732
|
+
},
|
|
1733
|
+
};
|
|
1734
|
+
```
|
|
1735
|
+
|
|
1736
|
+
### Find additional modules
|
|
1737
|
+
|
|
1738
|
+
Normally Wrangler will only include additional modules that are statically imported in your source code as in the example above. By setting `find_additional_modules` to `true` in your configuration file, Wrangler will traverse the file tree below `base_dir`. Any files that match `rules` will also be included as unbundled, external modules in the deployed Worker. `base_dir` defaults to the directory containing your `main` entrypoint.
|
|
1739
|
+
|
|
1740
|
+
See <https://developers.cloudflare.com/workers/wrangler/bundling/> for more details and examples.
|
|
1741
|
+
|
|
1742
|
+
### Python Workers
|
|
1743
|
+
|
|
1744
|
+
By default, Python Workers bundle the files and folders in `python_modules` at the root of your Worker (alongside your wrangler config file). The files in this directory represent your vendored packages and is where the pywrangler tool copies packages into. In some cases, you may find that the files in this folder are too large and if your worker doesn't require them then they just grow your bundle size for no reason.
|
|
1745
|
+
|
|
1746
|
+
To fix this, you can exclude certain files from being included. To do this use the `python_modules.excludes` option, for example:
|
|
1747
|
+
|
|
1748
|
+
- wrangler.jsonc
|
|
1749
|
+
|
|
1750
|
+
```jsonc
|
|
1751
|
+
{
|
|
1752
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1753
|
+
"python_modules": {
|
|
1754
|
+
"excludes": ["**/*.pyc", "**/__pycache__"]
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
```
|
|
1758
|
+
|
|
1759
|
+
- wrangler.toml
|
|
1760
|
+
|
|
1761
|
+
```toml
|
|
1762
|
+
[python_modules]
|
|
1763
|
+
excludes = ["**/*.pyc", "**/__pycache__"]
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
This will exclude any .pyc files and `__pycache__` directories inside any subdirectory in `python_modules`.
|
|
1767
|
+
|
|
1768
|
+
By default, `python_modules.excludes` is set to `["**/*.pyc"]`, so be sure to include this when setting it to a different value.
|
|
1769
|
+
|
|
1770
|
+
## Local development settings
|
|
1771
|
+
|
|
1772
|
+
Note
|
|
1773
|
+
|
|
1774
|
+
If you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), you should use Vite's [server options](https://vite.dev/config/server-options.html) instead.
|
|
1775
|
+
|
|
1776
|
+
You can configure various aspects of local development, such as the local protocol or port.
|
|
1777
|
+
|
|
1778
|
+
- `ip` string optional
|
|
1779
|
+
|
|
1780
|
+
* IP address for the local dev server to listen on. Defaults to `localhost`.
|
|
1781
|
+
|
|
1782
|
+
- `port` number optional
|
|
1783
|
+
|
|
1784
|
+
* Port for the local dev server to listen on. Defaults to `8787`.
|
|
1785
|
+
|
|
1786
|
+
- `local_protocol` string optional
|
|
1787
|
+
|
|
1788
|
+
- Protocol that local dev server listens to requests on. Defaults to `http`.
|
|
1789
|
+
|
|
1790
|
+
- `upstream_protocol` string optional
|
|
1791
|
+
|
|
1792
|
+
- Protocol that the local dev server forwards requests on. Defaults to `https`.
|
|
1793
|
+
|
|
1794
|
+
- `host` string optional
|
|
1795
|
+
|
|
1796
|
+
- Host to forward requests to, defaults to the host of the first `route` of the Worker.
|
|
1797
|
+
|
|
1798
|
+
- `enable_containers` boolean optional
|
|
1799
|
+
|
|
1800
|
+
- Determines whether to enable containers during a local dev session, if they have been configured. Defaults to `true`. If set to `false`, you can develop the rest of your application without requiring Docker or other container tool, as long as you do not invoke any code that interacts with containers.
|
|
1801
|
+
|
|
1802
|
+
- `container_engine` string optional
|
|
1803
|
+
|
|
1804
|
+
- Used for local development of [Containers](https://developers.cloudflare.com/containers/local-dev). Wrangler will attempt to automatically find the correct socket to use to communicate with your container engine. If that does not work (usually surfacing as an `internal error` when attempting to connect to your Container), you can try setting the socket path using this option. You can also set this via the environment variable `DOCKER_HOST`. Example:
|
|
1805
|
+
|
|
1806
|
+
* wrangler.jsonc
|
|
1807
|
+
|
|
1808
|
+
```jsonc
|
|
1809
|
+
{
|
|
1810
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1811
|
+
"dev": {
|
|
1812
|
+
"ip": "192.168.1.1",
|
|
1813
|
+
"port": 8080,
|
|
1814
|
+
"local_protocol": "http"
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
```
|
|
1818
|
+
|
|
1819
|
+
* wrangler.toml
|
|
1820
|
+
|
|
1821
|
+
```toml
|
|
1822
|
+
[dev]
|
|
1823
|
+
ip = "192.168.1.1"
|
|
1824
|
+
port = 8080
|
|
1825
|
+
local_protocol = "http"
|
|
1826
|
+
```
|
|
1827
|
+
|
|
1828
|
+
### Secrets
|
|
1829
|
+
|
|
1830
|
+
[Secrets](https://developers.cloudflare.com/workers/configuration/secrets/) are a type of binding that allow you to [attach encrypted text values](https://developers.cloudflare.com/workers/wrangler/commands/#secret) to your Worker.
|
|
1831
|
+
|
|
1832
|
+
Warning
|
|
1833
|
+
|
|
1834
|
+
Do not use `vars` to store sensitive information in your Worker's Wrangler configuration file. Use secrets instead.
|
|
1835
|
+
|
|
1836
|
+
Put secrets for use in local development in either a `.dev.vars` file or a `.env` file, in the same directory as the Wrangler configuration file.
|
|
1837
|
+
|
|
1838
|
+
Choose to use either `.dev.vars` or `.env` but not both. If you define a `.dev.vars` file, then values in `.env` files will not be included in the `env` object during local development.
|
|
1839
|
+
|
|
1840
|
+
These files should be formatted using the [dotenv](https://hexdocs.pm/dotenvy/dotenv-file-format.html) syntax. For example:
|
|
1841
|
+
|
|
1842
|
+
```bash
|
|
1843
|
+
SECRET_KEY="value"
|
|
1844
|
+
API_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
|
|
1845
|
+
```
|
|
1846
|
+
|
|
1847
|
+
Do not commit secrets to git
|
|
1848
|
+
|
|
1849
|
+
The `.dev.vars` and `.env` files should not committed to git. Add `.dev.vars*` and `.env*` to your project's `.gitignore` file.
|
|
1850
|
+
|
|
1851
|
+
To set different secrets for each Cloudflare environment, create files named `.dev.vars.<environment-name>` or `.env.<environment-name>`.
|
|
1852
|
+
|
|
1853
|
+
When you select a Cloudflare environment in your local development, the corresponding environment-specific file will be loaded ahead of the generic `.dev.vars` (or `.env`) file.
|
|
1854
|
+
|
|
1855
|
+
- When using `.dev.vars.<environment-name>` files, all secrets must be defined per environment. If `.dev.vars.<environment-name>` exists then only this will be loaded; the `.dev.vars` file will not be loaded.
|
|
1856
|
+
|
|
1857
|
+
- In contrast, all matching `.env` files are loaded and the values are merged. For each variable, the value from the most specific file is used, with the following precedence:
|
|
1858
|
+
|
|
1859
|
+
- `.env.<environment-name>.local` (most specific)
|
|
1860
|
+
- `.env.local`
|
|
1861
|
+
- `.env.<environment-name>`
|
|
1862
|
+
- `.env` (least specific)
|
|
1863
|
+
|
|
1864
|
+
Controlling `.env` handling
|
|
1865
|
+
|
|
1866
|
+
It is possible to control how `.env` files are loaded in local development by setting environment variables on the process running the tools.
|
|
1867
|
+
|
|
1868
|
+
- To disable loading local dev vars from `.env` files without providing a `.dev.vars` file, set the `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV` environment variable to `"false"`.
|
|
1869
|
+
- To include every environment variable defined in your system's process environment as a local development variable, ensure there is no `.dev.vars` and then set the `CLOUDFLARE_INCLUDE_PROCESS_ENV` environment variable to `"true"`.
|
|
1870
|
+
|
|
1871
|
+
## Module Aliasing
|
|
1872
|
+
|
|
1873
|
+
Note
|
|
1874
|
+
|
|
1875
|
+
If you're using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), `alias` is replaced Vite's [`resolve.alias`](https://vite.dev/config/shared-options.html#resolve-alias).
|
|
1876
|
+
|
|
1877
|
+
You can configure Wrangler to replace all calls to import a particular package with a module of your choice, by configuring the `alias` field:
|
|
1878
|
+
|
|
1879
|
+
- wrangler.jsonc
|
|
1880
|
+
|
|
1881
|
+
```jsonc
|
|
1882
|
+
{
|
|
1883
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1884
|
+
"alias": {
|
|
1885
|
+
"foo": "./replacement-module-filepath"
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
```
|
|
1889
|
+
|
|
1890
|
+
- wrangler.toml
|
|
1891
|
+
|
|
1892
|
+
```toml
|
|
1893
|
+
[alias]
|
|
1894
|
+
"foo" = "./replacement-module-filepath"
|
|
1895
|
+
```
|
|
1896
|
+
|
|
1897
|
+
```js
|
|
1898
|
+
export const bar = "baz";
|
|
1899
|
+
```
|
|
1900
|
+
|
|
1901
|
+
With the configuration above, any calls to `import` or `require()` the module `foo` will be aliased to point to your replacement module:
|
|
1902
|
+
|
|
1903
|
+
```js
|
|
1904
|
+
import { bar } from "foo";
|
|
1905
|
+
|
|
1906
|
+
console.log(bar); // returns "baz"
|
|
1907
|
+
```
|
|
1908
|
+
|
|
1909
|
+
### Example: Aliasing dependencies from NPM
|
|
1910
|
+
|
|
1911
|
+
You can use module aliasing to provide an implementation of an NPM package that does not work on Workers — even if you only rely on that NPM package indirectly, as a dependency of one of your Worker's dependencies.
|
|
1912
|
+
|
|
1913
|
+
For example, some NPM packages depend on [`node-fetch`](https://www.npmjs.com/package/node-fetch), a package that provided a polyfill of the [`fetch()` API](https://developers.cloudflare.com/workers/runtime-apis/fetch/), before it was built into Node.js.
|
|
1914
|
+
|
|
1915
|
+
`node-fetch` isn't needed in Workers, because the `fetch()` API is provided by the Workers runtime. And `node-fetch` doesn't work on Workers, because it relies on currently unsupported Node.js APIs from the `http`/`https` modules.
|
|
1916
|
+
|
|
1917
|
+
You can alias all imports of `node-fetch` to instead point directly to the `fetch()` API that is built into the Workers runtime:
|
|
1918
|
+
|
|
1919
|
+
- wrangler.jsonc
|
|
1920
|
+
|
|
1921
|
+
```jsonc
|
|
1922
|
+
{
|
|
1923
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1924
|
+
"alias": {
|
|
1925
|
+
"node-fetch": "./fetch-polyfill"
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
```
|
|
1929
|
+
|
|
1930
|
+
- wrangler.toml
|
|
1931
|
+
|
|
1932
|
+
```toml
|
|
1933
|
+
[alias]
|
|
1934
|
+
"node-fetch" = "./fetch-polyfill"
|
|
1935
|
+
```
|
|
1936
|
+
|
|
1937
|
+
```js
|
|
1938
|
+
export default fetch;
|
|
1939
|
+
```
|
|
1940
|
+
|
|
1941
|
+
### Example: Aliasing Node.js APIs
|
|
1942
|
+
|
|
1943
|
+
You can use module aliasing to provide your own polyfill implementation of a Node.js API that is not yet available in the Workers runtime.
|
|
1944
|
+
|
|
1945
|
+
For example, let's say the NPM package you rely on calls [`fs.readFile`](https://nodejs.org/api/fs.html#fsreadfilepath-options-callback). You can alias the fs module by adding the following to your Worker's Wrangler configuration file:
|
|
1946
|
+
|
|
1947
|
+
- wrangler.jsonc
|
|
1948
|
+
|
|
1949
|
+
```jsonc
|
|
1950
|
+
{
|
|
1951
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1952
|
+
"alias": {
|
|
1953
|
+
"fs": "./fs-polyfill"
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
```
|
|
1957
|
+
|
|
1958
|
+
- wrangler.toml
|
|
1959
|
+
|
|
1960
|
+
```toml
|
|
1961
|
+
[alias]
|
|
1962
|
+
"fs" = "./fs-polyfill"
|
|
1963
|
+
```
|
|
1964
|
+
|
|
1965
|
+
```js
|
|
1966
|
+
export function readFile() {
|
|
1967
|
+
// ...
|
|
1968
|
+
}
|
|
1969
|
+
```
|
|
1970
|
+
|
|
1971
|
+
In many cases, this allows you to work provide just enough of an API to make a dependency work. You can learn more about Cloudflare Workers' support for Node.js APIs on the [Cloudflare Workers Node.js API documentation page](https://developers.cloudflare.com/workers/runtime-apis/nodejs/).
|
|
1972
|
+
|
|
1973
|
+
## Source maps
|
|
1974
|
+
|
|
1975
|
+
[Source maps](https://developers.cloudflare.com/workers/observability/source-maps/) translate compiled and minified code back to the original code that you wrote. Source maps are combined with the stack trace returned by the JavaScript runtime to present you with a stack trace.
|
|
1976
|
+
|
|
1977
|
+
- `upload_source_maps` boolean
|
|
1978
|
+
- When `upload_source_maps` is set to `true`, Wrangler will automatically generate and upload source map files when you run [`wrangler deploy`](https://developers.cloudflare.com/workers/wrangler/commands/#deploy) or [`wrangler versions deploy`](https://developers.cloudflare.com/workers/wrangler/commands/#versions-deploy).
|
|
1979
|
+
|
|
1980
|
+
Example:
|
|
1981
|
+
|
|
1982
|
+
- wrangler.jsonc
|
|
1983
|
+
|
|
1984
|
+
```jsonc
|
|
1985
|
+
{
|
|
1986
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
1987
|
+
"upload_source_maps": true
|
|
1988
|
+
}
|
|
1989
|
+
```
|
|
1990
|
+
|
|
1991
|
+
- wrangler.toml
|
|
1992
|
+
|
|
1993
|
+
```toml
|
|
1994
|
+
upload_source_maps = true
|
|
1995
|
+
```
|
|
1996
|
+
|
|
1997
|
+
## Workers Sites
|
|
1998
|
+
|
|
1999
|
+
Use Workers Static Assets Instead
|
|
2000
|
+
|
|
2001
|
+
You should use [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/) to host full-stack applications instead of Workers Sites. It has been deprecated in Wrangler v4, and the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/) does not support Workers Sites. Do not use Workers Sites for new projects.
|
|
2002
|
+
|
|
2003
|
+
[Workers Sites](https://developers.cloudflare.com/workers/configuration/sites/) allows you to host static websites, or dynamic websites using frameworks like Vue or React, on Workers.
|
|
2004
|
+
|
|
2005
|
+
- `bucket` string required
|
|
2006
|
+
|
|
2007
|
+
- The directory containing your static assets. It must be a path relative to your Wrangler configuration file.
|
|
2008
|
+
|
|
2009
|
+
- `include` string\[] optional
|
|
2010
|
+
|
|
2011
|
+
- An exclusive list of `.gitignore`-style patterns that match file or directory names from your bucket location. Only matched items will be uploaded.
|
|
2012
|
+
|
|
2013
|
+
- `exclude` string\[] optional
|
|
2014
|
+
|
|
2015
|
+
- A list of `.gitignore`-style patterns that match files or directories in your bucket that should be excluded from uploads.
|
|
2016
|
+
|
|
2017
|
+
Example:
|
|
2018
|
+
|
|
2019
|
+
- wrangler.jsonc
|
|
2020
|
+
|
|
2021
|
+
```jsonc
|
|
2022
|
+
{
|
|
2023
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
2024
|
+
"site": {
|
|
2025
|
+
"bucket": "./public",
|
|
2026
|
+
"include": ["upload_dir"],
|
|
2027
|
+
"exclude": ["ignore_dir"]
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
```
|
|
2031
|
+
|
|
2032
|
+
- wrangler.toml
|
|
2033
|
+
|
|
2034
|
+
```toml
|
|
2035
|
+
[site]
|
|
2036
|
+
bucket = "./public"
|
|
2037
|
+
include = ["upload_dir"]
|
|
2038
|
+
exclude = ["ignore_dir"]
|
|
2039
|
+
```
|
|
2040
|
+
|
|
2041
|
+
## Proxy support
|
|
2042
|
+
|
|
2043
|
+
Corporate networks will often have proxies on their networks and this can sometimes cause connectivity issues. To configure Wrangler with the appropriate proxy details, [add the following environmental variables](https://developers.cloudflare.com/workers/configuration/environment-variables/):
|
|
2044
|
+
|
|
2045
|
+
- `https_proxy`
|
|
2046
|
+
- `HTTPS_PROXY`
|
|
2047
|
+
- `http_proxy`
|
|
2048
|
+
- `HTTP_PROXY`
|
|
2049
|
+
|
|
2050
|
+
To configure this on macOS, add `HTTP_PROXY=http://<YOUR_PROXY_HOST>:<YOUR_PROXY_PORT>` before your Wrangler commands.
|
|
2051
|
+
|
|
2052
|
+
Example:
|
|
2053
|
+
|
|
2054
|
+
```sh
|
|
2055
|
+
$ HTTP_PROXY=http://localhost:8080 wrangler dev
|
|
2056
|
+
```
|
|
2057
|
+
|
|
2058
|
+
If your IT team has configured your computer's proxy settings, be aware that the first non-empty environment variable in this list will be used when Wrangler makes outgoing requests.
|
|
2059
|
+
|
|
2060
|
+
For example, if both `https_proxy` and `http_proxy` are set, Wrangler will only use `https_proxy` for outgoing requests.
|
|
2061
|
+
|
|
2062
|
+
## Source of truth
|
|
2063
|
+
|
|
2064
|
+
We recommend treating your Wrangler configuration file as the source of truth for your Worker configuration, and to avoid making changes to your Worker via the Cloudflare dashboard if you are using Wrangler.
|
|
2065
|
+
|
|
2066
|
+
If you need to make changes to your Worker from the Cloudflare dashboard, the dashboard will generate a TOML snippet for you to copy into your Wrangler configuration file, which will help ensure your Wrangler configuration file is always up to date.
|
|
2067
|
+
|
|
2068
|
+
If you change your environment variables in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behavior, add `keep_vars = true` to your Wrangler configuration file.
|
|
2069
|
+
|
|
2070
|
+
If you change your routes in the dashboard, Wrangler will override them in the next deploy with the routes you have set in your Wrangler configuration file. To manage routes via the Cloudflare dashboard only, remove any route and routes keys from your Wrangler configuration file. Then add `workers_dev = false` to your Wrangler configuration file. For more information, refer to [Deprecations](https://developers.cloudflare.com/workers/wrangler/deprecations/#other-deprecated-behavior).
|
|
2071
|
+
|
|
2072
|
+
Wrangler will not delete your secrets (encrypted environment variables) unless you run `wrangler secret delete <key>`.
|
|
2073
|
+
|
|
2074
|
+
## Generated Wrangler configuration
|
|
2075
|
+
|
|
2076
|
+
Note
|
|
2077
|
+
|
|
2078
|
+
This section describes a feature that can be implemented by frameworks and other build tools that are integrating with Wrangler.
|
|
2079
|
+
|
|
2080
|
+
It is unlikely that an application developer will need to use this feature, but it is documented here to help you understand when Wrangler is using a generated configuration rather than the original, user's configuration.
|
|
2081
|
+
|
|
2082
|
+
For example, when using the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/), an output Worker configuration file is generated as part of the build. This is then used for preview and deployment.
|
|
2083
|
+
|
|
2084
|
+
Some framework tools, or custom pre-build processes, generate a modified Wrangler configuration to be used to deploy the Worker code. In this case, the tool may also create a special `.wrangler/deploy/config.json` file that redirects Wrangler to use the generated configuration rather than the original, user's configuration.
|
|
2085
|
+
|
|
2086
|
+
Wrangler uses this generated configuration only for the following deploy and dev related commands:
|
|
2087
|
+
|
|
2088
|
+
- `wrangler deploy`
|
|
2089
|
+
- `wrangler dev`
|
|
2090
|
+
- `wrangler versions upload`
|
|
2091
|
+
- `wrangler versions deploy`
|
|
2092
|
+
- `wrangler pages deploy`
|
|
2093
|
+
- `wrangler pages functions build`
|
|
2094
|
+
|
|
2095
|
+
When running these commands, Wrangler looks up the directory tree from the current working directory for a file at the path `.wrangler/deploy/config.json`. This file must contain only a single JSON object of the form:
|
|
2096
|
+
|
|
2097
|
+
```json
|
|
2098
|
+
{ "configPath": "../../path/to/wrangler.jsonc" }
|
|
2099
|
+
```
|
|
2100
|
+
|
|
2101
|
+
When this `config.json` file exists, Wrangler will follow the `configPath` (relative to the `.wrangler/deploy/config.json` file) to find the generated Wrangler configuration file to load and use in the current command. Wrangler will display messaging to the user to indicate that the configuration has been redirected to a different file than the user's configuration file.
|
|
2102
|
+
|
|
2103
|
+
The generated configuration file should not include any [environments](#environments). This is because such a file, when required, should be created as part of a build step, which should already target a specific environment. These build tools should generate distinct deployment configuration files for different environments.
|
|
2104
|
+
|
|
2105
|
+
### Custom build tool example
|
|
2106
|
+
|
|
2107
|
+
A common example of using a redirected configuration is where a custom build tool, or framework, wants to modify the user's configuration to be used when deploying, by generating a new configuration in a `dist` directory.
|
|
2108
|
+
|
|
2109
|
+
- First, the user writes code that uses Cloudflare Workers resources, configured via a user's Wrangler configuration file like the following:
|
|
2110
|
+
|
|
2111
|
+
- wrangler.jsonc
|
|
2112
|
+
|
|
2113
|
+
```jsonc
|
|
2114
|
+
{
|
|
2115
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
2116
|
+
"name": "my-worker",
|
|
2117
|
+
"main": "src/index.ts",
|
|
2118
|
+
"vars": {
|
|
2119
|
+
"MY_VARIABLE": "production variable"
|
|
2120
|
+
},
|
|
2121
|
+
"env": {
|
|
2122
|
+
"staging": {
|
|
2123
|
+
"vars": {
|
|
2124
|
+
"MY_VARIABLE": "staging variable"
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
```
|
|
2130
|
+
|
|
2131
|
+
- wrangler.toml
|
|
2132
|
+
|
|
2133
|
+
```toml
|
|
2134
|
+
name = "my-worker"
|
|
2135
|
+
main = "src/index.ts"
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
[vars]
|
|
2139
|
+
MY_VARIABLE = "production variable"
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
[env.staging.vars]
|
|
2143
|
+
MY_VARIABLE = "staging variable"
|
|
2144
|
+
```
|
|
2145
|
+
|
|
2146
|
+
This configuration points `main` at the user's code entry-point and defines the `MY_VARIABLE` variable in two different environments.
|
|
2147
|
+
|
|
2148
|
+
- Then, the user runs a custom build for a given environment (for example `staging`). This will read the user's Wrangler configuration file to find the source code entry-point and environment specific settings:
|
|
2149
|
+
|
|
2150
|
+
```bash
|
|
2151
|
+
> my-tool build --env=staging
|
|
2152
|
+
```
|
|
2153
|
+
|
|
2154
|
+
- `my-tool` generates a `dist` directory that contains both compiled code and a new generated deployment configuration file, containing only the settings for the given environment. It also creates a `.wrangler/deploy/config.json` file that redirects Wrangler to the new, generated deployment configuration file:
|
|
2155
|
+
|
|
2156
|
+
The generated `dist/wrangler.jsonc` might contain:
|
|
2157
|
+
|
|
2158
|
+
```json
|
|
2159
|
+
{
|
|
2160
|
+
"name": "my-worker",
|
|
2161
|
+
"main": "./index.js",
|
|
2162
|
+
"vars": {
|
|
2163
|
+
"MY_VARIABLE": "staging variable"
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
```
|
|
2167
|
+
|
|
2168
|
+
Now, the `main` property points to the generated code entry-point, no environment is defined, and the `MY_VARIABLE` variable is resolved to the staging environment value.
|
|
2169
|
+
|
|
2170
|
+
And the `.wrangler/deploy/config.json` contains the path to the generated configuration file:
|
|
2171
|
+
|
|
2172
|
+
```json
|
|
2173
|
+
{
|
|
2174
|
+
"configPath": "../../dist/wrangler.jsonc"
|
|
2175
|
+
}
|
|
2176
|
+
```
|