0:00 Let's make sure we go to our root index TS file 0:04 for our use cases, and in our command handler's 0:08 array, make sure we add our new confirm order 0:12 handler so that it will be wired into our NestJS application. 0:16 And now the last thing that we can do is wire in that event handler for the 0:20 order 0:20 confirmed event. Well, this is gonna be pretty straightforward as 0:24 we've 0:24 done before. Inside of order application 0:28 events, we can add our new 0:31 order confirmed handler.ts, 0:35 which will use events handler from NestJS CQRS, 0:40 pass through our order confirmed event, 0:44 and export class 0:48 order confirmed handler 0:51 that implements the I event handler. 0:56 Pass through the order confirmed event, and now we'll be 1:00 expected to implement the async handle method. 1:05 In our case, we really only need to get access to our 1:08 notification 1:09 service because we're gonna send an email to our internal shipping 1:12 department. So let's inject that dependency, 1:17 our notification service, which you know is using our port 1:20 and adapter 1:21 pattern so that we're not tied to a particular implementation here. 1:25 We don't care what the implementation is, we just want to emit the event. 1:30 And now in handle, it's exactly what we can do. 1:33 What I wanna do is extract all of the shipping details 1:37 using property destructuring here. 1:39 So we'll destructure the street, city, state, 1:43 zip code, and country 1:46 from event.shipping address. Finally, we can call 1:50 on notificationService.sendNotification. 1:54 Recipient ID, let's say we have a shipping 1:58 department at 2:01 clean shop.com, 2:05 a 2:06 example recipient, our internal shipping department. 2:10 And our subject, we'll say order 2:14 ready to ship, 2:17 and provide the message of order, 2:21 pass through the 2:23 event.orderID 2:25 has been paid 2:27 and is ready for shipment. 2:30 We can then include ship to 2:33 and provide all the shipping details that our department might need to actually
The rest of the transcript is for members.
Sign in