Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TypeScriptでDDD〜RepositoryとEntity編〜
Search
Shinse Tanaka
April 30, 2017
Programming
3.8k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypeScriptでDDD〜RepositoryとEntity編〜
We Are JavaScripters! @6th
https://wajs.connpass.com/event/54667/
Shinse Tanaka
April 30, 2017
More Decks by Shinse Tanaka
See All by Shinse Tanaka
PrimeNGという選択肢について
mrdshinse
0
820
Other Decks in Programming
See All in Programming
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
530
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
330
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
140
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
580
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
220
どこまでゆるくて許されるのか
tk3fftk
0
490
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
230
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
0
270
5分で問診!Composer セキュリティ健康診断
codmoninc
0
280
共通化で考えるべきは、実装より公開する型だった
codeegg
0
250
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
150
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
3
1.5k
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Navigating Weather and Climate Data
rabernat
0
370
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
600
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Ethics towards AI in product and experience design
skipperchong
2
330
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
370
The Invisible Side of Design
smashingmag
301
52k
Transcript
TypeScriptでDDD RepositoryとEntity編
自己紹介 ・不動産Techで働いてます。 ・Java/Scala/Ruby + ちょっとjs ・Web↔SI双方の技術を高めたい ・Node.js / TypeScriptでDDDしてみたい モチベーション
@mrdShinse @Shinse Tanaka
None
話すこと
https://github.com/mrdShinse/eve-linebot
ディレクトリ構成 ./app/application →アプリ起動時の設定やドメイン処理に 必要な前処理などを書く。 今回だとExpress.jsの起動。 ./domain →アプリケーションが解決したい問題や 業務の処理を書く。 ./infra →各レイヤーを実装するために必要な
具体的処理が書かれる。 今回だとMongo関係の処理。
ドメインとライブラリ依存を切り離したい
domainパッケージ
エンティティの定義 User →Entityとして定義。 nameはValueObject として定義する。
リポジトリ用読み書きインターフェース
ユーザーリポジトリの定義
domainパッケージにはmongoの処理を入れない! 続いてinfraパッケージ
Mongoリポジトリ共通親クラス
ユーザーリポジトリ
いい感じに
所感 ・TypeScriptのGenericsはいい ・TypeScriptでちゃんと設計してあげる事で・・・ (jsでそれ必要?という議論はあるがw) ・エンジニアの技術力の差を吸収することができる。 ・仕様の変更や依存ライブラリの変更に強くなる ・結果として、Node.jsで業務寄りなプログラムを書きやすくなる。 ・mongooseだとdomainとinfraの切り分けはできない・・・?``` ・DDDで書きやすいライブラリは未整備な状態。