Introducing a new way to review your PRs.

Read the announcement

opencut-app / opencut

The open-source CapCut alternative

View on GitHub

12 documents · Updated Nov 16, 2026

docs / api-worker


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 /health returns { healthy: true, timestamp: new Date().toISOString() }, so the response timestamp is generated per request at the Worker edge.
  • POST /echo returns the parsed request body, but only after Elysia validates it against t.Object({ message: t.String() }); requests whose JSON body does not contain a string message are 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 says 2025-06-01 is the minimum date required for CloudflareAdapter ahead-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 /echo request 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.