Code Monkey home page Code Monkey logo

nest-cqrs-example's People

Contributors

kamilmysliwiec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nest-cqrs-example's Issues

DDD approach in Nest CQRS

Since events, commands and models related to the business logic are part of the domain layer, they should remain framework-agnostic, but most tools in this plugin are decorators that you apply to directly in the domain layer or classes that you need to extend. What would be the best approach to separate the domain layer and move the plugin's mechanics to the application/infrastructure layer?

Is this really CQRS? No separation between Command and Query domains.

CQRS (but not necessarily CQS) typically implies that you maintain a completely separate domain model for your Command side and your Query side.

With that in mind, this example seems to be leading people astray and doesn't really communicate the essence of CQRS.

Reason being, the command handlers and the query handlers in this example repo are both using the same domain model.

Shared Domain Model

model

Repo for the Domain Model

repo

Command Handler

command

Query Handler

query

I would love to see this example repo updated to give a more realistic depiction of how to utilize CQRS and DDD patterns. I understand that this was put together primarily for giving a brief conference talk, but I think there's really a missed opportunity for education here.

As it stands now, Nest's attempt to steer people towards CQRS/DDD/reactive patterns seems to just cause confusion and raise more questions than it actually answers. Which is a shame, because Nest really seems primed to be a leader in this space.

Not sure if services are still relevant in cqrs

Very nice sample and very nice, neat and consice cqrs implementation !

In the sample it is suggested that still controller - service pipeline is useful.

I think that the whole idea of cqrs is among others, to give the aggregate root a more central place in favor of attached services.

I would simply call directly the command from the controller and remove the service.

Opinion on how to plugin persistance

Hi,

Thanks for providing such a starting point, this sample is a good starting point for cqrs implementation w/ nestjs.

However it covers only the "read side" of the pattern (repository findone). It is not clear to me as to where one should plugin the "write side". My understanding is that the aggregate root does all the logic, modifying the model and raises relevant events to notify subscribers. The persistence can then be triggered in either the command (just after the invocation of the root aggregate method) or in dedicated event handlers.

The drawback I see with the event handler is that the command returns before persistence is ran and therefore can lead to consistency issues. The drawback I see with invoking persistence from command is that it is not very SOLID.

What would be your opinion on this?

Rgds

Add sample logic

Can someone add logic to command handler, event handler and model ?

client-side example

Hi, exploring your framework.
Do you have a pointer to a client-side example, ie: querying and sending commands from the client?
Thanks

Another Aggregate Root

First off, awesome repo!

One thing I would like to see is how you handle more aggregate roots?

Do they each get their own folder like hero?

Naming inconsistency

CQRS exposes 3 decorators and 3 interfaces. All of them are singular form, except one:

CommandHandler
ICommandHandler

QueryHandler
IQueryHandler

EventsHandler
IEventHandler

I think it should be EventHandler

Maybe you can change this during next breaking change release

UUID do not define a '.' subpath

I have downloaded this example, when I try to start the application with npm start I get the following error

Error: Package exports for ...\node_modules\@nestjs\common\node_modules\uuid' do not define a '.' subpath
    at resolveExports (internal/modules/cjs/loader.js:419:17)
    at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
    at Function.Module._load (internal/modules/cjs/loader.js:693:27)
    at Module.require (internal/modules/cjs/loader.js:864:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (...\node_modules\@nestjs\common\decorators\core\injectable.decorator.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)
    at Module.load (internal/modules/cjs/loader.js:822:32) {

OS: Windows 10
Node 13.0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.