Node.js Weekly Update - 9 June, 2017

Below you can find RisingStack's collection of the most important Node.js updates, projects, tutorials & Node related conferences from this week:

1. Node.js 8: util.promisify()

Node.js 8 has a new utility function: util.promisify(). It converts a callback-based function to a Promise-based one.

Learn how to use it.

2. Running a Node server on a Raspberry Pi with a physical button

All the pieces needed to set up a Raspberry Pi with a physical button. Covers buying hardware, running a Raspberry Pi, wiring up a physical button, using the latest Node and npm, and creating a Node server to send a text message when the button is pressed.

It works! You press the button and it sends me a text message from my dog saying "I need to go to the bathroom!". It would be cool to additionally 3D print a case and button surface area extending disc, but the functional pieces are here.

3. Node.js + MySQL Example: Handling 100's of GigaBytes of Data

This Node.js + MySQL example tutorial shows how you can efficiently handle billions of rows that take up hundreds of gigabytes of storage space.

Node.js MySQL Tutorial

Most think if anyone has millions/billions of rows, they should use a NoSQL solution such as Cassandra or Mongo. Unfortunately, these solutions are not ACID compliant which makes them difficult to use when data consistency is extremely important.

However, with good indexing and proper planning, MySQL can be just as suitable for the task as the above-mentioned NoSQL alternatives.

4. Integrating OpenWhisk with Your Node Application

Imagine a simple Node application that performs a set of functions. It’s possible you may migrate one or more of those functions into serverless.

Node.js OpenWhisk Integration

Embracing serverless isn’t about destroying every single server you have left, and there are some things that simply don’t make sense in serverless. So I thought I’d build a simple Node app that demonstrated how this could look.

5. JavaScript’s new #private class fields

What they are, how they work, and why they are the way they are.

Private class fields are now at Stage 2 in the JavaScript standard process. It’s not finalized yet, but the JavaScript standards committee expects the feature to be developed and eventually included in the standard (although it may still change).

6. Understanding lock files in NPM 5

The next major version of NPM brings a number of improvements over the previous versions in terms of speed, security, and a bunch of other nifty things. What stands out from the user’s perspective however is the new lock file. Actually lock files.

npm 5 lockfile

As opposed to the previous version, the lock file now includes an integrity field which uses Subresource Integrity to verify that the installed package has not been tempered with or is otherwise invalid.

What the file now doesn’t have is the from field which together with the sometimes inconsistent version has notoriously been a source of pain when looking at the file’s diff during code reviews.

7. Upgrading from Node 6 to Node 8: a real-world performance comparison

Node 8 is out, did you hear? And it’s faster, or so they say. But without any numbers, ‘faster’ is just letters.

Node.js 8 Performance Improvement

To be honest, with Node 8 I was expecting an improvement of maybe a few percent, and wouldn’t have been surprised if that didn’t translate into the real world. But shaving a quarter off server-rendering time and a third off NPM install time is amazing.

Node Core Changes:

⬢ Node v8.1.0 (Current)

  • Async Hooks
  • When one Promise leads to the creation of a new Promise, the parent Promise will be identified as the trigger
  • Dependencies
  • libuv has been updated to 1.12.0
  • npm has been updated to 5.0.3
  • File system
  • The fs.exists() function now works correctly with util.promisify()
  • fs.Stats times are now also available as numbers
  • Inspector
    • It is now possible to bind to a random port using --inspect=0
  • Zlib
  • A regression in the Zlib module that made it impossible to properly subclasses zlib.Deflate and other Zlib classes has been fixed.

⬢ Node v6.11.0 (LTS)

  • build:
  • support for building mips64el
  • cluster:
  • disconnect() now returns a reference to the disconnected worker.
  • crypto:
  • ability to select cert store at runtime
  • Use system CAs instead of using bundled ones
  • The Decipher methods setAuthTag() and setAAD now return this.
  • adding support for OPENSSL_CONF again
  • make LazyTransform compabile with Streams1
  • deps:
  • upgrade libuv to 1.11.0
  • upgrade libuv to 1.10.2
  • upgrade libuv to 1.10.1
  • upgrade libuv to 1.10.0
  • dns:
  • Implemented {ttl: true} for resolve4() and resolve6().
  • process:
  • add NODE_NO_WARNINGS environment variable
  • readline:
  • add option to stop duplicates in history
  • src:
  • support "--" after "-e" as end-of-options
  • tls:
  • new tls.TLSSocket() supports sec ctx options
  • Allow obvious key/passphrase combinations.

Node.js Related Conferences

Source: The Node Foundation Newsletter

Previously in the Node.js Weekly

In the previous Node.js Weekly Update we read about Node 8 & npm 5 being released, Mikeal Rogers steps down, a great N-API tutorial, and on-premises Node monitoring announced by RisingStack.

We help you to stay up-to-date with Node.js on a daily basis too. Check out our Node.js news page and its Twitter feed!