We just installed all of our project dependencies.
We're now going to start up our code editor inside this track server directory and start up a tiny little
express application.
So let's get started.
I'll start my code editor and then inside of my root project directory I'm going to first begin by making
a new folder to house all my source code.
I'm going to call this folder source and then inside there I'm going to make the root file for my entire
project so I'll make a new file called index Dot.
J.S. then inside of here we're going to write out the bare minimum amount of code to create a express
application.
We're gonna create one existing route or one single route and then make sure that our Express server
listens to some port on our local machine will then use our Web browser to test out that little test
route and make sure that we can get some content to appear.
So inside of here I'm going to first begin by creating an express application so I'm going to import
the Express library or required in I'll then create an app object like so.
So this app object right here represents our entire application and we can associate some different
root handlers with it.
We'll now setup our first root handler right after the app declaration.
So to do so I'll say app dot get forward slash and I'll pass in a function as the second argument like
I said I'm going to generally assume that you are familiar with the express but just as a quick reminder
of what's going on here we're seeing anytime someone makes a get type each TTP request to the root root
of our application we want to run this function the function gets called automatically with a request
object or an object that represents the incoming H TTP request and a rez object which represents the
outgoing response so in this case we'll just send back a little bit of plain text to ever made this
request.
So I'll say red dot sent and I'll say something like Hi there.
Like so now anytime someone makes a request to our route route we're gonna send back the plain text
of Hi there.
Now to actually get this working we're gonna have our app object where our Express application listen
to a certain port on our local machine.
So I'll say app dot listen three thousand I'll pass in a callback function as the second argument and
inside here will say console log listening on port three thousand and that's all we need to get started.
So going to save this file and then we'll try running it from our terminal.
It's gonna flip over my terminal and I'll do node source index dot J.S..
Now of course if you're on Windows you're gonna have a slightly different path separator right there.
Just be aware so right away I'll see listing on port three thousand if you see an error message at this
point in time 100 percent likely that you have another process already running on port three thousand.
So just like we saw earlier on inside this course if you want to you can change the port right there
from 3000 to say three thousand one.
Or alternatively you could go find that other process and terminate it and then try running node source
index dot J.S. once again it's now that our server is listening to port three.
We can test out that route route just make sure everything is working as expected.
So to test it out I'm going to open up my browser and navigate to local host colon 3000 like so and
then once there I should see hi there on the screen.
Very good.
All right.
So now that we've got some of the basics put together here let's come back the next video we're gonna
start to wire up Mongo DB to our Express application so we can store some amount of data.