1 00:00:00,720 --> 00:00:03,620 We've now finished putting together our Express API together. 2 00:00:03,650 --> 00:00:08,450 Now remember many videos ago I said that you did not have to create the Express API with me. 3 00:00:08,550 --> 00:00:11,900 So if you skipped over all those different videos then stick around. 4 00:00:12,090 --> 00:00:16,230 But if you did go through the express setup with me if you went through all those videos on Express 5 00:00:16,440 --> 00:00:19,580 you can skip this video and move on to the next one. 6 00:00:19,650 --> 00:00:22,470 So if you don't have the express API set up stick around. 7 00:00:22,470 --> 00:00:24,900 We're gonna go through the setup right now. 8 00:00:25,010 --> 00:00:29,640 It's one of first begin by just making sure that you downloaded the zip file right before this video 9 00:00:29,820 --> 00:00:31,860 with all the completed API code. 10 00:00:31,860 --> 00:00:36,990 If you did not download that stuff please go back to the last section and download that zip file. 11 00:00:36,990 --> 00:00:40,860 So I want to first want to tell you a little bit about the API we put together and then we're going 12 00:00:40,860 --> 00:00:44,430 to go through a couple of different steps to actually set it up. 13 00:00:44,430 --> 00:00:44,720 All right. 14 00:00:44,730 --> 00:00:50,790 So first things first quick overview of how this API works our API has four different routes associated 15 00:00:50,790 --> 00:00:57,750 with it so we can make a post request to slash sign up a post to slash sign in it get two slash tracks 16 00:00:57,780 --> 00:01:03,180 or a post to slash tracks as you would guess a post to sign up or sign in. 17 00:01:03,270 --> 00:01:09,980 We have to make with a email and password and that's going to sign a sin with our Express API once we're 18 00:01:09,980 --> 00:01:11,330 signed into our application. 19 00:01:11,330 --> 00:01:16,100 We can then access these other two routes if we're not signed in there we're gonna get an era when we 20 00:01:16,100 --> 00:01:22,220 attempt to access them when we make a get request to slash tracks the Express API will send us back 21 00:01:22,280 --> 00:01:28,640 a list of track objects these different track objects are all the different paths that a user has created 22 00:01:28,640 --> 00:01:35,100 inside of our app in order to create a new track we're going to make a post request to slash tracks 23 00:01:35,530 --> 00:01:40,800 in inside that post request we'll put the name of the track in the list of locations where our user 24 00:01:40,800 --> 00:01:43,420 went to while they were recording that track. 25 00:01:43,710 --> 00:01:46,950 So that's pretty much the Express API in a nutshell. 26 00:01:46,950 --> 00:01:50,220 So let's now start to go through the actual setup process. 27 00:01:50,400 --> 00:01:54,930 The first thing we're going to do is find that zip file that you just downloaded. 28 00:01:55,050 --> 00:02:00,750 Yeah I've got mine right here and you're going to extract that zip file anywhere on your local machine. 29 00:02:00,870 --> 00:02:02,940 So I'm going to go out and double click and extract it. 30 00:02:02,940 --> 00:02:04,390 There we go. 31 00:02:04,390 --> 00:02:07,110 We're then going to open up our code editor inside there. 32 00:02:07,110 --> 00:02:11,840 So I'm gonna very quickly navigate to that track server directory All right. 33 00:02:11,850 --> 00:02:14,550 So I'm going to go to that folder 34 00:02:19,670 --> 00:02:25,430 so there's my track server folder once I'm inside that folder I'm then going to install all my dependencies 35 00:02:25,430 --> 00:02:30,550 for this project with npm install like so we've only got a couple of dependencies. 36 00:02:30,580 --> 00:02:35,320 So the npm install should go rather quickly get some all done already. 37 00:02:36,730 --> 00:02:41,320 Now that we've installed those dependencies we're gonna do a little bit of setup to create a mongo D.B. 38 00:02:41,320 --> 00:02:44,450 instance in order to create a mongo DV instance. 39 00:02:44,530 --> 00:02:49,020 We're going to navigate to this address right here. 40 00:02:49,020 --> 00:02:51,620 Cloud does Mongo DV dot com. 41 00:02:51,850 --> 00:02:55,870 It's going to navigate there myself once you get here. 42 00:02:55,880 --> 00:02:59,490 You're going to be prompted to either sign in or sign up for an account. 43 00:02:59,570 --> 00:03:04,330 If you do not have an account with Mongo DB yet then just go ahead and sign up for a brand new account. 44 00:03:04,550 --> 00:03:08,510 Once you signed up for an account you're going to land at a page kind of like this but it's probably 45 00:03:08,510 --> 00:03:11,760 in and tell you that you do not have any clusters available right now. 46 00:03:11,830 --> 00:03:15,440 So in the very middle of the screen you're going to see a green button that says something like create 47 00:03:15,440 --> 00:03:16,230 a cluster. 48 00:03:16,340 --> 00:03:20,240 So go ahead and click it and then it's going to throw you to a page that looks a little bit like this 49 00:03:21,370 --> 00:03:22,580 once you're on this page. 50 00:03:22,720 --> 00:03:27,400 You can go ahead and find any of these different three providers so you can make your Mongo DB instance 51 00:03:27,400 --> 00:03:31,800 with a W S Google Cloud Platform or Windows Ezer. 52 00:03:31,870 --> 00:03:33,880 It doesn't matter which provider you use. 53 00:03:34,000 --> 00:03:38,950 Just make sure that you select on these providers and then select one of the options that say free tier 54 00:03:38,950 --> 00:03:42,740 available so find one that says free tool available. 55 00:03:42,780 --> 00:03:45,800 Ideally it will be in a physical location close close by you. 56 00:03:46,290 --> 00:03:50,490 And once you've selected that go ahead and hit great cluster down there on the bottom right hand side 57 00:03:52,090 --> 00:03:55,090 I've already got a cluster created sons can hit cancel. 58 00:03:55,090 --> 00:03:59,350 Once you create your cluster you're going to see a message that says it's going to take about seven 59 00:03:59,350 --> 00:04:01,030 to 10 minutes to initialize it. 60 00:04:01,180 --> 00:04:08,170 So go ahead and pauses video and just wait for it to do its thing once the initialization is complete. 61 00:04:08,180 --> 00:04:11,590 You'll then see a window a little bit like this on the left hand side. 62 00:04:11,600 --> 00:04:13,330 You're going to find that Connect button. 63 00:04:13,520 --> 00:04:18,750 So there's Kinect right there and we'll open up the connection wizard you're going to see a screen that 64 00:04:18,750 --> 00:04:20,710 looks a little bit like this. 65 00:04:21,000 --> 00:04:25,380 The first thing you're gonna see is something says you have to whitelist your connection IP address. 66 00:04:26,100 --> 00:04:30,120 So this essentially means that every single time that you connect to your Mongo DB for instance from 67 00:04:30,120 --> 00:04:35,760 your local machine or whatever machine is running your server you need to make sure that that machine 68 00:04:35,820 --> 00:04:39,330 has a IP that has been white listed with Mongo DB. 69 00:04:40,110 --> 00:04:45,510 So you can click that button that says use my current IP but do note that if you ever change your current 70 00:04:45,720 --> 00:04:46,710 physical network. 71 00:04:46,710 --> 00:04:52,470 So if you connect to a different Wi-Fi network or if you plug in your computer to a wired internet connection 72 00:04:52,470 --> 00:04:56,910 or anything similar to that if you ever change your IP address you're gonna have to come back here and 73 00:04:56,970 --> 00:05:02,730 update your IP white list a very easy way to get around that would be to close this window very quickly 74 00:05:04,170 --> 00:05:11,720 on the left hand side you can find network access and then we can find add IP address in on here we 75 00:05:11,720 --> 00:05:16,040 can just tap allow access from anywhere and then hit confirm. 76 00:05:16,040 --> 00:05:19,280 So if you go through that process you won't have to whitelist your IP at all. 77 00:05:20,450 --> 00:05:20,740 Okay. 78 00:05:20,770 --> 00:05:26,770 So back at that connect tab once we've selected or white listed our IP address we're then going to create 79 00:05:26,800 --> 00:05:28,540 a Mongo DB user. 80 00:05:28,540 --> 00:05:32,710 Now the account that you're going to enter in here for the username and password is different than your 81 00:05:32,710 --> 00:05:34,310 Mongo DB account. 82 00:05:34,390 --> 00:05:39,280 So do not use the same credentials that used for logging onto a Mongo DB AECOM. 83 00:05:39,580 --> 00:05:43,040 I personally use some credentials like admin and password. 84 00:05:43,210 --> 00:05:45,030 So just use some very simple credentials. 85 00:05:45,040 --> 00:05:51,450 Again do not make them the same as your Mongo D.B. Atlas credentials once you've entered those in will 86 00:05:51,490 --> 00:05:58,260 then select choose a connection method will then go to connect your application and we're gonna see 87 00:05:58,260 --> 00:05:59,890 a big string up here right there. 88 00:06:01,130 --> 00:06:02,670 So that's the string we care about. 89 00:06:02,840 --> 00:06:08,680 So I gonna copy that string and we're going to open up our code editor and paste that string in it. 90 00:06:08,750 --> 00:06:10,330 I'm gonna go back over to my terminal. 91 00:06:10,340 --> 00:06:16,060 I'm gonna open up my code editor inside that track server directory then inside if you're going to expand 92 00:06:16,060 --> 00:06:22,040 the source directory and find the index dot J.S. file around line 16 or so. 93 00:06:22,040 --> 00:06:23,910 I'm going to find Mongo you or I. 94 00:06:24,020 --> 00:06:29,450 And right now it's being assigned a empty string so all we have to do is paste in that you are right 95 00:06:29,480 --> 00:06:32,970 that we just hate that we just copied off that other page. 96 00:06:33,230 --> 00:06:38,750 Now just so you know when you paste in this you or I sometimes it's going to put in an extra space between 97 00:06:38,810 --> 00:06:41,770 Mongo DV That plus and SRB. 98 00:06:41,960 --> 00:06:45,340 So if you have an extra space in there make sure you delete both those spaces. 99 00:06:45,350 --> 00:06:49,120 There should be no spaces whatsoever inside the string. 100 00:06:49,130 --> 00:06:54,410 The other thing right after you've got your user name right there so like I said my username is admin 101 00:06:54,920 --> 00:06:55,670 and then right after it. 102 00:06:55,670 --> 00:07:01,400 On the other side the colon there's a placeholder for your password so you're going to delete the password 103 00:07:01,430 --> 00:07:05,870 and the two angle brackets on either side and in your real password. 104 00:07:05,870 --> 00:07:12,660 So my real password again this is the password that we entered just back on this window over here my 105 00:07:12,660 --> 00:07:16,210 real password is password password. 106 00:07:16,350 --> 00:07:22,750 Like so I gotta make sure I entered in right there and that should be it Gates I'm going to save this 107 00:07:23,300 --> 00:07:28,450 and I'll finally to actually run our server we're going to go back to our terminal and once again inside 108 00:07:28,450 --> 00:07:34,960 of our server directory we're going to run the command NPM run Dev like so and that's gonna start our 109 00:07:34,960 --> 00:07:37,200 server up okay. 110 00:07:37,230 --> 00:07:40,290 So that's all you have to do to get the server up and running. 111 00:07:40,290 --> 00:07:44,910 Now anytime that you want to take a pause and come back to this application we're working on Remember 112 00:07:44,910 --> 00:07:50,190 you can always close down the server with control C and you can always start a backup with NPM run dev 113 00:07:50,820 --> 00:07:52,850 and that's pretty much it. 114 00:07:52,890 --> 00:08:00,330 Now I want to encourage you to keep this Mongo DV page open if you go to the collections button on here 115 00:08:00,930 --> 00:08:05,550 click on collections you're going to eventually see all the data that we save inside of application 116 00:08:05,790 --> 00:08:07,120 appear inside of here. 117 00:08:07,170 --> 00:08:11,010 So several times while we were building our app we're gonna come back to this page and take a look at 118 00:08:11,040 --> 00:08:13,980 all the information that we're saving to our database. 119 00:08:13,980 --> 00:08:17,910 So just be aware you'll properly want to keep this window open okay. 120 00:08:17,950 --> 00:08:18,580 That's pretty much it. 121 00:08:18,610 --> 00:08:20,050 That's all the setup we have to do. 122 00:08:20,110 --> 00:08:21,880 So let's take a quick pause right here. 123 00:08:21,970 --> 00:08:24,640 Come back the next video and start working on our application.