Node.js Fundamentals

As a non-blocking programming language with amazing concurrency capabilities, it is no surprise that JavaScript shines just as brightly on the server side as it does in a browser. Whether you are making a build tool, web application or API, the rich JavaScript ecosystem and Node core libraries are by your side.

Node.js Fundamentals

Networking

Node comes with some great foundational support for both low and high-level networking. We will begin with writing a program that manages a TCP socket directly, then upgrade it to a turnkey HTTP server to build a simple web application.

  • NetworkingHello Network

    TCP/IP is at the core of how the internet works (After all, the “IP” stands for “internet protocol”). The TCP (Transmission Control Protocol) ensures that when devices receive data, they are in the correct order and not missing any data. We’ll learn about how to open a port and communicate over it using Node’s net module.

  • NetworkingEXERCISE: Guess my Number

    Build a small Node program that opens up a port on localhost, generates a random number between 0 and 100, and then asks the user to guess it. The user should receive some feedback on their guess (too high, too low), and once they find the correct number, the socket should be closed.

    Please guess my number. It is between 0 and 100
    10
    Too Low! Try again
    50
    Too High! Try again
    30
    Too High! Try again
    20
    GOT IT! The number was 20 and you guessed in 4 tries
    
  • NetworkingHTTP

    HTTP (Hypertext Transfer Protocol) is an application networking protocol that describes concepts like URLs, request methods (GET, POST, PUT, etc…) and more! We’ll learn about Node’s fantastic support for HTTP servers and clients, and walk through typical usage patterns.

  • NetworkingEXERCISE: Hello, Web!

    We’ll build an HTTP-based version of our number guessing game from the previous exercise. After our work is done, players will be able to play the game using a web browser instead of their terminal.

  • NetworkingCoffee Break

    Short break