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
920
0
Share
#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
60
TypeScript - 45 minutes pour s’y mettre !
spontoreau
0
150
Event Sourcing avec Azure, quelle base de données choisir
spontoreau
0
100
Decorators in TypeScript 5.0, everything you need to know!
spontoreau
0
490
Leverage your CI/CD at the next level with Github actions
spontoreau
0
66
Commit comme un(e) "Hipster" avec Gitmoji !
spontoreau
0
160
Bird of a Feather - TypeScript (Devoxx 2022)
spontoreau
0
43
GitHub - Du besoin jusqu'à la production avec Github et Azure
spontoreau
0
44
Behavior Driven Development
spontoreau
1
290
Other Decks in Programming
See All in Programming
Back to the roots of date
jinroq
0
600
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
160
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
940
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
1
540
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
230
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
2
370
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.1k
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
940
書き換えて学ぶTemporal #fukts
pirosikick
1
310
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
240
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
990
Firefoxにコントリビューションして得られた学び
ken7253
2
150
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
560
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
Color Theory Basics | Prateek | Gurzu
gurzu
0
300
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
680
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
270
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
190
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
HDC tutorial
michielstock
2
650
Site-Speed That Sticks
csswizardry
13
1.2k
Marketing to machines
jonoalderson
1
5.2k
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!