To install dependencies:
macOS & Linux
curl -fsSL https://bun.com/install | bash
Windows
powershell -c "irm bun.sh/install.ps1|iex"
Package Managers
npm
npm install -g bun # the last `npm` command you'll ever need
Homebrew
brew install oven-sh/bun/bun
bun installTo run:
bun run devレイヤードアーキテクチャ
src/
├── index.ts # App Entrypoint(エントリーポイント)
│
├── features/ # 【機能別スキーマ層】OpenAPI定義・バリデーション
│ └── auth/
│ └── auth.schema.ts # 認証APIのスキーマ定義(Zod + OpenAPI)
│
├── interface/ # 【HTTP層】コントローラー・ルーティング
│ ├── auth.controller.ts # 認証エンドポイント
│ └── user.controller.ts # ユーザーエンドポイント
│
├── usecases/ # 【ロジック層】ビジネスロジック
│ ├── auth.usecase.ts # 認証ロジック(JWT発行など)
│ └── user.usecase.ts # ユーザー操作ロジック
│
├── infrastructure/ # 【DB層】データアクセス
│ └── repositories/ # リポジトリパターン
│ └── user.repository.ts # ユーザーデータアクセス
│
├── domain/ # 【ドメイン層】型定義・ビジネスモデル
│ └── models/
│ └── user.model.ts # ユーザーモデル型定義
│
└── utils/ # 【ユーティリティ層】共通処理
└── hash.util.ts # パスワードハッシュ化など
開発サーバーを起動後、ブラウザで以下にアクセス:
http://localhost:30001/ui
Swagger UIで以下が確認できます:
- すべてのAPIエンドポイント一覧
- リクエスト/レスポンスのスキーマ
- 「Try it out」ボタンで実際にAPIをテスト可能
- OpenAPI仕様書(JSON): http://localhost:30001/doc
- ヘルスチェック: http://localhost:30001/health