1 00:00:00,890 --> 00:00:06,000 In the last section we finished up stage 1 of all of our passport authentic cations stuff we're about 2 00:00:06,000 --> 00:00:09,000 to move into the next big section of our application. 3 00:00:09,000 --> 00:00:12,350 But before we do I want to take care of one outstanding little issue. 4 00:00:12,480 --> 00:00:16,700 Remember that right now every single time that we make a change to our code base inside of our index 5 00:00:16,720 --> 00:00:17,950 start as file. 6 00:00:17,950 --> 00:00:21,240 I've been saying that we have to restart our server manually. 7 00:00:21,240 --> 00:00:27,420 And so we've had to kill the server with Control-C and then started back up with node index G-S. 8 00:00:27,420 --> 00:00:30,600 Now obviously this gets really tiring really quickly. 9 00:00:30,600 --> 00:00:32,900 So we're going to do things just a little bit differently. 10 00:00:32,910 --> 00:00:37,830 We're going to install a little add on or a little module that's going to automatically restart our 11 00:00:37,830 --> 00:00:41,870 server any time we change any file inside of it. 12 00:00:41,950 --> 00:00:46,380 And so that means that we won't have to be constantly killing and restarting our server over and over 13 00:00:46,380 --> 00:00:47,650 and over again. 14 00:00:48,240 --> 00:00:53,910 So the module that we're going to use to give us this behavior is called node Mohn would solve it right 15 00:00:53,910 --> 00:00:57,910 now using NPM and then we will wired up to our application. 16 00:00:58,020 --> 00:01:04,140 So I'm going to install it by running NPM install dash dash save Node 1 like so 17 00:01:07,540 --> 00:01:14,590 now after that installs we're going to create a new script inside of our package not just on file to 18 00:01:14,890 --> 00:01:19,010 startup gnomon and tell it to just start doing its thing. 19 00:01:19,120 --> 00:01:23,430 So let's let this install Go quickly and we don't really need to watch it. 20 00:01:23,440 --> 00:01:26,490 Who cares about that gets will flip back over toward code editor. 21 00:01:26,620 --> 00:01:32,230 I'm going to find my package Scott japes on file and I'm going to find the scripts section inside of 22 00:01:32,230 --> 00:01:32,480 there. 23 00:01:32,500 --> 00:01:34,790 So here's scripts right here. 24 00:01:35,050 --> 00:01:42,520 I'm going to add an additional script called Dev and inside of dev we're going to provide the command 25 00:01:42,850 --> 00:01:45,220 node Mohn index. 26 00:01:47,710 --> 00:01:53,410 So now if we run this dev script the command node mon index G-S will start up. 27 00:01:53,440 --> 00:01:57,340 Now you might be a bit curious you know like what is the scripts thing like Dev. 28 00:01:57,340 --> 00:01:58,370 What's going on here. 29 00:01:58,570 --> 00:02:01,920 Well let's put it this way we have now installed node 1. 30 00:02:01,960 --> 00:02:07,410 You can imagine that if we had to constantly run the command nodes on index dot all the time. 31 00:02:07,540 --> 00:02:12,790 That's kind of a pain in the rear especially if some new developer comes and starts working on our project 32 00:02:12,850 --> 00:02:15,670 and they really have no idea how to start our server up. 33 00:02:15,670 --> 00:02:20,200 So rather than just kind of having this like knowledge in our head that oh yeah to start up our server 34 00:02:20,200 --> 00:02:27,070 for development we run Modan index dot J us we instead define this dev script inside of our scripts 35 00:02:27,070 --> 00:02:32,620 section which now allows any other developer in the future to come open up this package not just some 36 00:02:32,620 --> 00:02:36,400 file and say oh to start up the server in development mode. 37 00:02:36,400 --> 00:02:40,330 I'm going to run this script right here which is actually running this command. 38 00:02:40,330 --> 00:02:45,550 So essentially the script section is our opportunity to put on some kind of like memory saving and I'm 39 00:02:45,550 --> 00:02:50,110 talking about human memory here of course some human memory scripts so that we don't have to remember 40 00:02:50,110 --> 00:02:53,080 how to start our server up and stuff like that. 41 00:02:53,190 --> 00:03:01,390 Now to actually start the script up at the command line we will run Antium run death like so now when 42 00:03:01,390 --> 00:03:07,420 we do you'll see that that automatically executes the command Modan index dot us and then we start to 43 00:03:07,420 --> 00:03:10,270 see a little bit of output from node on right here. 44 00:03:10,930 --> 00:03:11,220 OK. 45 00:03:11,230 --> 00:03:13,120 So let's test this out just very quickly. 46 00:03:13,120 --> 00:03:18,450 If I go back into my index file and I'd change like absolute anything in here. 47 00:03:18,460 --> 00:03:24,040 So like let's say here's my console log statement I'm going to just remove the colon on there and then 48 00:03:24,040 --> 00:03:30,160 save the file the instant I save the file if I change back over to my terminal you'll see a message 49 00:03:30,160 --> 00:03:32,590 that says restarting due to changes. 50 00:03:32,590 --> 00:03:35,260 And here is the command that just got executed again. 51 00:03:35,610 --> 00:03:35,870 OK. 52 00:03:35,890 --> 00:03:36,880 So that's pretty sweet. 53 00:03:36,880 --> 00:03:42,670 Now at this point in time anytime we make a change to our code base we don't have to go back and restart 54 00:03:42,760 --> 00:03:47,140 the server anymore because no gnomon is going to automatically restart it for us. 55 00:03:47,260 --> 00:03:49,270 Once we change any given file. 56 00:03:49,700 --> 00:03:50,860 So that's pretty much it. 57 00:03:50,860 --> 00:03:52,370 So that's a nice little time saver. 58 00:03:52,510 --> 00:03:56,550 Let's continue in the next section and get back into our authentication flow. 59 00:03:56,680 --> 00:03:58,470 So I'll see you in just a second.