We're now going to move on to our common service.
We need to make sure that any time someone creates new comment we once again emit an event over to that
event bus.
In this case our event is going to look a little something like this.
They'll have a type of comic created and the data in this case will be the actual comment itself.
So once again we're going to send this over to the event bus and the event bus is going to echo so to
speak.
This event over to all of our different services we're going to once again see that we're going to get
a couple of forum for errors because again we don't have anything on the services themselves to receive
these events just yet.
All right.
So going to change back over to my editor I'm going to find the comments service folder.
Here it is right here.
Inside there I'll open up the index such as file at the very top.
I'll get access
all then go down to my code where I'm creating a new comment.
Here it is right here
I'll then add in right after we add in that new comment right there or we push it into that.
Right about right after that's really where we kind of save.
So to speak the comments.
I'll go ahead and we'll add in the axial stop post to local host colon four thousand and five flash
events and once again the data or the event they were gonna send over is going to have a type of something
like comment created and a data property that's gonna be the actual comment itself to remember a comment
is going to have the comment tidy some content and then in that case or in this case that is the entire
comment.
Well we're going to also add into this data property another property of post I.D. just to clarify exactly
what comment this thing is tied to in this case for data.
I'm going to put in the I.D. of comment I.D. the content and then finally our post I.D. as well which
is available inside this request handler.
Remember it's technically in that parameter string right there or the root string.
So we can access that using rec perhaps dot I.D. We'll say post I.D. is rec not prams dot I.D. then
once again I'm going to add on async to the wrapping function and awaits on the request itself.
OK.
ALEX Good.
So let's test this out again.
I'm going to flip on over to my browser to find the post we had just created.
And I'll add in some comments and submit it's I can refresh the page see some comments here.
And then finally I'll go over to my terminal and I'm going to expect to once again see a series of 4
4 errors coming out of our event bus.
Again that's because we don't have anything inside of our services yet to actually receive these events
yet.
That looks good.
Well at this point time we've now got two services that are emitting events whenever something interesting
happens.
So now we need to make sure that all of our services right now really just posting comments because
we've not yet created the query service as an endpoint where it can receive these events and then do
some processing on them.
If that service cares about the event that was just emitted in our scenario or in our case right now
our postal service and the common service don't really care whatsoever.
They just don't care about any incoming events out of the two that we've created common created and
post created.
But as soon as we make this query service Well we're definitely going to have something that is very
much interested in some events that are coming out of our application so quick pause right here.
We're going to start putting this and this those two event person who wrote handlers together in just
a moment.