All Dressed Programming

Create CLIs For 2023 Using Deno

Introduction We are in 2023 and my world still evolves around CLIs1. I enjoy looking at my terminal and piping commands together. Knowing how to do stuff with CLIs is empowering and gives the impression of really understanding how things are built under the hood. At work, I like to create a CLI where I put all my utilities bundled in a single executable. Usually, the CLI starts as a bunch of aliases and evolves into a complex tool that is used by many people.

Returning Lists Of Items In JSON APIs

It happens often that we need to implement an endpoint that returns a list of items with a “canonical” id. A typical example is a /users endpoint that returns a list of users. In this post, I will advocate for returning a list of objects each of which contains an id key and not a single object where ids are associated with their canonical values. // Good [ {id: 1, name: 'Emelia', age: 12}, {id: 2, name: 'Cassidy', age: 96} ] // Bad { 1: {name: 'Emelia', age: 12}, 2: {name: 'Cassidy', age: 96} } Communicate Intent The first reason to return a list of items is that, semantically, it is what the endpoint returns.