O'Reilly logo

Mastering Node.js - Second Edition by Kevin Faaborg, Sandro Pasquali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The switchboard

The switchboard will have a single responsibility—to communicate with Twilio. Since we're using webhooks, we'll need to create a server that can catch POST data from Twilio. For the web server, we'll use the restify package (http://www.restify.com). This is a very fast Node server implementation that is designed specifically for fast, high-load REST-based APIs. Since the switchboard is solely focused on handling incoming messages from Twilio, and its outbound traffic is through WebSockets, there is no need for a higher-level server like Express, which is designed to facilitate the presentation of views through templates, sessions, and so forth.

Let's look at the code instantiating a restify server that accepts POST messages ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required