covers:
- apps/api/**
API Worker
Overview
The API application is a Cloudflare Worker backed by Elysia. Cloudflare loads apps/…/index.ts as the Worker entrypoint through apps/…/wrangler.jsonc, whose main field points at src/index.ts and whose Worker name is opencut-api.
apps/…/index.ts exports a compiled Elysia app configured with CloudflareAdapter from elysia/adapter/cloudflare-worker. Request handling is currently defined directly in the entrypoint:
GET /returns{ status: "ok" }for a minimal liveness/status response.GET /healthreturns{ healthy: true, timestamp: new Date().toISOString() }, so the response timestamp is generated per request at the Worker edge.POST /echoreturns the parsed request body, but only after Elysia validates it againstt.Object({ message: t.String() }); requests whose JSON body does not contain a stringmessageare rejected by Elysia before the handler returns.
The final .compile() call in apps/…/index.ts triggers Elysia ahead-of-time compilation at startup, which the inline comment marks as required for this Worker setup. There is no application-owned persistence, queue, cache, or environment binding in apps/api/** at present; state is limited to per-request values such as the /health timestamp and /echo body.
Local development and deployment are driven by apps/…/package.json: bun run dev delegates to wrangler dev, bun run deploy delegates to wrangler deploy, and bun run build performs wrangler deploy --dry-run. apps/…/moon.yml registers the package as a TypeScript application project and wires Moon tasks to those package scripts; its build task treats src/**/*, wrangler.jsonc, and package.json as inputs.
Coupling
- If apps/…/index.ts moves or is renamed, update apps/…/wrangler.jsonc
main; Cloudflare will otherwise deploy a Worker whose configured entrypoint no longer exists. - If the Worker adapter or Elysia startup path in apps/…/index.ts changes, verify apps/…/wrangler.jsonc
compatibility_date; the config comment says2025-06-01is the minimum date required forCloudflareAdapterahead-of-time support. - If routes, request schemas, or runtime config files are added outside the current
apps/api/src/**/*, apps/…/wrangler.jsonc, or apps/…/package.json inputs, update apps/…/moon.yml so Moon rebuilds the Worker when those files change. - If the
/echorequest contract in apps/…/index.ts changes, update any clients or tests that rely on the body shape; Elysia validates the body before the handler echoes it, so schema drift changes which requests reach the handler at all.