The Node.js Update #Week 22 of 2019. 31 May

Below you can find a collection of the most important Node.js updates, tutorials & announcements from this week - curated by RisingStack's Node.js Developers.


Node v10.16.0 (LTS) Released

  • deps:
  • update ICU to 64.2
  • upgrade npm to 6.9.0
  • upgrade openssl sources to 1.1.1b
  • upgrade to libuv 1.28.0
  • events: add once method to use promises with EventEmitter
  • n-api: mark thread-safe function as stable
  • repl: support top-level for-await-of
  • zlib: add brotli support

Turn JavaScript Functions into Typed HTTP APIs

FunctionScript is a language and specification for turning JavaScript functions into typed HTTP APIs. It allows JavaScript (Node.js) functions to be seamlessly exported as HTTP APIs by defining what the HTTP interface will look like and how it behaves in the preceding comment block - including type-safety mechanisms.

Demo

FunctionScript is intended to provide an easy introduction to API development for those of any skill level, while maintaining professional power and flexibility.


Javascript: Understanding async/await

async/await makes it easier to work with asynchronous code in javascript. Understand how it works and why we should use it is important to get the best out of it. Advantages of async/await:

  • Clean code: As can be seen from the files example, async/await really makes the code cleaner and easy to read.
  • Error handling: We can handle both asynchronous and synchronous errors using try/catch in an async function as can be seen in the files example above.
  • Debugging: When debugging then chains, if you place a breakpoint inside a then function and then step over the code, it will not go into the next then function since step overs only work with synchronous code. With async/await it will step over awaits just like it does in synchronous code.

PM2 caused thousands of CI builds to Fail

So pm2 (a node process manager package on npm) just caused thousands of CI builds to fail because of an "optionalDependency" on a package called gkt which is requested as a tarball from a server that was returning 503. That package consists of one file which contains this:

JavaScript Try Catch & Error Handling ES6 Tutorial (2019)

If you want to know how to use try catch in JavaScript and how can you use error handling in this video you will learn the most important things that you should know about.

We are going to go through the structure of a try catch and what happens when we have nested try-catch blocks in our code.We are also going to see what errors can we have in JavaScript and how can we build custom errors ourselves.


Build a Social Network in JavaScript with Graphs!

How would you design the data structure for a very large social network like Facebook or Linkedin?

Such kind of question is known to be asked by top-tier tech companies like Google, Amazon, Facebook and Linkedin as part of their recruitment process.

The reason is, that social networks are a great use case for graph data structures. In this tutorial, we will dive into the topic with an hands-on example and build a social network ourselves! Thereby, we will learn how a graph works and why it’s such an important and powerful data structure.


Fullstack CRUD application using Fastify, React, Redux & MongoDB Part-1

In today’s tutorial we’ll be building a Fullstack Application using Fastify, React, Redux and MongoDB, which would support all CRUD functionalities.

The application that we are about to built is a simple menu app that lists all the menu items currently present in the database. In this application you would be able to create menu items, which could hold details like item-name and item-price. You could also modify them or even delete them.


Hooks — A truly modular Node.js App

@forrestjs/hooks is a small library that enables traceable composability in your Javascript application. It enables a clear separation of responsibilities in your code. And by the way, “Single Responsibility Principle” and is one of the most important things you can learn for engineering and Life.


Task Scheduling with Node.js and Redis

At uSTADIUM, we use a task scheduling system for sending thousands of push-notifications. The need for a task queue and scheduler wasn’t obvious at first. Our server would process notifications as they were needed during a request. Over time, this load began to overwhelm the system.

‌I wasn’t sure how to fix it so it was an interesting journey solving this problem. In this article, I’ll discuss this method, how we built it using Redis, and our experience as the system scaled.