Skip to main content

Paul Armstrong

Random thoughts from a Software Engineer specializing in Node.js, JavaScript, and all things web.

· 4 min read

With any server, you need to ensure that you don't have run-away requests that end up getting stuck in an infinite process, held in memory for long periods of time. Typically, the requester will abandon the request if it is taking too long, perceptually, to respond.

Express in a node.js server doesn't handle this by itself. Instead you need to add something like the connect-timeout middleware. However, the default example for this leaves you open to forgetting to add the timeout check within your middleware chain.

import express from 'express';
import timeout from 'connect-timeout';

function haltOnTimedout (req, res, next) {
if (!req.timedout) next()
}

const app = express()
.use(timeout(5_000))
.use(bodyParser())
.use(haltOnTimedout)
.use(cookieParser())
.use(haltOnTimedout)

Notice that you need to manually add the haltOnTimedout middleware after each other middleware in the chain. This may be fine and dandy for a small personal project that you, as the sole developer, know all about. However, as you start distributing knowledge to a larger team, it's imperative that this is easy and automatic. There are few, if any, cases where you would want to opt-out of the behavior of timing out a request if it's taking too long.

· One min read

There was a shooting in my town last night.

It hurts to hear about each and every one of these. Many others probably feel the same, but there’s something different about needing to text your family and friends so they know you’re okay.

I can’t imagine how it feels to be on the other side waiting to get a message that your loved one is safe – only to never hear back.

Something must be done. It needs to be drastic. People will scream about hundred year old laws – laws that are not needed today – laws that we need the opposite of today.

Please: no more guns.

· 5 min read
Paul Armstrong
Multi-part series

In the introduction to this series, we covered the rationale for building a custom wedding website, as well as the requirements that we laid out for ourselves.

Now that we know what we need, it’s time to choose the right tools for the job. From our previously set requirements, the following items stood out as important for what we choose here:

  • Free or very cheap hosting with a custom domain and SSL
  • Invitees must be able to
    • Sign in with their email address and no password (magic link email)
    • Receive automated emails for their invitation and RSVP confirmation
  • All significant information must come from a protected database