Skip to content

Build your first Worker

Last updated View as MarkdownAgent index

Create a private reports Worker with only wrangler.jsonc and index.ts. You will run it locally and package its compiled code. This tutorial does not provision resources or deploy to Cloudflare.

Prerequisites

Use a checkout containing the shared Worker tooling. Install Node.js 24 and pnpm using the root package.json pins. Install Terraform and TFLint for the repository checks. Choose a different app name if reports already exists.

Create and run the app

  1. From a clean checkout, create a working branch.

    git checkout -b add/reports-worker
  2. Create the Worker and its registration.

    make app-create APP=reports DESCRIPTION="Internal reports API"
    git diff --stat
    git status --short

    The app folder contains two files. The command also creates org/cloudflare/app-reports.tf, adds the app to org/catalog.json, and refreshes the README inventory. The new Worker has no public route, Custom Domain, or enabled workers.dev endpoint.

  3. Install the shared toolchain and start the local Worker.

    make app-setup APP=reports
    make app-dev APP=reports
  4. In another terminal, request the local address printed by Wrangler. With the default port available, run:

    curl --fail http://localhost:8787/

    The response contains service: "reports" and status: "ok". Stop the development process before continuing.

Verify and inspect the release

  1. Generate binding types and run application checks.

    make app-types APP=reports
    make app-verify APP=reports

    Generated types belong in the ignored .generated/ directory. Verification type-checks the Worker and performs a Wrangler dry run.

  2. Package the app and test that package without deploying it.

    make app-package APP=reports
    make app-release-check APP=reports

    Inspect org/apps/reports/.release/manifest.json. It names stormtrust-reports and records the compiled files and their checksums. Local packages use the current commit identifier; uncommitted edits do not become a production release merely because packaging succeeds.

  3. Verify the repository registration.

    make fmt
    make verify
    git status --short

    Review the two source files, Terraform declaration, catalog, and README. Build output, generated types, and release directories stay untracked.

Next steps

Connect resources and shared code before following Deploy a change. Only the trusted main workflow provisions and deploys the app.