Prerequisites
- Node.js and npm/yarn/bun installed.
- A Cloudflare account.
- Wrangler CLI installed globally or as a dev dependency (
npm install -g wranglerorbun add -d wrangler).
Configuration
-
Login to Cloudflare:
Follow the prompts to authenticate with your Cloudflare account.
-
Review
wrangler.jsonc(orwrangler.toml):- Ensure the
nameproperty reflects the desired name for your Worker service. - Verify the
mainproperty points to the correct entry file (likely related tosrc/app/index.tsafter build). (Exact path depends on build output) - Check
compatibility_dateand update if necessary. - Confirm the
account_idis present or configured via environment variables/secrets if needed. - (Add any specific details found in wrangler.jsonc, like KV namespaces, routes, etc. if they were present)
- Ensure the
Build
Before deploying, you need to build the TypeScript code into JavaScript suitable for Cloudflare Workers.tsc or another bundler (like esbuild via Hono’s build tools) to compile the code, often outputting to a dist directory.
Deploy
Once built, deploy the worker using Wrangler:wrangler.jsonc. After deployment, it will usually output the URL where the Worker is accessible.
CI/CD (Continuous Integration / Continuous Deployment)
(No specific CI/CD configuration (e.g., GitHub Actions, GitLab CI) was detected in the repository structure provided.) To set up CI/CD:- Create workflow files (e.g.,
.github/workflows/deploy.yml). - Configure steps to:
- Checkout the code.
- Set up Node.js/Bun.
- Install dependencies (
bun install). - Build the project (
bun run build). - Deploy using Wrangler (
wrangler deploy).
- Store Cloudflare API tokens (
CF_API_TOKEN) andCF_ACCOUNT_IDsecurely as secrets in your CI/CD environment. The Wrangler deploy command can use these environment variables for authentication.