Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
0
880
#2 NestJS Paris meetup - NestJS & Event Store
NestJS & Event Store (CQRS & Event Sourcing)
Presenation made during NestJS Paris meetup.
Sylvain PONTOREAU
September 10, 2019
Tweet
Share
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
47
TypeScript - 45 minutes pour s’y mettre !
spontoreau
0
140
Event Sourcing avec Azure, quelle base de données choisir
spontoreau
0
66
Decorators in TypeScript 5.0, everything you need to know!
spontoreau
0
470
Leverage your CI/CD at the next level with Github actions
spontoreau
0
47
Commit comme un(e) "Hipster" avec Gitmoji !
spontoreau
0
150
Bird of a Feather - TypeScript (Devoxx 2022)
spontoreau
0
37
GitHub - Du besoin jusqu'à la production avec Github et Azure
spontoreau
0
36
Behavior Driven Development
spontoreau
1
270
Other Decks in Programming
See All in Programming
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
160
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
1.7k
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
630
JETLS.jl ─ A New Language Server for Julia
abap34
2
450
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
440
Tinkerbellから学ぶ、Podで DHCPをリッスンする手法
tomokon
0
140
Grafana:建立系統全知視角的捷徑
blueswen
0
190
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
190
Patterns of Patterns
denyspoltorak
0
310
AIコーディングエージェント(Gemini)
kondai24
0
270
愛される翻訳の秘訣
kishikawakatsumi
3
340
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
260
Featured
See All Featured
How to make the Groovebox
asonas
2
1.8k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
410
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
27
How Software Deployment tools have changed in the past 20 years
geshan
0
30k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Google's AI Overviews - The New Search
badams
0
870
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.4k
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!