Chapter 3. Node.js for the Web of Things

 

This chapter covers

  • An overview of how JavaScript can be used for the IoT and the WoT
  • A thorough yet accessible introduction to Node.js
  • The implementation of a simple HTTP server with Node.js
  • An introduction to Node.js modularity and NPM
  • The basics of asynchronous programming and control-flow libraries

The previous chapter provided a first encounter with web-connected devices. We hope it made you realize how easy it is to build applications that interact with various web-connected devices. But this was only the tip of the iceberg because we did all the hard work for you. In the rest of the book, we’ll teach you all you need to know in order to implement your own web-connected devices and applications.

Before we jump straight to the code and other juicy bits, you have two important decisions to make. First, you have to pick an embedded platform on which your applications will run. This will be the subject of chapter 4. Second, you need to choose the programming language in which you’ll write your code, and this is the topic of this chapter.

3.1. The rise of JavaScript: from clients to servers to things!

3.2. Introduction to Node.js

3.3. Modularity in Node.js

3.4. Understanding the Node.js event loop

3.5. Getting started with asynchronous programming

3.6. Summary and beyond the book