Fetching the latest release of a GitHub package with Cloudflare Workers

There's an example of this worker up at https://mod.jpwilliams.dev/github-release-version that can be used for any package like so: https://mod.jpwilliams.dev/github-release-version/jpwilliams/midi-mixer-releases. When creating the website for MIDI…

Nullish Short-Circuit Assignment in TypeScript 4.0 (beta)

On June 26th 2020, TypeScript 4.0 Beta was announced. The update brings a myriad of useful changes, but one such addition is something you'll quickly get in to the habit of using every day: Nullish Short-Circuit Assignment. You've used a += b before…

How to unpack the return type of a Promise in TypeScript

TypeScript 4.5 (released on November 17th, 2021) introduced the Awaited type that solves this problem. If you can use Awaited, use that instead of the below method. - edited 1st December, 2021 While making @jpwilliams/distributed-promise I came…

🔗
🔗

Using EventEmitters to resolve Promises from afar in Node.js

A common-but-powerful pattern I've come to frequent is the utilisation of EventEmitter alongside a Promise, enabling me to resolve said promise from an entirely different part of my code base. To demonstrate, let's revisit the basics of both an…

Modularising GraphQL for scale

When fiddling around with GraphQL projects, I've frequently found it difficult to know where things should go. Just like naming variables, naming and placing files is hard. The simplest method here is to bundle everything in to one file, but that…

🔗
🔗

It's all about trade-offs

I recently had a great discussion regarding WebSockets and HTTP/2 with a former colleague. During the discourse, they uttered one line so deeply-set in truth that it must be shared. Repeatedly. "It's all about trade-offs." As someone who has been…