Now we are going to introduce some NPM modules that we need to use the very beginning of our code. Even if later during the course we are going to install other NPM modules. Let's start with the most important probably that is the Express. For framework that is defined as a fast minimalist web framework for note, you can check all the details on Express js.com. So how does it work? The first thing we have to do is to create an express application as shown.
And the very basic operation we can do is to just listen on a specific port for example 5000, as shown in this slide. Before going to see how to handle an HTTP request with experts. We have to introduce the concept of middleware function that is defined as a function that has access to the request object called v rec by convention and the response object called rest, by convention, and the next function in the applications request response cycle. The next function is a function in the Express router, which, when invoked, executes the middleware succeeding the current middleware. So how do we handle HTTP requests? For example, let's see how we can get a specific route.
So what we are going to do is to use the app, the Express app and call the get method to perform a get request. We specify our route URL, and we provide the middleware function. So in this case, dot get represents the HTTP method for which the middleware function applies. The route is a path. That by convention is called route in the experts world for which the middleware function applies the middleware arguments. The first is an HTTP request argument.
The second one is the HTTP response argument. And the third one is the callback. In the same way, we can perform a POST request as shown in the slide. The second module, I will I would like to introduce this body parser that is our no GS body parser middleware. I am not going to go through these definitions, but these two are the function we are going to use. Please check it in the resources I'm leaving in the web page.
The third one stripe of course, the stripe node library provides convenient access to the stripe API from applications written in the server side JavaScript. Please note server side. This is a library only for server side JavaScript.