[MUSIC]
>> Hi there. I'm Christopher Harrison,
Senior Program Manager inside of Microsoft Cloud and AI.
What I want to take a look at now is,
how we can start to configure routes inside of our Express App.
A route, at its core,
is how it is that a client or user can request something,
be a data, be it an operation,
or otherwise from our application.
Basically, what's going to happen is
the client will specify a URL.
They'll maybe send up some information,
and then that will cause
a function to execute in response to that.
Now, the way that we're going to set this up is,
we're going to create a router here.
We'll set up our router and set that equal to
the cool little router that express makes available to us.
Now, what you're going to notice about
the router is that we're going to be able to
specify the method or verb that we want to now look for.
This could be get, this could be patch,
this could be post,
this could be put, etc.
Now, there's different verbs will have different meanings,
and we'll see those in later videos.
For now though, let's focus in on get,
which is the core on how we're going to start everything off.
Now what we'll do with the first parameter is specify the path.
That little forward slash,
that's going to specify that this is now the default.
If the user just navigates to that core URL,
this is what we're going to do in response to that.
The handle that we're going to give it is going to
take two parameters; request,
which is going to contain any information
that was sent up from the user,
and response, which is how we're going to send
information down to the user.
For our little demo,
what we want to do is send down the description
and the version of our application.
We're going to retrieve that from the package.json file.
We'll go ahead and import that in.
Then what we'll do, is we'll use
that response object and send down,
in our case, a string.
We'll use the string format,
we'll go ahead and go grab the description from the package.
We'll grab the version from
the package and we will send that down.
There's a little bit of a typo here,
that we'll go ahead and clean up in just a second. There we go.
Now, this is set up,
so it's going to send down that formatted string.
The last step here,
after we've got that set up
is to actually register our router with the app.
We're going to set up an API route,
which is going to be API,
that's a standard convention,
and then we're going to tell our app to use that.
We're going to specify our API route,
and then we're going to add in our router.
Let's go ahead and save this and we'll
let nodemon then refresh it.
Then we're going to use a neat little package here,
called "Simple Rest Client",
that will allow us to go ahead and make these requests.
This is an extension inside of Visual Studio Code.
We'll specify our URL forward slash API.
Our method of get,
we'll send this and what we're going to notice is,
that the response is that string that we have put together.
This really is core to everything
that we're going to be doing with our applications.
That we'll create a route,
we'll specify some function that's going to respond to it,
and then send down
whatever information it is that the user has requested.
In the next section,
we're going to take a look at how we can continue to
build on this by adding in a little bit of data.