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
#2 NestJS Paris meetup - NestJS & Event Store
Search
Sylvain PONTOREAU
September 10, 2019
Programming
930
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
#2 NestJS Paris meetup - NestJS & Event Store
NestJS & Event Store (CQRS & Event Sourcing)
Presenation made during NestJS Paris meetup.
Sylvain PONTOREAU
September 10, 2019
More Decks by Sylvain PONTOREAU
See All by Sylvain PONTOREAU
aMS Lausanne - Préparez-vous à une virée intersidérale avec Azure Cosmos DB 🧑🚀
spontoreau
0
72
TypeScript - 45 minutes pour s’y mettre !
spontoreau
0
160
Event Sourcing avec Azure, quelle base de données choisir
spontoreau
0
120
Decorators in TypeScript 5.0, everything you need to know!
spontoreau
0
520
Leverage your CI/CD at the next level with Github actions
spontoreau
0
73
Commit comme un(e) "Hipster" avec Gitmoji !
spontoreau
0
170
Bird of a Feather - TypeScript (Devoxx 2022)
spontoreau
0
55
GitHub - Du besoin jusqu'à la production avec Github et Azure
spontoreau
0
52
Behavior Driven Development
spontoreau
1
310
Other Decks in Programming
See All in Programming
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.7k
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
590
プロポーザルを書いてもらう
pvcresin
0
280
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
350
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
1
250
Built Our Own Background Agent at LayerX
layerx
PRO
9
5k
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
150
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.5k
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
150
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
670
AIが無かった頃の素敵な出会いの話
codmoninc
1
390
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Building Applications with DynamoDB
mza
96
7.2k
Statistics for Hackers
jakevdp
799
230k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Utilizing Notion as your number one productivity tool
mfonobong
4
520
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
620
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
360
GraphQLとの向き合い方2022年版
quramy
50
15k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Transcript
September 10, 2019 | NestJS Paris | Sylvain Pontoreau NestJS
& Event Store
Formerly Microsoft In ❤ with Co-organizer Who I am? @spontoreau
Paris TypeScript @ParisTypeScript www.typescript.paris
Domain Driven Design • DDD is not a Framework nor
a Methodology… • … it's an approach to dealing with complexity • DDD focusing: • The domain representation • The domain logic • Technical aspects are secondary • Just a part that enforcing the domain
Opposite of Data Driven Development Data Driven Development Domain Driven
Design != Data structure Entity Relationship CRUD Behavior Bounded Context Event
Query Just a read operation Command Data validation Business logic
Persistence CQRS
CQRS GetBookById Query CreateBook Command GetAllBook Query DeleteBook Command …
… Dispatcher Read DB Dispatcher QueryHandler CommandHandler Write DB Validation Plugin Monitoring Plugin Telemetry Plugin … Eventual consistency
https://martinfowler.com/eaaDev/EventSourcing.html Event Sourcing
Event Sourcing & CQRS
CQRS & Event Sourcing GetBookById Query CreateBook Command GetAllBook Query
DeleteBook Command … … Dispatcher Read DB Dispatcher QueryHandler CommandHandler Event Store Projection Projection AggregateRoot State Events
Our focus in this talk GetBookById Query CreateBook Command GetAllBook
Query DeleteBook Command … … Dispatcher Read DB Dispatcher QueryHandler CommandHandler Event Store Projection Projection AggregateRoot State Events
NestJS, Commands, Aggregates & Events Command Bus EventBus EventPublisher Repository
CommandHandler Controller/Service Aggregate Execute Comand Execute Handler Get Aggregate Merge Aggregate Apply events Execute behaviors IEventPublisher Publish events DefaultPubSub Default implementation EventHandler EventStore Publisher
Custom EventPublisher & MessageSource import { IEvent } from './event.interface';
export interface IEventPublisher { publish<T extends IEvent>(event: T); } import { Subject } from 'rxjs'; import { IEvent } from './event.interface'; export interface IMessageSource { bridgeEventsTo< T extends Ievent >(subject: Subject<T>); } • IEventPublisher • MessageSource export class UserModule implements OnModuleInit { constructor( private readonly eventBus: EventBus, private readonly eventStorePublisher: EventStorePublisher ) {} onModuleInit() { this.eventBus.publisher = this.eventStorePublisher; } } • Module
Which database for storing events? Choose what you want! Please
try me!!!
Event Store, the stream database https://eventstore.org
Demo
Resources • CQRS & Event Sourcing • CQRS pattern: https://docs.microsoft.com/en-US/azure/architecture/patterns/cqrs
• Event Sourcing pattern: https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing • Tackle business complexity in a Microservice with DDD and CQRS: https://docs.microsoft.com/en- us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/ • NestJS CQRS module: https://docs.nestjs.com/recipes/cqrs • Event Store website: https://eventstore.org • Talk’s sample: https://github.com/spontoreau/nestjs-eventstore-demo • node-eventstore-client NPM package: https://github.com/nicdex/node-eventstore-client • gereventstore-pomise NPM package : https://github.com/RemoteMetering/geteventstore-promise • Jérôme Rouaix presentation on CQRS & ES: https://gitpitch.com/jrouaix/cqrs-es-presentation/master#/ • Arnaud Lemaire talk on CQRS, ES and DDD: https://www.youtube.com/watch?v=qBLtZN3p3FU • Greg Young, A decade of DDD, CQRS and ES: https://www.youtube.com/watch?v=LDW0QWie21s
Questions?
Thank you!