Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free
  • By Maciej Treder
    Asynchronous JavaScript: Introducing ReactiveX and RxJS Observables async-js-reactivex-rxjs-observables.png

    Reactive Extensions (ReactiveX) are one of the most widely-adopted set of tools in programming today. ReactiveX libraries for JavaScript and other languages provide a way to operate on sequences of data as if they were events. This is a convenient way to handle data from asynchronous sources like web APIs: your programs can react to data as it is emitted from the source without tightly coupling the code that uses the data with the code that gets the data.

    In this post you’ll learn about the fundamental concepts of ReactiveX programming and get hands-on experience doing ReactiveX programming with RxJS for JavaScript. You’ll learn how to retrieve data asynchronously, manipulate it as it arrives, and handle errors. You’ll also see how RxJS Observables compare to JavaScript Promises.

    Introducing the ReactiveX API and the RxJS library

    Reactive Extensions, known as ReactiveX, is an application programming interface (API) enabling programming languages …

    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Refactoring Callbacks to Promises in Node.js Advanced JavaScript: Refactoring Callbacks to Promises

    If you know how the event loop mechanism works in JavaScript you know how it enables you to work with asynchronous events. You might also know how to refactor your code into separate functions to reduce the amount of nesting associated with a sequence of callback functions. If you work with web APIs you are probably familiar with the JavaScript request library, which is used to perform HTTP calls.

    You can put these skills together to retrieve remote data through an HTTP request and work with the call response asynchronously. But in doing so you’ll probably notice that code has at least one pitfall: the logical order of declared functions is reversed. That makes the code hard to read and maintain.

    With the node-fetch JavaScript library and Promise objects you can reduce nesting, known as the callback “Pyramid of Doom”, and organize your code in a more readable and logical …

    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Advanced Promises with Node.js Asynchronous JavaScript: Advanced Promises with Node.js

    JavaScript Promise objects are a considerable improvement over basic JavaScript callback functions. Promises provide an object that represents both the state of an asynchronous function and the values returned by it. The state indicates whether the promise is pending, fulfilled by a successfully completed operation, or rejected because of an error or other condition. When a promise is fulfilled its value is determined by the asynchronous operation executed by the promise.

    Promises can also be chained together to use the state of settled promises (resolved or rejected) and the promises’ values to control the flow of execution in your program. This is useful when you have a sequence of asynchronous operations to perform that each depend on the results of the previous operation: the next step in the chain isn’t performed until the preceding step is resolved. Chains of promises also include error propagation; errors in a …

    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Introduction to JavaScript Promises Asynchronous JavaScript Introduction to Promises

    Asynchronous processing is one of the most important capabilities JavaScript acquired as the language matured. JavaScript’s async capabilities enable more sophisticated and responsive user interfaces. They also make it possible to implement a distributed web application architecture built on standards like SOAP and REST.

    JavaScript Promises are currently the most powerful and flexible asynchronous technology built into the language itself. This post will explain how they work and get you writing your own promises with some practical examples.

    Promises offer a number of advantages:

    • a promise can be called multiple times
    • promises can be chained together
    • promises can include error rejection events
    • errors in a chain of promises need only be handled once (error propagation)
    • promises can be used to wrap old-style callback functionality
    • promises always execute after the current execution stack is empty

    If you’re just starting out with asynchronous functionality in JavaScript the preceding points might not mean …

    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Organizing Callbacks for Readability and Reusability cxgwWEzJkPC0ZPM2fWcHu3BrGZXaMUO2Z0tUwOu9UTctbND9UrJpqwisJe7EOp9UZlf6sUZhhnH80lvOQadVfLyAfaswgFqm0BB9rs6FD9beeFkQYLMHSwNBo1kNwgkMMrBcHX4l

    Asynchronous programming is an essential part of being a complete JavaScript programmer. Understanding the code execution flow in JavaScript is the foundation of understanding how it can handle asynchronous tasks. And being able to program asynchronous tasks enables you to take advantage of the extensive array of functions provided by JavaScript runtime engines and external APIs. With those tools you can connect your JavaScript programs with web APIs across the internet and effectively manage those—sometimes tenuous—connections.

    With power comes complexity. Using JavaScript callbacks to implement asynchronous functionality can quickly create a series of deeply nested function calls. This post will show you how to write and organize your JavaScript callbacks to maximize the readability, maintainability, and reusability of your asynchronous functions.

    As an old programming saying goes:

    Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

    The first part of this …

    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Understanding Callbacks Asynchronous JavaScript: Understanding Callbacks

    By design, JavaScript is a synchronous scripting language. In fact, many of the widely used asynchronous functions in JavaScript are not part of the core language. Understanding how asynchronous features work in the JavaScript ecosystem, including the role played by external APIs, is an essential part of using the language effectively.

    This post will show you how to use asynchronous functionality in JavaScript. It’s also going to explain an important difference between the way code execution works in JavaScript and other languages and frameworks. Understanding this difference is essential to understanding how to do asynchronous programming with JavaScript.

    Understanding JavaScript asynchronous code

    JavaScript programs rely on a JavaScript runtime environment for execution. Browsers, like Chrome and Firefox, and application servers, like Node.js, include a runtime environment as part of the application. This enables websites to run JavaScript in client browsers and standalone JavaScript applications to run in Node.js.

    While Chrome …

    Read More
  • By Maciej Treder
    Protecting JavaScript Microservices on Node.js with JSON Web Tokens and Twilio Authy Copy of Product Template - Authy.png

    Building a JavaScript application on Node.js with a microservices architecture gives you the ability to scale your app: you can respond to varying load levels by adding and removing instances of a service. When multiple instances of a service access the same data, your application can use a common persistence layer, a database, to share information between instances and maintain consistency between them.

    In many applications you'll also want to limit access to some data and functions to particular users. While you could do this directly in your service APIs, there's a better way.

    This post will show you how to add two-factor authentication (2FA) with Twilio Authy and an authorization web service using JSON Web Tokens (JWTs), a standard for securely storing and transmitting sensitive data.

    Authentication with Twilio Authy

    Twilio Authy uses push authentications to verify a user's identity. Push authentications are better than passwords because they require …

    Read More
  • By Maciej Treder
    Scaling Node.js JavaScript Microservices on Shared MongoDB Atlas Cloud Persistence Layers SJnUOPvxV61fRcmv5Yt-pzFgX-lGmYhj6_t5HI-kLrenVH2eaKj_h56yuKtqiApJSH1HLQLmURnIvDX0i03ZqZ87q9iK_D3UVJ2SRZD3YmgG0EOhztC_Gm3oWYQJ-EP93TMqIDee

    Building a JavaScript application on Node.js with a microservices architecture gives you the ability to scale your app to respond to increasing load levels by adding more instances of a service. But when multiple instances of a service work with the same data your application will have an additional design requirement: you'll need a persistence layer the service instances can use to store and share data.

    This post will show you how to use a database as a persistence layer for a JavaScript microservices application. You'll see how the application uses Netflix Eureka and Netflix Zuul for service discovery and load balancing. You'll be able to apply the techniques you learn here to build applications you can scale up and scale out while avoiding the complexity of building service discovery and load balancing on your own.

    You'll also get a hands-on introduction to working with MongoDB Atlas as a database-as-a-service …

    Read More
  • By Maciej Treder
    Implementing Eureka and Zuul for Service Discovery and Dynamic Routing in JavaScript Microservices Running on Node.js Gw87W418humMuagmwCQwtUyO2SOfwrWPG7TdI2vz7z_y86RFhQPQorXMBTcuPGWz1qCgkzBfvzX51Lgf1K1y493wa4Apwoq-y0zQf8Sig9UDXo5XaZi-y_YdGYoecOCIvX4Jfawz

    Building your JavaScript applications as a collection of microservices give you a number of advantages. Your applications can be more modular, uniform, and testable as you build them and they can be more robust, scalable, and available when you deploy them to the production environment. Including a service discovery registry and dynamic routing capabilities will help you achieve scalability and availability in the production.

    This post will show you how to integrate service discovery and intelligent routing into a Node.js application built with a microservices architecture. You'll see how you can do this with two Netflix open source projects, Eureka and Zuul, that run in the Java SE Runtime Environment.

    The Netflix Eureka server provides service discovery. This gives your application's services the ability to find other services without knowing where they are hosted or the full URL required to reach them, so you don't have to provide complete URLs …

    Read More
  • By Maciej Treder
    Building JavaScript Microservices with Node.js mUCiZxpOc_8QJwGWjnL-3laEHBvVPsWFUUaaqEwngtHx6dvVh4OCSHt930RA_L321CXXwCN0MkX_duBXkbyACYCVNsBFUCM09cLYxG3Q8hp0AkaSIdo4e_LyZfPj-EFr9davE6U5

    When your JavaScript application grows in size you start facing challenges with maintaining the code, fixing bugs, and implementing new features. Also, adding new developers to the project becomes complicated.

    Applications are built from pieces, like packages and modules, but at some point those structures aren’t enough to reduce the size and complexity of the application. The idea behind distributed systems is to break big, monolithic designs into small, independent programs which communicate with each other to exchange data and perform operations.

    One of the many variants of distributed systems is the microservices architecture, which structures an application as a collection of loosely coupled services. Services are fine-grained and the communication protocols are lightweight (like the HTTP protocol).

    There are few things worth emphasizing about the superiority of microservices, and distributed systems generally, over monolithic architecture:

    • Modularity – responsibility for specific operations is assigned to separate pieces of the application …
    Read More
  • Newer
    Sign up and start building
    Not ready yet? Talk to an expert.