1 00:00:00,820 --> 00:00:03,300 We just installed all of our project dependencies. 2 00:00:03,340 --> 00:00:08,200 We're now going to start up our code editor inside this track server directory and start up a tiny little 3 00:00:08,200 --> 00:00:09,700 express application. 4 00:00:09,700 --> 00:00:11,340 So let's get started. 5 00:00:11,380 --> 00:00:17,030 I'll start my code editor and then inside of my root project directory I'm going to first begin by making 6 00:00:17,060 --> 00:00:20,000 a new folder to house all my source code. 7 00:00:20,060 --> 00:00:25,640 I'm going to call this folder source and then inside there I'm going to make the root file for my entire 8 00:00:25,640 --> 00:00:28,760 project so I'll make a new file called index Dot. 9 00:00:28,760 --> 00:00:35,430 J.S. then inside of here we're going to write out the bare minimum amount of code to create a express 10 00:00:35,430 --> 00:00:36,450 application. 11 00:00:36,540 --> 00:00:41,430 We're gonna create one existing route or one single route and then make sure that our Express server 12 00:00:41,460 --> 00:00:47,490 listens to some port on our local machine will then use our Web browser to test out that little test 13 00:00:47,490 --> 00:00:50,480 route and make sure that we can get some content to appear. 14 00:00:50,790 --> 00:00:55,860 So inside of here I'm going to first begin by creating an express application so I'm going to import 15 00:00:55,980 --> 00:01:04,060 the Express library or required in I'll then create an app object like so. 16 00:01:04,080 --> 00:01:08,700 So this app object right here represents our entire application and we can associate some different 17 00:01:08,700 --> 00:01:10,770 root handlers with it. 18 00:01:10,860 --> 00:01:14,350 We'll now setup our first root handler right after the app declaration. 19 00:01:14,430 --> 00:01:23,390 So to do so I'll say app dot get forward slash and I'll pass in a function as the second argument like 20 00:01:23,390 --> 00:01:27,650 I said I'm going to generally assume that you are familiar with the express but just as a quick reminder 21 00:01:27,650 --> 00:01:33,800 of what's going on here we're seeing anytime someone makes a get type each TTP request to the root root 22 00:01:33,800 --> 00:01:40,460 of our application we want to run this function the function gets called automatically with a request 23 00:01:40,460 --> 00:01:47,150 object or an object that represents the incoming H TTP request and a rez object which represents the 24 00:01:47,180 --> 00:01:53,080 outgoing response so in this case we'll just send back a little bit of plain text to ever made this 25 00:01:53,080 --> 00:01:54,100 request. 26 00:01:54,100 --> 00:01:58,240 So I'll say red dot sent and I'll say something like Hi there. 27 00:01:58,240 --> 00:02:03,460 Like so now anytime someone makes a request to our route route we're gonna send back the plain text 28 00:02:03,520 --> 00:02:05,530 of Hi there. 29 00:02:05,660 --> 00:02:11,240 Now to actually get this working we're gonna have our app object where our Express application listen 30 00:02:11,240 --> 00:02:13,640 to a certain port on our local machine. 31 00:02:13,980 --> 00:02:21,710 So I'll say app dot listen three thousand I'll pass in a callback function as the second argument and 32 00:02:21,830 --> 00:02:31,650 inside here will say console log listening on port three thousand and that's all we need to get started. 33 00:02:31,880 --> 00:02:35,930 So going to save this file and then we'll try running it from our terminal. 34 00:02:36,150 --> 00:02:43,540 It's gonna flip over my terminal and I'll do node source index dot J.S.. 35 00:02:43,750 --> 00:02:48,100 Now of course if you're on Windows you're gonna have a slightly different path separator right there. 36 00:02:48,140 --> 00:02:53,510 Just be aware so right away I'll see listing on port three thousand if you see an error message at this 37 00:02:53,510 --> 00:02:59,360 point in time 100 percent likely that you have another process already running on port three thousand. 38 00:02:59,540 --> 00:03:03,830 So just like we saw earlier on inside this course if you want to you can change the port right there 39 00:03:03,830 --> 00:03:06,190 from 3000 to say three thousand one. 40 00:03:06,290 --> 00:03:11,480 Or alternatively you could go find that other process and terminate it and then try running node source 41 00:03:11,510 --> 00:03:16,430 index dot J.S. once again it's now that our server is listening to port three. 42 00:03:16,570 --> 00:03:20,710 We can test out that route route just make sure everything is working as expected. 43 00:03:20,770 --> 00:03:28,760 So to test it out I'm going to open up my browser and navigate to local host colon 3000 like so and 44 00:03:28,760 --> 00:03:32,300 then once there I should see hi there on the screen. 45 00:03:32,330 --> 00:03:33,500 Very good. 46 00:03:33,500 --> 00:03:33,800 All right. 47 00:03:33,800 --> 00:03:37,670 So now that we've got some of the basics put together here let's come back the next video we're gonna 48 00:03:37,670 --> 00:03:42,530 start to wire up Mongo DB to our Express application so we can store some amount of data.