Build the future of communications.
Start building for free
  • 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 ...

    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 ...

    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 ...

    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 ...

    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 ...

    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
  • By Maciej Treder
    Encrypting Cookies with Angular Universal and Node.js Angular Universal

    Cookies are a ubiquitous feature of web applications, as anyone clicking GDPR notifications for the last several months has realized. Securely handling the data in those cookies is just as much a requirement as the consent notification. Encrypting your Angular and Node.js application cookies is a way to prevent unauthorized access to confidential and personal information, and it’s easy to implement.

    As you know, using an httpOnly cookie helps prevent cross-site scripting (XSS) attacks. (You can learn more in another post.) But what about protecting one registered user’s data against another registered user? Are cookies vulnerable to attacks from trusted users?

    This post will demonstrate how authenticated users can get unauthorized access to other users’ cookie data. It will also show you how to encrypt your cookies so the data can only be read by your code, not by users.

    The code in this post uses the ...

    Read More
  • By Maciej Treder
    Building Expedited Two-Factor Authentication into Angular Apps with Authy Angular and Twilio logos

    Two-Factor Authentication (2FA) provides web applications with an important additional layer of security, but 2FA requires the user to perform an additional action each time they log in. This extra step can be wearying for users who sign into an application frequently. Is it possible to maintain the security provided by a second factor while making an application convenient for repeat visitors? It is with Angular, Node.js, and Twilio Authy.

    Implementing a “remember me” checkbox on the login page is a convenient way for a user to indicate they are going to be a repeat visitor. Behind the scenes, an encrypted security cookie is a convenient mechanism for identifying a user who has previously checked the “remember me” box and logged in successfully from a specific machine.

    With Twilio Authy and an encrypted cookie, such as a JSON Web Token (JWT), you can make the sign-in process fast and ...

    Read More
  • By Maciej Treder
    How to Transfer Files and Data Between Angular Clients and Node.js Backends scuYOAhIEQ4GEH19vMrkLXpit7Ajvupr2OCDcoUBbmZ3txEtpae8CAfBA9Hu2kkQk8B60YVwNeDBu-EbZO9F7sk4fDibyz5aVm2-V-y8JXCB5C5qe16XjTGbB7Um9GgPnUClUzZ2

    Having a shared codebase for both the server-side and browser-side code of an Angular application aids the maintainability of a project. You can do that with Angular Universal and Node.js using the server-side rendering (SSR) concept. You can even use SSR to securely pass data, including files, between the application server (Node.js) and the Angular application running on it.

    This post will show you how to create an application for uploading, storing, managing, and downloading files from a Node.js server using a single codebase. When you finish this project you’ll be able to:

    • Create an Angular application
    • Set up server-side rendering with Angular Universal and Node.js
    • Implement file transfer operations
    • Create a dynamic, in-memory list of files
    • Pass data about storage content between the server application and the JavaScript used by Angular for SSR

    To accomplish the tasks in this post you will need the ...

    Read More
  • By Maciej Treder
    Build Two-factor Authentication in Angular with Twilio Authy Y8iaichVZvJMIIzZ-Bghjj0321PVkb8TkqdFwexxbf9-wZjp5JHbmtJJ_yc2GPPFMDpw3ZWW3NJXZNiPpiUBFtt3pu16hJrY7JU0jn7O8cWf7-WR88AySSuEmfah9qbrsjJdHuug

    User authentication is a crucial requirement for many Angular applications and simply logging in with user ID and password is increasingly inadequate security. Two-Factor Authentication (2FA) provides device-based security that is substantially more difficult to hack, but building your own 2FA system is a daunting challenge. Twilio Authy makes it easy to add 2FA to Angular apps.

    This post will show you how to add Authy to your Angular project. You’ll also learn how to improve the user’s experience and your app’s security by using Angular Universal to implement the login process.

    In this post we will:

    • Create a basic Angular application with a login page
    • Set up an authorization guard service and an authorization service
    • Add server-side rendering with Angular Universal
    • Set up server-side authentication
    • Implement two-factor authentication with Twilio Authy

    Prerequisites to build with Angular and Authy

    To accomplish the tasks in this post you ...

    Read More
  • Newer
    Sign up and start building
    Not ready yet? Talk to an expert.