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 »

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 »

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 »