In the last section we finished up stage 1 of all of our passport authentic cations stuff we're about
to move into the next big section of our application.
But before we do I want to take care of one outstanding little issue.
Remember that right now every single time that we make a change to our code base inside of our index
start as file.
I've been saying that we have to restart our server manually.
And so we've had to kill the server with Control-C and then started back up with node index G-S.
Now obviously this gets really tiring really quickly.
So we're going to do things just a little bit differently.
We're going to install a little add on or a little module that's going to automatically restart our
server any time we change any file inside of it.
And so that means that we won't have to be constantly killing and restarting our server over and over
and over again.
So the module that we're going to use to give us this behavior is called node Mohn would solve it right
now using NPM and then we will wired up to our application.
So I'm going to install it by running NPM install dash dash save Node 1 like so
now after that installs we're going to create a new script inside of our package not just on file to
startup gnomon and tell it to just start doing its thing.
So let's let this install Go quickly and we don't really need to watch it.
Who cares about that gets will flip back over toward code editor.
I'm going to find my package Scott japes on file and I'm going to find the scripts section inside of
there.
So here's scripts right here.
I'm going to add an additional script called Dev and inside of dev we're going to provide the command
node Mohn index.
So now if we run this dev script the command node mon index G-S will start up.
Now you might be a bit curious you know like what is the scripts thing like Dev.
What's going on here.
Well let's put it this way we have now installed node 1.
You can imagine that if we had to constantly run the command nodes on index dot all the time.
That's kind of a pain in the rear especially if some new developer comes and starts working on our project
and they really have no idea how to start our server up.
So rather than just kind of having this like knowledge in our head that oh yeah to start up our server
for development we run Modan index dot J us we instead define this dev script inside of our scripts
section which now allows any other developer in the future to come open up this package not just some
file and say oh to start up the server in development mode.
I'm going to run this script right here which is actually running this command.
So essentially the script section is our opportunity to put on some kind of like memory saving and I'm
talking about human memory here of course some human memory scripts so that we don't have to remember
how to start our server up and stuff like that.
Now to actually start the script up at the command line we will run Antium run death like so now when
we do you'll see that that automatically executes the command Modan index dot us and then we start to
see a little bit of output from node on right here.
OK.
So let's test this out just very quickly.
If I go back into my index file and I'd change like absolute anything in here.
So like let's say here's my console log statement I'm going to just remove the colon on there and then
save the file the instant I save the file if I change back over to my terminal you'll see a message
that says restarting due to changes.
And here is the command that just got executed again.
OK.
So that's pretty sweet.
Now at this point in time anytime we make a change to our code base we don't have to go back and restart
the server anymore because no gnomon is going to automatically restart it for us.
Once we change any given file.
So that's pretty much it.
So that's a nice little time saver.
Let's continue in the next section and get back into our authentication flow.
So I'll see you in just a second.