'Using Nodejs to stream GIF count down timer to client

I need a countdown timer in my email. The only way I know it's possible is to use the img element and point to a server in my src attribute that returns a stream of say GIF encoded data. I went ahead and built it out and most of it works. However, when the timer updates, I am not seeing the changes being consumed in my stream. Please help!

My code is here: https://github.com/ElijahCannon/email-countdown.git

I think I'm not understanding something in the timer.js update() method, do I use canvasStream.on with events, or do I use pipe? I wasn't able to get as far just using pipe(), but maybe that's because I'm using the wrong stream types? My temporary stream (created every update) is a readableStream (https://github.com/Automattic/node-canvas#canvascreatepngstream), and my main stream piped to res is a duplex stream.

Any insight you can provide would be very helpful. Streams are a very confusing topic for me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source