1 00:00:01,290 --> 00:00:03,390 Our clients lied application is now looking pretty good. 2 00:00:03,390 --> 00:00:06,510 We've got the full gamut of authentication stuff running inside of here. 3 00:00:06,640 --> 00:00:09,380 A sign and sign ups sign out and so on. 4 00:00:09,380 --> 00:00:13,470 It's now going to start to move on to our next service before we do it. 5 00:00:13,490 --> 00:00:18,150 However you may have a quick question you might say hey Stephen we have not really done any event related 6 00:00:18,150 --> 00:00:20,190 stuff around our auto service. 7 00:00:20,190 --> 00:00:23,310 Remember all of our micros services communicate using events. 8 00:00:23,310 --> 00:00:27,310 We have not implemented any events or anything like that inside our cluster so far. 9 00:00:28,140 --> 00:00:33,780 So as it turns out our auth service really doesn't have a whole lot to communicate to our other services 10 00:00:33,780 --> 00:00:35,170 inside of our cluster. 11 00:00:35,190 --> 00:00:40,470 Yes we could limit events like say sign up or sign in or stuff like that but there's no other services 12 00:00:40,470 --> 00:00:44,400 that we are going to have inside of our cluster that are ever going to make use of those events. 13 00:00:44,490 --> 00:00:49,050 So we're not gonna worry about any event related stuff or the off service as a matter of fact all the 14 00:00:49,050 --> 00:00:53,940 actual stuff that the off service really does is being communicated through that Jason web token. 15 00:00:54,360 --> 00:00:58,580 So that's how the all service kind of somewhat communicates with other services. 16 00:00:58,620 --> 00:01:03,020 It's really by setting that Jason web token inside the user's cookie. 17 00:01:03,090 --> 00:01:06,900 So in this video we're going to start to work on our next big service. 18 00:01:06,960 --> 00:01:09,600 So what service are we going to work on next. 19 00:01:09,600 --> 00:01:14,640 Well it's going to be the ticketing service or the ticket service the gold the ticket service is going 20 00:01:14,640 --> 00:01:18,720 to be to list all the different tickets that have been created inside of our application and all the 21 00:01:18,720 --> 00:01:20,700 tickets that are for sale. 22 00:01:20,700 --> 00:01:25,470 We want to have the ability to show details about a very particular ticket we want to create a ticket 23 00:01:25,500 --> 00:01:26,970 and edit a ticket. 24 00:01:26,970 --> 00:01:29,390 So these are all some pretty basic root handlers. 25 00:01:29,520 --> 00:01:36,180 We're going to list up show a particular record create a record and edit a record ticket service is 26 00:01:36,180 --> 00:01:38,670 definitely going to need to have some event related stuff. 27 00:01:38,760 --> 00:01:42,930 So as soon as we get some kind of basic groundwork put together for the ticket service then we're going 28 00:01:42,930 --> 00:01:46,900 to start implementing that event plus stuff inside of our cluster. 29 00:01:46,910 --> 00:01:47,180 All right. 30 00:01:47,210 --> 00:01:51,230 Now as we start to think about these different routes right here specifically it create a ticket and 31 00:01:51,260 --> 00:01:52,370 edit a ticket. 32 00:01:52,370 --> 00:01:57,260 There's one quick thing I want to mention chances are that whenever someone comes to our service and 33 00:01:57,260 --> 00:02:01,810 tries to create a ticket or edit one we probably want to make sure that this user is logged in. 34 00:02:01,820 --> 00:02:06,870 So in other words we're going to require authentication for a user to create or edit a ticket. 35 00:02:06,980 --> 00:02:08,560 That seems like a very reasonable requirement. 36 00:02:08,570 --> 00:02:09,750 Right. 37 00:02:09,770 --> 00:02:12,770 Let's think about the impact that's gonna have on our ticket service. 38 00:02:12,770 --> 00:02:16,880 That means that our ticket service is probably going to need to have some kind of middleware inside 39 00:02:16,880 --> 00:02:22,580 of it to make sure that the user is authenticated so inspect the cookie pull out that Jason web token 40 00:02:22,940 --> 00:02:25,370 validate the token and so on. 41 00:02:25,370 --> 00:02:30,020 We'll probably implement that inside of a middleware and we'll probably want to have that run before 42 00:02:30,020 --> 00:02:32,660 we ever send that thing off to a root handler. 43 00:02:32,660 --> 00:02:34,210 Now does that sound familiar. 44 00:02:34,220 --> 00:02:36,080 Does this require off middleware. 45 00:02:36,080 --> 00:02:43,430 Sound familiar you might recall that we kind of put something together inside of our auto service. 46 00:02:43,530 --> 00:02:45,110 Very very similar to that. 47 00:02:45,270 --> 00:02:50,080 You might recall inside that middleware directory we've got this require all middleware right here. 48 00:02:50,070 --> 00:02:54,690 It's certainly very easy implementation but without a doubt we already wrote out something like this 49 00:02:56,360 --> 00:03:01,100 as he starts also think about that require off middleware inside the ticket service if a user is not 50 00:03:01,100 --> 00:03:01,820 signed in. 51 00:03:01,820 --> 00:03:07,040 Chances are we're going to want to throw some kind of error maybe you like a not authorized error or 52 00:03:07,040 --> 00:03:12,170 something like that and have that error somehow get captured by our Express application turned into 53 00:03:12,170 --> 00:03:16,000 some error message and then sent back to whoever made the request. 54 00:03:16,010 --> 00:03:21,200 So something very similar for example to maybe this not authorized error that we already put together 55 00:03:21,200 --> 00:03:23,510 inside of our auto service. 56 00:03:23,510 --> 00:03:26,850 So I think you might be seeing where I'm going with this. 57 00:03:26,870 --> 00:03:31,940 It turns out that we've got a lot of functionality already created inside of our auto service that we 58 00:03:31,940 --> 00:03:34,340 need inside the ticket service. 59 00:03:34,550 --> 00:03:38,420 And so the first thing we're going to do before even worrying about putting together the ticket service 60 00:03:38,630 --> 00:03:43,790 we're going to go back to our auto service and we're gonna start to extract a ton of logic from it. 61 00:03:43,790 --> 00:03:46,240 We're going to pull out that entire custom error system. 62 00:03:46,340 --> 00:03:49,520 We're going to pull out some of the different middleware as we put together and we're going to pull 63 00:03:49,520 --> 00:03:52,560 out some of that request validation stuff as well. 64 00:03:52,730 --> 00:03:57,530 We're gonna pull all this out into a shared library that we're going to then start to use between all 65 00:03:57,530 --> 00:03:59,130 of our different services. 66 00:03:59,270 --> 00:04:04,220 And this is going to dramatically decrease the amount of time it takes together it takes to put together 67 00:04:04,250 --> 00:04:09,350 our ticket service the ticket service in general is going to come together so much more quickly than 68 00:04:09,350 --> 00:04:14,210 the time that we spent on our service because all of this kind of core foundational stuff has already 69 00:04:14,210 --> 00:04:18,530 been written and all we really need to do is make sure that we can use it in both of these different 70 00:04:18,530 --> 00:04:20,820 services okay. 71 00:04:20,870 --> 00:04:24,420 So that's the first thing we're going to be working on we're going to extract a lot of the shared logic 72 00:04:24,450 --> 00:04:29,920 into a shared library and then make sure that we can use this library inside of our different services. 73 00:04:29,940 --> 00:04:33,360 So with that might quick Basra here and let's get started in the next video.