How To Send HTML Email in Node.js

If you reading this to learn how to send the beautiful HTML email you just finished designing, you’ve already done the hard part. While designing HTML email is a pain, sending HTML email may required an additional step or two than what you’re used to but it’s still super easy.

Read more »

Allow Public Access To Private Files In An AWS S3 Bucket

For security purposes you may not want objects stored in your AWS S3 buckets to be publicly accessible (and by default, all objects in S3 are private). However, you likely still need to be able to serve them to properly authenticated users. This can be done by utilizing pre-signed URLs.

Read more »

Create CSV Files With Node.js

More often than I care for I find myself needing to write data to a csv file. This certainly falls under the “less than interesting” category of things I work on, but you have to take the good with the bad, I guess.

Read more »

Dynamic 'Where' Clauses With Parameterized Queries in Node.js and MySQL

Occassionally when writing SQL queries the number of fields that we need to filter on may change depending on user selection. Let’s take a look at how we can build dynamic ‘where’ clauses and the corresponding parameter array to handle this scenario.

Read more »

Test JWT-Authenticated Express Routes with Jest And SuperTest

So you have decided to use JSON Web Tokens (JWT) to secure your API, or you are already using JWT and need to add some unit tests for your routes, and you are a little unsure how to acquire, store, and pass the required token to complete the test. Let’s take a look at how to do this using Jest and SuperTest.

Read more »

Need To Allow Public Access To Localhost? Check Out Ngrok

During the development process there may be times when you need to allow public access to your local development environment. You may want to demo your progress to a client or test an incoming webhook, for example. With ngrok (https://ngrok.com) there is no need to push to production or some other public facing environment in order to accomplish this.

Read more »

Force File Download From Amazon S3 With Node/Express

Generally, when content is returned from a web server to a browser it is intended to be displayed inline, meaning rendered as a web page or as part of a web page. This is especially true for file types such as images, html documents, PDF documents, etc. that can be rendered natively by web browsers. There are times, however, when we would rather have the user be prompted to download and save the file locally. Here is a quick look at how we can send files from S3 (or other remote locations) to be downloaded and saved locally on the client.

Read more »

Maintain Environment Configuration Settings and Secrets in Node.js Apps

It worth it to invest some time reaching a good solution for managing environment configuration settings and secrets for your apps to support multiple runtime environments (development, production, staging, etc) and multiple developers. These settings will likely require different configurations, depending on environment and/or developer, for things such as database connection information, log settings, API keys, usernames, passwords, etc. Additionally, we need to keep some of this information from being included in the codebase or repository but still be easily maintained. Let’s look at 2 packages that when used together create a nice solution to this problem.

Read more »

How To Upload Files With React To A Node/Express Server

Handling file uploads in a React/Node/Express application is done a little different on both the server-side and client-side than what you may be used to doing when handling regular form submissions. In this post we’ll take a look at code on the server and client for uploading a file from a React application and saving the file on the server using Node.js and Express.

Read more »

How To Install The Latest Version of Node.js on Ubuntu

Here is a quick and easy way to install the latest version of Node.js on an Ubuntu system. As with many things in the JavaScript world there is more than one way to do this, but for getting up-and-going quickly it’s hard to beat n.

Read more »

Search and Split PDF Files With Node.js

So much of my work is web development related that when something different comes along I can geek out on it pretty hard. It’s even better when it’s an opportunity to save our organization money. A recent need for a command line script to search and split a PDF file satisfied both.

Read more »

Performing 'like' Queries Using the MySQL Package in Node.js

The MySQL package is a hugely popular library for working with MySQL from Node.js, and with good reason. It’s performant, easy to use, battle tested, and well documented. I was a bit surprised, however, that the documentation doesn’t show the syntax for performing parameterized ‘like’ queries.

Read more »

A Dynamic Catch-All Route Handler For Rendering Views in Express.js

I was recently working on a demo project and found myself constantly creating and deleting views. Rather than having to keep updating my routes I wondered if I could create a dynamic route handler that would match a view with a requested route.

Read more »