Skip to main content

Node.js error code `ERR_OSSL_EVP_UNSUPPORTED`

· 3 min read

TL;DR

Problem

Error in Node.js output

Error: error:0308010C:digital envelope routines::unsupported

Easiest solution

Create a .npmrc file in the root of the project (same location as your package.json file) with following contents:

node-options="--openssl-legacy-provider"

TypeScript object types with optional and minimally required properties

· 2 min read

TL;DR

// Solution 1
type LabelEntry = { label: string };
type ImageEntry = { image: string };
type Entry = LabelEntry | ImageEntry;

// Solution 2
type Entry = Record<'label' & 'image', string>;

An object type that I find myself creating very frequently is one that has one or all of several properties. For example, I can create an entry with a text label, one with an image, or one with both:

Auto-increment field with Prisma

· 2 min read

SELECT setval(pg_get_serial_sequence(&#39;tablename&#39;, &#39;id&#39;), coalesce(max(id)+1, 1), false) FROM &quot;tablename&quot;;

This post is a knowledgebase article on Prisma with PostgreSQL.

The typical model in a Prisma schema has an id field that auto-increments:

model User {
id Int @id @default(autoincrement())
name String
}

The following is working (most of the time) code that inserts a new entry:

prisma.user.create({
data: { name: 'Some User' },
});

However, the following error may occur:

Unique constraint failed on the fields: (id)

This is baffling - if the field auto-increments, how can the unique constraint be violated?

Docusaurus with Google Authentication

· 5 min read

With a little bit of programming, your site made by Docusaurus can be modified to be accessible only to users signed in to Google.

The source material came from this article by Thomasdevshare. His article describes a similar authentication scheme for Docusaurus with Firebase as the identity provider whereas this article describes the same approach using Google API directly.

Leaving My Company

· 9 min read
photo of a balloon in Orchard Road, Singapore
Photo credit: Chua Chee How

Two months ago I left the company which I co-founded 13 years back. Here are some of my takeaways after 13 years as its CTO.