0:00 All right, so now we're ready to actually implement 0:02 the logic for registering a new 0:04 user in our application. 0:06 So for this, we're gonna create a new use case to 0:09 handle this with 0:10 a new command for our NestJS CQRS command bus 0:14 to listen for it and then execute the logic, keeping our 0:17 presentation layer fully decoupled from the application. 0:22 So for this, in our customer's application folder, 0:25 let's create a 0:26 new use cases directory. And inside of here, we'll add our 0:30 first use case, which are gonna be our commands 0:33 or writes for the 0:34 application. We'll add the new register customer use 0:37 case. And now inside of here, we can create the register 0:42 customer command, which is gonna be the definition 0:45 for the application layer parameters for this handler. 0:49 And then we can also create the register customer handler, which will be 0:53 listening for these events and actually implement the logic 0:57 of orchestrating our domain model and 1:00 triggering the creation. And so in our register customer command, 1:04 let's now define the parameters we need to create this customer. 1:08 And again, we're defining this separately bec- 1:10 because we don't want the 1:11 application layer to rely on a 1:15 lower level dependency, in this case, the presentation. 1:18 And so this is why we wanna define our own type for the application layer, so 1:22 we can 1:24 encapsulate it from any changes to that more volatile part of 1:28 our application, which we will see later on 1:30 is gonna become critical when we 1:32 add a different presentation layer like GraphQL. 1:35 So in this register customer command, let's redefine the properties we know we 1:39 need 1:39 to create the new user. So that will be the email, 1:44 first name, 1:45 and the last name. So now we have the register customer 1:49 command complete, we can actually start implementing the
The rest of the transcript is for members.
Sign in