0:00 All right, so let's go ahead and head into our order service, where now 0:04 we're ready to add our presentation layer, which will 0:08 allow us to expose our orders domain model over 0:12 a 0:14 presentation layer like a client. 0:16 So that's a UI, a REST HTTP con-controller, 0:22 GraphQL. Really any implementation that's gonna 0:25 translate the inner 0:26 workings of the domain model to a consumer. 0:28 And again, we wanna keep this fully decoupled from 0:30 both the domain and the 0:32 application layer as much as we can, and we're gonna use CQRS 0:36 for this 0:39 as we've done so far. 0:42 So inside our presentation, we can create the new 0:45 OrderController.ts, 0:47 and we're gonna go ahead and mark this new controller with the 0:51 @controller decorator and call it orders. 0:55 And we'll export class OrderController. 1:01 And in here, let's go ahead and start off by adding our 1:04 constructor where we know we want to inject both our 1:08 command bus, which we're gonna use to issue commands 1:11 for 1:12 application, which we know our command handlers will 1:14 then listen for. 1:16 And we have the corresponding query bus for any reads as well. 1:20 So we'll add this, and now we are ready to dispatch events. 1:23 So let's go ahead and start off with the post route to 1:26 create a new order. 1:28 And again, we'll talk about this in the language of 1:30 the domain. 1:30 So in our case, well, we know orders are placed by our 1:34 users, and so we'll create an async place method 1:38 for 1:38 the presentation layer, where we'll go ahead and access the 1:42 incoming request body with the @body decorator. 1:46 And now we need to define the DTO, which is going to be the data 1:49 that this will 1:50 take in to, to place this new order. 1:54 So we'll do our HTTP level validation as well using Class
The rest of the transcript is for members.
Sign in