From 9b556ffe6c0c0528697e15f7f4f35107de212ce1 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Wed, 15 Jul 2026 02:08:17 -0400 Subject: Add Cloudflare Workers deployment target Split routes into a shared createApp() (src/app.ts) used by both the Node entry (src/index.ts) and a new Workers entry (src/worker.ts). Workers disallow runtime code generation, so scripts/compile-views.ts precompiles the Eta templates into src/views.generated.ts and rendering switches from renderAsync to the sync render. Static files move to public/static so Workers Static Assets can serve them; the Node build and serveStatic root are updated to match. Deploy with pnpm run deploy:cf, local dev with pnpm run dev:cf. Co-Authored-By: Claude Fable 5 --- cgithub/CLAUDE.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cgithub/CLAUDE.md') diff --git a/cgithub/CLAUDE.md b/cgithub/CLAUDE.md index 827cc3b..1bf4d88 100644 --- a/cgithub/CLAUDE.md +++ b/cgithub/CLAUDE.md @@ -13,6 +13,10 @@ pnpm run build # Run tests pnpm test + +# Cloudflare Workers: local dev and deploy +pnpm run dev:cf +pnpm run deploy:cf ``` ## Architecture @@ -20,10 +24,14 @@ pnpm test **Stack:** Hono (web framework) + Eta (templating) + TypeScript, bundled with esbuild **Source files:** -- `src/index.ts` - Hono routes and server setup (supports systemd socket activation via `LISTEN_FDS=1`) +- `src/app.ts` - Hono routes, shared by both entry points +- `src/index.ts` - Node server entry (supports systemd socket activation via `LISTEN_FDS=1`) +- `src/worker.ts` - Cloudflare Workers entry (config in `wrangler.jsonc`) - `src/scraper.ts` - GitHub HTML fetching and JSON extraction logic -**Templates:** `views/*.eta` - Eta templates with layout inheritance (`layout.eta` as base) +**Templates:** `views/*.eta` - Eta templates with layout inheritance (`layout.eta` as base). On Workers, runtime code generation is disallowed, so `scripts/compile-views.ts` precompiles templates to `src/views.generated.ts` (gitignored, regenerated by the `dev:cf`/`deploy:cf` scripts). + +**Static files:** `public/static/*`, served by `@hono/node-server` on Node and by Workers Static Assets on Cloudflare. **Routes:** - `GET /:owner` - User or organization profile with pinned repositories -- cgit v1.3.1