Hono.js + TypeScript로 엣지 REST API 만들기 — Cloudflare Workers
Hono v4 + Bun 1.3 + Zod v4로 타입 안전한 REST API를 직접 만들었다. 라우팅 정의, Zod 기반 입력 검증, CORS·logger·timing 미들웨어, Cloudflare Workers 배포 설정까지 실전 코드와 터미널 로그를 포함한 단계별 가이드.
jangwook.net
Personal technical notes on AI agents, automation, developer tools, and the process of building software.
Latest Notes
The root page stays intentionally small. Choose a language, then read the full archive and related posts there.
AI 에이전트, 자동화, 개발 도구, 소프트웨어 제작 과정을 한국어로 기록합니다.
Hono v4 + Bun 1.3 + Zod v4로 타입 안전한 REST API를 직접 만들었다. 라우팅 정의, Zod 기반 입력 검증, CORS·logger·timing 미들웨어, Cloudflare Workers 배포 설정까지 실전 코드와 터미널 로그를 포함한 단계별 가이드.
Zod v4 safeParse()와 변경된 스키마 API로 Claude API 응답을 타입 안전하게 파싱하는 패턴을 직접 검증했다. v3 대비 성능 수치, z.string().check() 신규 API, 중첩 스키마 설계 전략을 Claude API 통합 코드와 함께 정리한다.
Vitest 4.1.7로 Anthropic SDK messages.create()와 스트리밍 응답을 모킹하는 실전 패턴. vi.fn()과 화살표 함수 차이, async function* 제너레이터로 SSE 스트림을 재현해 9개 테스트를 142ms에 통과시키는 방법을 안내한다.
Personal notes on AI agents, automation, developer tools, and building software.
I built a type-safe REST API with Hono v4, Bun 1.3, and Zod v4. This guide covers routing, Zod input validation, CORS/logger/timing middleware, and Cloudflare Workers deployment config — with real terminal logs and step-by-step code.
I tested Zod v4 safeParse() and the updated schema API with Claude API responses to build type-safe LLM output pipelines. Here: v3 performance comparison, the new z.string().check() API, nested schema design, and error handling patterns for production use.
I verified practical patterns for mocking Anthropic SDK messages.create() and streaming responses in Vitest 4.1.7. This covers why vi.fn().mockImplementation(function(){...}) differs from arrow functions, how to reproduce SSE streams with async function* generators, and how 9 tests pass in 142ms without a single API call.
AIエージェント、自動化、開発ツール、ソフトウェア開発の記録です。
Hono v4 + Bun 1.3 + Zod v4 で型安全な REST API を実際に構築した。ルーティング定義・Zod 入力バリデーション・CORS/logger/timing ミドルウェア・Cloudflare Workers デプロイ設定まで、実際のターミナルログと実行コードで解説する。
Zod v4のsafeParse()と変更されたスキーマAPIでClaude API応答を型安全にパースするパターンを実際に検証した。v3比の性能数値、z.string().check()新API、ネストスキーマ設計戦略をClaude API統合コードとともに整理する。
Vitest 4.1.7でAnthropic SDKのmessages.create()とストリーミングレスポンスをモッキングする実践パターンを直接検証した。vi.fn().mockImplementation(function(){...})がアロー関数と異なる理由、async function*ジェネレーターでSSEストリームを再現する方法まで、9テストが142ms以内に通過する過程をステップバイステップで解説する。
记录 AI 代理、自动化、开发工具和软件构建过程。
我用 Hono v4、Bun 1.3 和 Zod v4 实际构建了一个类型安全的 REST API。本文涵盖路由定义、Zod 输入验证、CORS/日志/计时中间件,以及 Cloudflare Workers 部署配置——包含真实终端日志和分步骤代码示例。
通过实际测试Zod v4的safeParse()和更新的schema API处理Claude API响应,构建类型安全的LLM输出解析方案。涵盖v3性能对比、z.string().check()新API、嵌套schema设计策略和生产级错误处理模式。
我在 Vitest 4.1.7 中直接验证了模拟 Anthropic SDK messages.create() 和流式响应的实战模式。涵盖 vi.fn().mockImplementation(function(){...}) 与箭头函数的区别、用 async function* 生成器重现 SSE 流的方法,以及 9 个测试在 142ms 内通过的完整过程。