Composability
Learn how to compose streams by adding client-side encryption and server-side decryption.
We'll cover the following
The code we’ve seen so far has already given us an overview of how streams can be composed thanks to the pipe()
method, which allows us to connect the different processing units, each being responsible for one single functionality, in perfect Node.js style. This is possible because streams have a uniform interface, and they can understand each other in terms of API. The only prerequisite is that the next stream in the pipeline has to support the data type produced by the previous stream, which can be either binary, text, or even objects.
To take a look at another demonstration of the power of this property, we can try to add an encryption layer to the gzip-send/gzip-receive
application that we built previously.
In order to do this, we’ll need to apply some small changes to both our client and server.
Adding client-side encryption
Let’s start with the client.
Get hands-on with 1400+ tech skills courses.