TypeORM: Adding created_at and updated_at columns

February 6, 2022 A Goodman

In TypeORM, you can add a created_at column and a updated_at column by making use of the CreateDateColumn and UpdateDateColumn decorators, respectively. These columns will be automatically initialized and updated to the current date and time…

Node + TypeScript: Export Default Something based on Conditions

February 4, 2022 Pennywise

There might be times when you might want to export something based on one or multiple conditions (for example, you want to export configuration information like database, API keys, etc for development environment and production environment)….

2 Ways to Set Default Time Zone in Node.js

February 4, 2022 Pennywise

This short article walks you through 2 different ways to set the default time zone in Node.js. The first approach is to modify the TZ environment variable and the second one is to make use of…

Node.js: How to Compress a File using Gzip format

November 29, 2021 A Goodman

In Node.js, you can compress a file using the Gzip format by using streams. We can get the job done with just a few lines of code and there is no need to install any third-party…

Node.js: The Maximum Size Allowed for Strings/Buffers

November 29, 2021 Guest Contributor

Buffers and strings in Node.js are limited in size. The actual maximum size of a buffer or a string changes across platforms and versions of Node.js. You can check yours as follows: Here’s my output: Further…

4 Ways to Read JSON Files in Node.js

November 23, 2021 A Goodman

This article walks you through a bunch of different ways to read JSON files in Node.js. Without any further ado, let’s get our hands dirty by writing some code. Getting Started This is the sample JSON…

Node.js: Using __dirname and __filename with ES Modules

November 18, 2021 A Goodman

If you’re building a Node.js application with ES modules instead of CommonJS modules (“import” instead of “require”, in simpler terms), you have to do something before writing __filename and __direname in your code. The Problem In…

Tweaking a Node.js Core Module

November 18, 2021 The Plumber

The example below shows you how to change the behavior of a Node.js core module by modifying or extending it. What we are going to do should not appear in serious products but might be somehow…

Node.js: Getting User Input from Console (2 approaches)

November 18, 2021 A Goodman

This article walks you through a couple of different ways to get user input from the console in a Node.js program. The first approach is to do things from scratch with only built-in features of Node.js….

Node.js: Use Async Imports (Dynamic Imports) with ES Modules

November 17, 2021 Pennywise

Overview Nowadays, many modern Node.js applications use ES modules (that go with the import keyword) instead of CommonJS modules (that go with the require keyword). When working with ES modules, there might be scenarios where you…

How to Install Node.js on Ubuntu 21.04 and 21.10

November 14, 2021 Pennywise

This article shows you how to install Node.js and NPM on Ubuntu 21.04 (Hirsute Hippo) or Ubuntu 21.10 (Impish Indri). Our goal is to get the LTS (the long-term support version, which is officially recommended for…

Node.js: Generate Images from Text Using Canvas

November 10, 2021 A Goodman

The example below shows you how to programmatically generate images from text in Node.js by using the canvas library. Example Here’s the image we are going to “draw” with code: The code 1. Install the library:…

1 2 3 4 5