API runtime
The API worker is a Hono service in apps/api. It runs on Cloudflare Workers
with D1 as durable storage and Vectorize for semantic retrieval.
Scripts
Section titled “Scripts”pnpm --filter api-worker devpnpm --filter api-worker buildpnpm --filter api-worker deploypnpm --filter api-worker cf-typegenRun cf-typegen after changing wrangler.jsonc so Worker binding types stay in
sync with Cloudflare resources.
Cloudflare resources
Section titled “Cloudflare resources”Create production resources before deploying a real environment:
wrangler d1 create memo-stwrangler vectorize create memo-st-memory --dimensions 1536 --metric cosineThen update apps/api/wrangler.jsonc with the D1 database ID and apply
migrations:
wrangler d1 migrations apply memo-st --localwrangler d1 migrations apply memo-st --remoteRuntime behavior
Section titled “Runtime behavior”- D1 stores memory records and metadata.
- Vectorize stores embeddings when callers provide
embedding. ctx.waitUntil()is used for Vectorize upserts so the API can acknowledge the durable D1 write quickly.- CORS allows
https://memo.st,http://localhost:3000, andhttp://localhost:3001.