Node Servers
Node.js is a cross-platform Javascript runtime environment for applications and servers. Designed by Ryan Dahl in 2009, it enables Javascript developers to take their applications from scratch to deployment without disruption.
Life before Node
Before Node.js, Javascript was primarily used for client-side development. Alternately, server-side programming required fluency in coding languages other than Javascript. This made for a more segregated delegation of duties when developing applications and forced a project manager to hire separate devs for backend and for frontend.
But Node.js changed the game. Employing the powerful V8 Javascript engine created by Google to convert JS into lower level or machine code that microprocessors can understand — true fullstack development became a reality for JavaScript programmers. Nowadays you can use Javascript to write both front-end and back-end for web applications, making app deployment much easier and more efficient.
Now that we know a bit about Node.js and its impact on the industry, let’s look at how we are able to use Javascript in creating our own, mostly-homemade server.

Node.js supplies HTTP interfaces that are designed to support many features of the protocol which, in the past, have been difficult to use. Specifically, large, sometimes chunk-encoded, messages. This HTTP interface never buffers entire requests or responses, allowing the user to stream data. Looking at the code above, here we include the http module and use the module to create an HTTP server.

Next we tell our server to listen on the specified port, in this case 3000. When we finish creating our server, we will call a listen callback function on this specified port. So whenever I get an incoming request on port 3000, the server function will fire and i get to access what they’re requesting and make a response

In this example, we’ll set our ip address to 127.0.0.1, which is a the address that always refers to localhost (i.e. our individual computer).

To make our server we’ll use a Node method called createServer that takes a callback function with req and res — req for the incoming request data and res for the incoming response data. Inside our callback we’ll want to set our response to a status code reflecting the success or failure of each transmission. We’ll also need to send back a header to tell the client what language we’ll be communicating in. And finally, the end method causes the server to stop processing the script and return the current result.

Now that we’ve created our server and established our port and ip address, we’re ready to go live. To start up our server we’ll call a listen method and pass in our port variable and a callback function which typically prints something to the effect of “Server is running…”. Viola! Our very own homemade server, all thanks to Node.js.
As you can see, Node.js is a powerful yet simple tool for anyone fluent in Javascript. Having the Node.js server lets Javascript developers to tackle both front-end and back-end programming in a way that wasn’t possible in the past.