This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Deno-based HTTP server implementing the
Nx Custom Self-Hosted Remote Cache specification.
Uses Hono as the HTTP framework and S3-compatible storage (real AWS S3 in
production; emulate.dev for local dev/tests) as the cache
backend. Published as a multi-platform Docker image to
ghcr.io/ikatsuba/nx-cache-server.
# Start the local S3 emulator (emulate.dev AWS service on :4566, seeds nx-cloud bucket)
deno task emulate
# Development (watch mode, uses .env.local; expects `deno task emulate` running in another terminal)
deno task dev
# Production start (uses .env)
deno task start
# Unit tests (self-host the emulator, no external deps)
deno task test
# E2E tests (creates a real Nx workspace; self-hosts emulator + cache server)
deno task e2e
# Lint and format
deno lint
deno fmt --check
deno fmtSingle-file application (src/index.ts) built on Hono with typed bindings for
env vars and an S3Client context variable.
Request flow: S3Client init middleware -> Logger middleware -> Auth middleware (Bearer token) -> Route handler
Routes:
GET /health— health check (no auth)PUT /v1/cache/:hash— upload artifact to S3 (checks for duplicates with HeadObject, returns 409 on conflict)GET /v1/cache/:hash— download artifact via S3 presigned URL
Key pattern: The Hono app is exported separately from server startup
(if (import.meta.main)), allowing unit tests to call app.fetch() directly
with mock env bindings without starting a real server.
- Unit tests (
src/index.test.ts): Callapp.fetch()directly.beforeAllboots anemulate.devAWS service viascripts/start-emulator.ts;afterAllshuts it down. - E2E tests (
e2e/e2e.test.ts): Scaffold a full Nx React workspace viacreate-nx-workspace.beforeAllboots the emulator AND serves the cache server in-process on:3000(Deno.serve+ the exportedapp). Then runs builds and verifies cache miss then cache hit. Uses@david/daxfor shell commands.
Both suites are self-contained — no Docker, no separate deno task dev.
Required at runtime: AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
S3_BUCKET_NAME, S3_ENDPOINT_URL, NX_CACHE_ACCESS_TOKEN. Optional: PORT
(default 3000).
Local dev values are in .env.local (emulate.dev's seeded IAM defaults:
AKIAIOSFODNN7EXAMPLE / wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY, bucket
nx-cloud, endpoint http://localhost:4566).
GitHub Actions (.github/workflows/main.yml) runs on push/PR to main and
releases:
- checks:
deno lint+deno fmt --check - e2e: runs
deno task test+deno task e2edirectly (each suite self-hosts its dependencies) - publish (after checks + e2e pass): builds multi-platform Docker image (amd64/arm64) and pushes to GHCR
- Deno runtime (not Node.js) — use
deno.jsonfor deps, tasks, and config - Single quotes enforced via
"fmt": { "singleQuote": true }indeno.json - Dependencies use
npm:andjsr:specifiers in theimportsmap - Deno permissions are explicit per task (no
--allow-all)