We've now finished putting together our Express API together.
Now remember many videos ago I said that you did not have to create the Express API with me.
So if you skipped over all those different videos then stick around.
But if you did go through the express setup with me if you went through all those videos on Express
you can skip this video and move on to the next one.
So if you don't have the express API set up stick around.
We're gonna go through the setup right now.
It's one of first begin by just making sure that you downloaded the zip file right before this video
with all the completed API code.
If you did not download that stuff please go back to the last section and download that zip file.
So I want to first want to tell you a little bit about the API we put together and then we're going
to go through a couple of different steps to actually set it up.
All right.
So first things first quick overview of how this API works our API has four different routes associated
with it so we can make a post request to slash sign up a post to slash sign in it get two slash tracks
or a post to slash tracks as you would guess a post to sign up or sign in.
We have to make with a email and password and that's going to sign a sin with our Express API once we're
signed into our application.
We can then access these other two routes if we're not signed in there we're gonna get an era when we
attempt to access them when we make a get request to slash tracks the Express API will send us back
a list of track objects these different track objects are all the different paths that a user has created
inside of our app in order to create a new track we're going to make a post request to slash tracks
in inside that post request we'll put the name of the track in the list of locations where our user
went to while they were recording that track.
So that's pretty much the Express API in a nutshell.
So let's now start to go through the actual setup process.
The first thing we're going to do is find that zip file that you just downloaded.
Yeah I've got mine right here and you're going to extract that zip file anywhere on your local machine.
So I'm going to go out and double click and extract it.
There we go.
We're then going to open up our code editor inside there.
So I'm gonna very quickly navigate to that track server directory All right.
So I'm going to go to that folder
so there's my track server folder once I'm inside that folder I'm then going to install all my dependencies
for this project with npm install like so we've only got a couple of dependencies.
So the npm install should go rather quickly get some all done already.
Now that we've installed those dependencies we're gonna do a little bit of setup to create a mongo D.B.
instance in order to create a mongo DV instance.
We're going to navigate to this address right here.
Cloud does Mongo DV dot com.
It's going to navigate there myself once you get here.
You're going to be prompted to either sign in or sign up for an account.
If you do not have an account with Mongo DB yet then just go ahead and sign up for a brand new account.
Once you signed up for an account you're going to land at a page kind of like this but it's probably
in and tell you that you do not have any clusters available right now.
So in the very middle of the screen you're going to see a green button that says something like create
a cluster.
So go ahead and click it and then it's going to throw you to a page that looks a little bit like this
once you're on this page.
You can go ahead and find any of these different three providers so you can make your Mongo DB instance
with a W S Google Cloud Platform or Windows Ezer.
It doesn't matter which provider you use.
Just make sure that you select on these providers and then select one of the options that say free tier
available so find one that says free tool available.
Ideally it will be in a physical location close close by you.
And once you've selected that go ahead and hit great cluster down there on the bottom right hand side
I've already got a cluster created sons can hit cancel.
Once you create your cluster you're going to see a message that says it's going to take about seven
to 10 minutes to initialize it.
So go ahead and pauses video and just wait for it to do its thing once the initialization is complete.
You'll then see a window a little bit like this on the left hand side.
You're going to find that Connect button.
So there's Kinect right there and we'll open up the connection wizard you're going to see a screen that
looks a little bit like this.
The first thing you're gonna see is something says you have to whitelist your connection IP address.
So this essentially means that every single time that you connect to your Mongo DB for instance from
your local machine or whatever machine is running your server you need to make sure that that machine
has a IP that has been white listed with Mongo DB.
So you can click that button that says use my current IP but do note that if you ever change your current
physical network.
So if you connect to a different Wi-Fi network or if you plug in your computer to a wired internet connection
or anything similar to that if you ever change your IP address you're gonna have to come back here and
update your IP white list a very easy way to get around that would be to close this window very quickly
on the left hand side you can find network access and then we can find add IP address in on here we
can just tap allow access from anywhere and then hit confirm.
So if you go through that process you won't have to whitelist your IP at all.
Okay.
So back at that connect tab once we've selected or white listed our IP address we're then going to create
a Mongo DB user.
Now the account that you're going to enter in here for the username and password is different than your
Mongo DB account.
So do not use the same credentials that used for logging onto a Mongo DB AECOM.
I personally use some credentials like admin and password.
So just use some very simple credentials.
Again do not make them the same as your Mongo D.B. Atlas credentials once you've entered those in will
then select choose a connection method will then go to connect your application and we're gonna see
a big string up here right there.
So that's the string we care about.
So I gonna copy that string and we're going to open up our code editor and paste that string in it.
I'm gonna go back over to my terminal.
I'm gonna open up my code editor inside that track server directory then inside if you're going to expand
the source directory and find the index dot J.S. file around line 16 or so.
I'm going to find Mongo you or I.
And right now it's being assigned a empty string so all we have to do is paste in that you are right
that we just hate that we just copied off that other page.
Now just so you know when you paste in this you or I sometimes it's going to put in an extra space between
Mongo DV That plus and SRB.
So if you have an extra space in there make sure you delete both those spaces.
There should be no spaces whatsoever inside the string.
The other thing right after you've got your user name right there so like I said my username is admin
and then right after it.
On the other side the colon there's a placeholder for your password so you're going to delete the password
and the two angle brackets on either side and in your real password.
So my real password again this is the password that we entered just back on this window over here my
real password is password password.
Like so I gotta make sure I entered in right there and that should be it Gates I'm going to save this
and I'll finally to actually run our server we're going to go back to our terminal and once again inside
of our server directory we're going to run the command NPM run Dev like so and that's gonna start our
server up okay.
So that's all you have to do to get the server up and running.
Now anytime that you want to take a pause and come back to this application we're working on Remember
you can always close down the server with control C and you can always start a backup with NPM run dev
and that's pretty much it.
Now I want to encourage you to keep this Mongo DV page open if you go to the collections button on here
click on collections you're going to eventually see all the data that we save inside of application
appear inside of here.
So several times while we were building our app we're gonna come back to this page and take a look at
all the information that we're saving to our database.
So just be aware you'll properly want to keep this window open okay.
That's pretty much it.
That's all the setup we have to do.
So let's take a quick pause right here.
Come back the next video and start working on our application.