This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Personal API at api.michi.onl built as a Cloudflare Worker. Aggregates data from multiple sources (GitHub, Wikipedia, blog, IMDb, Billboard, Hacker News, Steam) into a cached REST API with auto-generated OpenAPI 3.1 documentation.
pnpm install # Install dependencies
npm run dev # Local dev server at http://localhost:8787 (Swagger UI at /)
npm run deploy # Deploy to Cloudflare Workers
npm run cf-typegen # Regenerate TypeScript types after changing bindings in wrangler.jsoncNo test runner or linter is configured.
Framework stack: Hono (routing) + chanfana (OpenAPI schema generation) + Zod (validation) + Cheerio (HTML scraping)
Key pattern — OpenAPI endpoints: Each endpoint in src/endpoints/ is a class extending OpenAPIRoute from chanfana. It declares a schema property (Zod-based request/response validation) and a handle(c: AppContext) method. Routes are registered in src/index.ts.
Data fetching: src/fetchers/ contain standalone functions that call external APIs or scrape HTML. Endpoints compose these fetchers. External calls use Promise.allSettled to prevent cascading failures.
Caching: src/cache.ts provides a generic caching wrapper over Cloudflare KV (API_CACHE binding). Each endpoint has its own TTL (10 min–6 hours). Some endpoints conditionally cache only on successful results.
Timeline aggregation: GET /api/timeline merges events from 5 sources into a common TimelineEvent interface. src/normalize.ts deduplicates and filters to the last 90 days.
CORS: Configured in src/index.ts — allows https://www.michi.onl and localhost origins.
Defined in wrangler.jsonc:
GITHUB_USER,WIKI_USER,BLOG_FEED— plaintext varsGITHUB_TOKEN— optional secret for higher GitHub rate limitsAPI_CACHE— KV namespace binding
Types are in src/types.ts (Env, AppContext, TimelineEvent). Auto-generated binding types are in worker-configuration.d.ts.
Strict mode is on but noImplicitAny and strictNullChecks are off. noUncheckedIndexedAccess is enabled. JSON imports are supported (resolveJsonModule).