name = "traks-api-dev" main = "src/index.ts" compatibility_date = "2026-06-01" compatibility_flags = ["nodejs_compat"] # Dashboard requests are back-end bound: each one makes several sequential hops # to D1, the live Durable Object and R2 SQL, none of which live at the edge. # Running near the data beats running near the viewer here - the opposite of # the collect worker, which stays at the edge because ingest latency is felt on # the visitor's page. [placement] mode = "smart" # --- Dev (local-first: wrangler dev, shared state in /.wrangler-state) --- # Local dev serves the SPA from vite (:5012, proxying /api to :5011). D1/KV # are local simulations; ids below are inert locally. Only the events # warehouse (R2 SQL over traks-events-dev) is a real cloud dependency. [[d1_databases]] binding = "DB" database_name = "traks-db-dev" database_id = "cd0ff4bb-5cc4-4002-a259-be02b3234e29" migrations_dir = "src/db/migrations" # Cross-script binding to the collect worker's live-stats Durable Object # (hot path for "today"/realtime queries). The collect worker owns the class. [[durable_objects.bindings]] name = "LIVE" class_name = "SiteLiveStore" script_name = "traks-collect-dev" # Global (cross-colo) result cache for R2 SQL dashboard queries. Layered # behind the per-colo Cache API: a scan any colo already paid for is reused # worldwide for the TTL. On workers.dev installs (the wizard default) the # Cache API is a no-op, so this KV namespace is the only result cache. [[kv_namespaces]] binding = "R2SQL_CACHE" id = "fc5eb93cfb8f4cb18969af2ccd4f9ea5" # Query telemetry: one row per R2 SQL cache decision (wall ms, rows, outcome). [[analytics_engine_datasets]] binding = "METRICS" dataset = "traks_api_metrics_dev" # Every minute: the pre-warm sweep (src/lib/prewarm.ts) - a no-op unless a # cache bucket just rolled for a recently viewed site. # Brute-force guard on the auth surface, keyed by client IP. Better Auth's # built-in limiter is in-memory - per-isolate on Workers, so effectively no # limiter at all. A single-owner instance has one known account, so this is # the only thing standing between it and offline-speed guessing. [[ratelimits]] name = "AUTH_LIMIT" namespace_id = "1004" simple = { limit = 20, period = 60 } [triggers] crons = ["* * * * *"] [vars] ENVIRONMENT = "development" R2_BUCKET_NAME = "traks-events-dev" R2_ACCOUNT_ID = "4cf68c768770ccda55d287d6ecbdeb4f" COLLECT_URL = "http://localhost:5010" # The platform ships to customers as a release bundle; the ONLY install path # is the traks.dev deploy wizard. There is no wrangler prod deploy - our own # instance (and any staging one) is installed through the wizard like any # other customer. Dev config above is for local iteration only.