简体   繁体   中英

node.js using domain driven design

I am in the process of moving an application from c# to node.js. I am learning node.js as I go along, so I am a node.js newbie. I am reading the book, Patterns, Principles and Practices of Domain Driven Design and found a lot of great information my current project could benefit from.

For instance, in the book, there is a sample e-commerce application that contains three bounded contexts: sales, shipping and billing. Each bounded context is responsible for its own database and each bounded context is running in an instance of NServiceBus. This seems to be a great approach as everything is running under the same solution, but different projects. In translating this to node.js, I am having a few areas of confusion.

1) I am having a rough time finding good examples that incorporate node.js with ddd like the e-commerce example above? Some of the hurdle here is the difference in how OOP is handled.

2) If in the book sample code, each bounded context is in its own project and runs within NServiceBus, would this mean that in translating this to node.js, I am using vscode as GUI, that I would need to create a separate parent folder(bounded context) for each project and supply a different port for each bounded context to listen on if I want all of the bounded contexts to run on the same server until I need to scale accordingly?

3) NServiceBus allows messages and events to get passed back ad forth. For node.js, what service bus technology, preferably open source and can run on linux-based machine, exists that would provide the kind of functionality NServiceBus provides and reliably? Should I just look at using rabbitmq alone to provide this functionality including sending events?

You might be interested in wolkenkit , a CQRS and event-sourcing framework for Node.js and JavaScript that plays very well together with domain-driven design (DDD).

Besides the actual framework (which is deployed as npm module wolkenkit ), there are a number of sample applications available that show how things work:

Apart from that you might want to take a look at the wolkenkit documentation , and there again especially at the brochure you can download which explains DDD, event-sourcing and CQRS, what they are, how they relate to each other, and so on…

PS: Please note that I am one of the authors of wolkenkit, so please take my answer with a grain of salt.

I would suggest going through the npm modules tagged with ddd:

and tagged with service bus:

There is also a JavaScript Domain-Driven Design book by Philipp Fehre.

This post is a couple of years old, but for anyone still interested there's a DDD framework for Typescript/node at:

https://github.com/node-ts/ddd

As well as an NServiceBus inspired message bus at:

https://node-ts.github.io/bus/

They're designed to work together to build message driven DDD systems with node

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM