Our clients lied application is now looking pretty good.
We've got the full gamut of authentication stuff running inside of here.
A sign and sign ups sign out and so on.
It's now going to start to move on to our next service before we do it.
However you may have a quick question you might say hey Stephen we have not really done any event related
stuff around our auto service.
Remember all of our micros services communicate using events.
We have not implemented any events or anything like that inside our cluster so far.
So as it turns out our auth service really doesn't have a whole lot to communicate to our other services
inside of our cluster.
Yes we could limit events like say sign up or sign in or stuff like that but there's no other services
that we are going to have inside of our cluster that are ever going to make use of those events.
So we're not gonna worry about any event related stuff or the off service as a matter of fact all the
actual stuff that the off service really does is being communicated through that Jason web token.
So that's how the all service kind of somewhat communicates with other services.
It's really by setting that Jason web token inside the user's cookie.
So in this video we're going to start to work on our next big service.
So what service are we going to work on next.
Well it's going to be the ticketing service or the ticket service the gold the ticket service is going
to be to list all the different tickets that have been created inside of our application and all the
tickets that are for sale.
We want to have the ability to show details about a very particular ticket we want to create a ticket
and edit a ticket.
So these are all some pretty basic root handlers.
We're going to list up show a particular record create a record and edit a record ticket service is
definitely going to need to have some event related stuff.
So as soon as we get some kind of basic groundwork put together for the ticket service then we're going
to start implementing that event plus stuff inside of our cluster.
All right.
Now as we start to think about these different routes right here specifically it create a ticket and
edit a ticket.
There's one quick thing I want to mention chances are that whenever someone comes to our service and
tries to create a ticket or edit one we probably want to make sure that this user is logged in.
So in other words we're going to require authentication for a user to create or edit a ticket.
That seems like a very reasonable requirement.
Right.
Let's think about the impact that's gonna have on our ticket service.
That means that our ticket service is probably going to need to have some kind of middleware inside
of it to make sure that the user is authenticated so inspect the cookie pull out that Jason web token
validate the token and so on.
We'll probably implement that inside of a middleware and we'll probably want to have that run before
we ever send that thing off to a root handler.
Now does that sound familiar.
Does this require off middleware.
Sound familiar you might recall that we kind of put something together inside of our auto service.
Very very similar to that.
You might recall inside that middleware directory we've got this require all middleware right here.
It's certainly very easy implementation but without a doubt we already wrote out something like this
as he starts also think about that require off middleware inside the ticket service if a user is not
signed in.
Chances are we're going to want to throw some kind of error maybe you like a not authorized error or
something like that and have that error somehow get captured by our Express application turned into
some error message and then sent back to whoever made the request.
So something very similar for example to maybe this not authorized error that we already put together
inside of our auto service.
So I think you might be seeing where I'm going with this.
It turns out that we've got a lot of functionality already created inside of our auto service that we
need inside the ticket service.
And so the first thing we're going to do before even worrying about putting together the ticket service
we're going to go back to our auto service and we're gonna start to extract a ton of logic from it.
We're going to pull out that entire custom error system.
We're going to pull out some of the different middleware as we put together and we're going to pull
out some of that request validation stuff as well.
We're gonna pull all this out into a shared library that we're going to then start to use between all
of our different services.
And this is going to dramatically decrease the amount of time it takes together it takes to put together
our ticket service the ticket service in general is going to come together so much more quickly than
the time that we spent on our service because all of this kind of core foundational stuff has already
been written and all we really need to do is make sure that we can use it in both of these different
services okay.
So that's the first thing we're going to be working on we're going to extract a lot of the shared logic
into a shared library and then make sure that we can use this library inside of our different services.
So with that might quick Basra here and let's get started in the next video.