How it works…

We wrote a server; now, let's see it run. With this very simple project, we can just directly run the server code. In later sections in this chapter, we'll see that using Flow types will require some extra preprocessing; we can skip that part for now, however. We can start our server with the following command line:

> node src/miniserver.js
Mini server ready at http://localhost:8080/

To verify if everything is working fine, just open a browser and go to http://localhost:8080. The following screenshot shows the (admittedly not very impressive) result:

 Our minimalistic server is running, showing that we have Node working properly

Now that we know that everything is OK, let's get started with some basic techniques that we will be using in several other places of the book.

Why are we running the server at port 8080 instead of 80? To access ports below 1024, you need administrative (root) rights. However, that would make your server highly unsafe; a hacker that somehow managed to get into it would have maximum rights at your machine! Thus, the standard practice is to run Node with normal rights, at ports over 1024 (such as 8080, for example) and set up a reverse proxy to send traffic on ports 80 (HTTP) or 443 (HTTPS).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset