# Cloudflare Workers STOP. Your knowledge of Cloudflare Workers APIs and limits may be outdated. Always retrieve current documentation before any Workers, KV, R2, D1, Durable Objects, Queues, Vectorize, AI, or Agents SDK task. ## Docs - https://developers.cloudflare.com/workers/ - MCP: `https://docs.mcp.cloudflare.com/mcp` For all limits and quotas, retrieve from the product's `/platform/limits/` page. e.g. `/workers/platform/limits` ## Product Docs Retrieve API references and limits from: `/kv/` · `/r2/` · `/d1/` · `/durable-objects/` · `/queues/` · `/vectorize/` · `/workers-ai/` · `/agents/` ## Errors - **Error 1102** (CPU/Memory exceeded): Retrieve limits from `/workers/platform/limits/` - **All errors**: https://developers.cloudflare.com/workers/observability/errors/ --- # Project: tangfamily A Cloudflare Workers full-stack family tree website. The single Worker at `src/index.ts` serves all API routes; static HTML pages in `public/` are served via Cloudflare's asset pipeline (`env.ASSETS`). Data is stored in a KV namespace (`FAMILY_DATA`). Deployed at https://tangfamily.shumengya666.workers.dev. ## Commands | Command | Purpose | |---------|---------| | `npm run dev` | Start local dev server (http://127.0.0.1:8787) | | `npm run deploy` | Deploy to Cloudflare | | `npm test` | Run all tests (vitest watch mode) | | `npm run cf-typegen` | Regenerate `worker-configuration.d.ts` from `wrangler.jsonc` | **Run a single test file:** ```bash npx vitest run test/index.spec.ts ``` **Run a single test by name:** ```bash npx vitest run -t "test name here" ``` Always run `npm run cf-typegen` after changing any bindings in `wrangler.jsonc`. There is no lint script. Format with Prettier manually if needed: ```bash npx prettier --write "src/**/*.ts" ``` ## Project Structure ``` src/index.ts # Single-file Worker: all API handlers + routing + CORS public/index.html # Visitor login page public/tree.html # Family tree viewer (authenticated visitors) public/admin-login.html # Admin login public/admin.html # Admin CRUD panel test/index.spec.ts # Vitest integration tests (runs inside Workers runtime) test/tsconfig.json # Extends root tsconfig; adds vitest-pool-workers types test/env.d.ts # Merges Env into cloudflare:test module vitest.config.mts # Vitest config — uses defineWorkersConfig + wrangler.jsonc wrangler.jsonc # Worker config: entry, KV binding, assets, compat flags worker-configuration.d.ts # Auto-generated by cf-typegen — do not edit manually ``` ## Architecture - All API logic lives in `src/index.ts`; there are no other Worker source files. - `public/*.html` pages are pure HTML with inline CSS and inline `