型でドメインモデルを表現する - #92
Draft
Ojoxux wants to merge 1 commit into
Draft
Conversation
- app/types/domain.ts を新規追加 - Brand<T, B> ユーティリティ型 - UserId, BookId, TagId, SessionId のブランド型 - OAuthProvider, BookStatus, BookSortOrder の単一定義元 - 全レイヤーでブランド型を使用 - DB リポジトリ: UserId/BookId/TagId を引数型に使用 - セッション: createSession が UserId を受け取り SessionId を返す - 認証ミドルウェア: UserId で統一 - マッパー: crypto.randomUUID() を BookId/TagId にキャスト - API ハンドラー: URL パラメータ境界で as BookId 等でキャスト - 重複を解消 - OAuthProvider: types/api.ts と schemas/auth.ts で domain から再エクスポート - BookStatus: database.ts で domain から再エクスポート、domain/book.ts も同様 - テストヘルパーと全テストファイルをブランド型に対応 Co-authored-by: Jou Okuyama <Ojoxux@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Branded Typesでドメインモデルを表現し、ID やステータスなどの概念を型レベルで区別できるようにしました。
app/types/domain.tsを追加し、UserId/BookId/TagId/SessionId、OAuthProvider、BookStatus、BookSortOrderを単一定義元に集約OAuthProviderとBookStatusの重複定義を解消確認
pnpm typecheck成功pnpm lintエラーなし(既存 warning のみ)補足
as BookId等のキャストを行い、アプリ内部では型安全性を担保しています