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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Sylvain PONTOREAU
September 10, 2019
Programming
920
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
65
TypeScript - 45 minutes pour s’y mettre !
spontoreau
0
150
Event Sourcing avec Azure, quelle base de données choisir
spontoreau
0
110
Decorators in TypeScript 5.0, everything you need to know!
spontoreau
0
510
Leverage your CI/CD at the next level with Github actions
spontoreau
0
69
Commit comme un(e) "Hipster" avec Gitmoji !
spontoreau
0
170
Bird of a Feather - TypeScript (Devoxx 2022)
spontoreau
0
46
GitHub - Du besoin jusqu'à la production avec Github et Azure
spontoreau
0
50
Behavior Driven Development
spontoreau
1
300
Other Decks in Programming
See All in Programming
ふつうのFeature Flag実践入門
irof
8
4.1k
Claspは野良GASの夢をみるか
takter00
0
200
AIで効率化できた業務・日常
ochtum
0
140
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
360
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
1B+ /day規模のログを管理する技術
broadleaf
0
100
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.8k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
270
C# and C++ Interoperability - cho-dotnetnew
harukasao
0
280
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.2k
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
Featured
See All Featured
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
260
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Chasing Engaging Ingredients in Design
codingconduct
0
220
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
Making Projects Easy
brettharned
120
6.7k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
430
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
850
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Un-Boring Meetings
codingconduct
0
320
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!