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
0
770
#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
20
TypeScript - 45 minutes pour s’y mettre !
spontoreau
0
120
Event Sourcing avec Azure, quelle base de données choisir
spontoreau
0
36
Decorators in TypeScript 5.0, everything you need to know!
spontoreau
0
420
Leverage your CI/CD at the next level with Github actions
spontoreau
0
16
Commit comme un(e) "Hipster" avec Gitmoji !
spontoreau
0
110
Bird of a Feather - TypeScript (Devoxx 2022)
spontoreau
0
20
GitHub - Du besoin jusqu'à la production avec Github et Azure
spontoreau
0
20
Behavior Driven Development
spontoreau
1
220
Other Decks in Programming
See All in Programming
コードを読んで理解するko build
bells17
1
110
color-scheme: light dark; を完全に理解する
uhyo
7
490
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
250
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.2k
自力でTTSモデルを作った話
zgock999
0
100
sappoRo.R #12 初心者セッション
kosugitti
0
270
Amazon Q Developer Proで効率化するAPI開発入門
seike460
PRO
0
120
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
8
1.3k
推しメソッドsource_locationのしくみを探る - はじめてRubyのコードを読んでみた
nobu09
2
240
ナレッジイネイブリングにAIを活用してみる ゆるSRE勉強会 #9
nealle
0
160
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
14
4.6k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
BBQ
matthewcrist
87
9.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Become a Pro
speakerdeck
PRO
26
5.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
52k
Unsuck your backbone
ammeep
669
57k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Thoughts on Productivity
jonyablonski
69
4.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
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!