The ticket created publisher is definitely now working.
So now we're going to go through this very similar process and we're gonna create a new publisher to
handle ticket.
Tickets being updated as well.
So again the very person we have to do is go into our events publishers directory.
We're gonna create a new file inside they're called Ticket updated publisher dot T.S. we could write
out all the code from this from scratch or alternatively we could just do a copy paste from ticket created
publisher lets us do the ticket or the copy paste just to save ourselves a little bit of time so go
to ticket created copy everything inside of you or go backward updated and paste and then inside of
here we'll go round and update the word created to updated instead so I'll do one update second update.
Third update
and fifth so we should not see the word created anywhere inside of here.
We should have five copies of updated ok once that's all done.
We'll save this and then going to go over to my roots directory I'll find the update handler so inside
of here we will import ticket updated publisher from up one directory events publishers ticket updated
publisher
and then we also need our client wrapper as well.
So we'll get Nat's wrapper from up Nat's wrapper
then down inside of our update handler right after we successfully do the save right after that that's
when we probably want to make sure that we met some kind of update event so we can do a new ticket updated
publisher we'll pass in our Nat's wrapper clients and we'll call publish and then typescript remember
is going to guide us on the different properties we need to add inside of here.
So we need to put in the idea that ticket title price and user I.D..
Once again the ideal the ticket.
Dot I.D. title is ticket.
Title
price and user I.D. and that should be at
let's save this we'll do a quick test of this as well.
So we don't really have anything to listen for this event.
I just want to make sure that we can send in a post or is me a put to update a given ticket go over
to our terminal and just verify makes sure we don't see any errors or anything like that coming out
of our ticket service.
So to do in updates are going to change my request type here to put I'm going to take the idea of the
ticket I just created in the last video and I'll add it onto the very end of that year El and then I'll
make a change to the price change it to say 10 so I'll send this off.
OK.
Looks like the update was successful.
I'll then go back over to my terminal.
I'll find scaffold and I should see event published to subject ticket colon update right there.
Which means that the event was successfully published.
Let's say it looks pretty good all right.
So everything at this point definitely works.
What we have right here it is a working implementation.
There are nonetheless one or two quick things I wanna mention.
One is something for your own benefit for projects you might work on on the future.
Just something to kind of get your mind running.
And the other is just something I want to mention around how it's kind of awkward right now to actually
publish an event.
So we have to create a new instance of the publisher we have to pass on the client and as kind of a
side effect of all this I want to also mention that if we open up yet another terminal window and go
into our ticket service and try to run our tests.
So NPM run tests.
We're probably gonna see all this stuff failing horribly because whenever we tried to test say the update
or new operations we don't actually have any running connection to nets and so we're gonna see a ton
of stuff inside here cannot access Nats client before connecting.
And so without doubt there's kind of a little bit of awkwardness around how we're actually publishing
events right now.
So quick pause right here.
Go over some of the site topics in just a moment.