mirror of
https://github.com/dcarrillo/atalaya.git
synced 2026-06-29 15:03:48 +00:00
3.1 KiB
3.1 KiB
AGENTS.md — Atalaya
Architecture
npm workspace: Cloudflare Worker (src/) + Astro 6 SSR app (status-page/).
- Worker entrypoint:
src/index.ts—fetch+scheduledhandlers,RegionalCheckerDurable Object - Astro entrypoint:
status-page/src/pages/index.astro— single-page SSR app - Static assets:
status-page/dist/client/served viaASSETSbinding (run_worker_first = true) - Shared types:
src/types.tsimported via@worker/typesalias instatus-page/tsconfig.json - Auth:
status-page/src/lib/auth.ts, configured viaSTATUS_PUBLIC,STATUS_USERNAME,STATUS_PASSWORDenv vars - Monitor config: YAML inline in
wrangler.tomlMONITORS_CONFIGenv var. Secrets interpolated via${ENV_VAR}syntax (src/utils/interpolate.ts).
Commands
Root (Worker)
npm run dev # wrangler dev
npm run test # vitest (20 test files)
npm run typecheck # tsc --noEmit
npm run check # typecheck + lint + format:check
npm run check:fix # auto-fix lint + format
npm run deploy # build:pages + wrangler deploy
npm run lint:strict # oxlint --deny warnings + eslint --max-warnings=0
vitest run src/path/to.test.ts # single test (no npx needed)
Pages workspace
npm run dev:pages # astro dev
npm run build:pages # astro build → status-page/dist/
npm run test:pages # vitest (3 test files)
npm run check:pages # astro check + tsc --noEmit + eslint
npm run lint:pages # eslint (astro plugin)
Verification order
Before commit: npm run check && npm run test && npm run build:pages && npm run check:pages
Gotchas
.jsextensions in imports: All worker imports use.jsextensions (import { foo } from './bar.js'). Required for ESM resolution withmoduleResolution: "bundler".- D1 requires bind parameters: Use
WHERE 1=?with.bind(1)for queries that would otherwise have no parameters. - Database naming: D1 columns are
snake_case, TypeScript properties arecamelCase. Map at query boundary. --legacy-peer-deps: Needed when installing Pages dependencies (@astrojs/checkdeclarestypescript@^5but project uses TypeScript 6).- Pages
dist/and.astro/: Build artifacts, gitignored. - Astro SSR build artifact: Worker dynamically imports
../status-page/dist/server/index.mjsat runtime — uses@ts-expect-error. - Astro 6 + @astrojs/cloudflare v13 workarounds:
status-page/astro.config.mjsincludesfixBuildRollupInputplugin andprerenderEnvironment: 'node'.
Code Style
- Formatting: Prettier — single quotes, semicolons, 100 char width, trailing commas ES5, no arrow parens.
- Linting: Oxlint (worker) + ESLint with
eslint-plugin-oxlintdedup. Pages useseslint-plugin-astro. - Types:
typefor aliases,interfacefor object shapes. Explicit return types. - Naming: files
kebab-case.ts, typesPascalCase, variablescamelCase, DB fieldssnake_case. - Tests:
*.test.tscolocated with source. Vitest withvifor mocks.