Skip to content

Workers ​

Workers are the core unit of deployment in Tamer. Each worker is declared via defineWorker and produces one Wrangler script per environment.

Basic structure ​

ts
import { defineWorker } from "@dragonmastery/tamer";

export const apiWorker = defineWorker({
  path: "workers/cf-app-api",        // project directory (relative to repo root)
  scriptName: "my-app-api",          // deployed script name
  main: "src/worker.ts",             // entrypoint

  resources: {
    d1: [{ logicalName: "settings", type: "single" }],
    r2: [{ logicalName: "assets" }],
    kv: [{ logicalName: "cache" }],
  },

  vars: {
    ENVIRONMENT: "local",
    LOG_LEVEL: "debug",
  },

  env: {
    dev: { vars: { ENVIRONMENT: "dev", LOG_LEVEL: "debug" } },
    prod: { vars: { ENVIRONMENT: "prod", LOG_LEVEL: "info" } },
  },
});

Key fields ​

path ​

Project directory for the worker, relative to the repo root. Tamer generates wrangler.json here (and wrangler.vitest.json on --env local), and runs wrangler types / wrangler deploy from this directory. Local generate: tamer wrangler --env local — see Local Development.

scriptName ​

The deployed Cloudflare script name. If omitted, Tamer derives a name from the stack identity and worker key ({stack}-{workerKey}-{env}, or {stack}-{workerKey} for local).

resources ​

Tamer-managed Cloudflare resources. Each kind expands to a wrangler binding plus a state row. See Resource Kinds.

vars ​

Runtime environment variables for the Worker. These land in wrangler.json and are also passed as env vars to the build step (if declared). See Values Lifecycle.

build ​

Pre-deploy build command (e.g. { command: "vite build" }). Tamer spawns it in the worker's path directory with resolved vars as environment variables. See SPA Build.

env / local ​

Per-env overrides. See Environments.

tamerRoutes ​

HTTP routes expanded per env. Zone-name routes are managed via the Workers Routes API (not written to wrangler.json). Custom-domain routes are written to wrangler.json.

doMigrations + resources.durableObjects ​

Managed Durable Object class bindings and append-only class migrations. Emitted as wrangler durable_objects + migrations on deploy / tenant provision. Instance census and in-DO SQL schema are app-owned. See Durable Objects.

secrets ​

Declares required secret names. Values come from the Tamer vault and are pushed on deploy. See Secrets.

durable_objects (passthrough) ​

Raw Wrangler durable_objects still passes through when you are not using managed resources.durableObjects / doMigrations. Mixing both on the same worker is rejected. tamer deploy's topological sort still reads durable_objects.bindings[].script_name so DO hosts deploy before dependents. See Field Boundary.

What lands in wrangler.json ​

Not all fields on the worker config appear in the generated wrangler.json. Tamer-only fields like path, resources, build, secrets, tamerRoutes are stripped. On --env local, Tamer also writes a wrangler.vitest.json sibling (remote stripped). See Field Boundary and Local Development.

Released under the Tamer Evaluation License.