How to ship a Cloudflare Worker API with D1 backing
언제 쓸까: You want a small JSON API with auth and persistence, deployed to Cloudflare.
흐름
-
ScaffoldUse the Cloudflare skill. New Worker with D1 binding, Hono router, routes: GET /todos, POST /todos, DELETE /todos/:id.✓ 복사됨→ Worker code + wrangler.toml + schema.sql
-
AuthAdd bearer token auth using a secret in env.✓ 복사됨→ Middleware + wrangler secret put instructions
-
Deploywrangler d1 execute + wrangler deploy steps.✓ 복사됨→ Live URL after deploy
결과: A deployed Worker API with D1 persistence.
함정
- D1 migrations drift between envs — Use wrangler d1 migrations create + apply; don't ad-hoc exec