Upgrading Sapling to Express 5

Upgrading Sapling to Express 5

I upgraded Sapling to Express 5 today. Things were mostly straightforward. I did hit a couple small snags.

Weird Error From Not Using Wildcards Correctly

You get a misleading error (shown below) if you don't replace all of your wildcards (*s) with named wildcards. They syntax for named wildcards is literall /*splat where you can replace "splat" with any name. These work like parameters (/:a/:b) except that they apply across path segments. The error comes from path-to-regexp which is what Express uses for path matching under the hood.

TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError at name (/home/david/mono/node_modules/path-to-regexp/src/index.ts:153:13) at lexer (/home/david/mono/node_modules/path-to-regexp/src/index.ts:171:21) at lexer.next (<anonymous>) at Iter.peek (/home/david/mono/node_modules/path-to-regexp/src/index.ts:188:32) at Iter.tryConsume (/home/david/mono/node_modules/path-to-regexp/src/index.ts:195:24) at Iter.text (/home/david/mono/node_modules/path-to-regexp/src/index.ts:213:26) at consume (/home/david/mono/node_modules/path-to-regexp/src/index.ts:285:23) at parse (/home/david/mono/node_modules/path-to-regexp/src/index.ts:320:18) at /home/david/mono/node_modules/path-to-regexp/src/index.ts:503:40 at Array.map (<anonymous>)

req.host Became req.hostname

I use vhosts, and in certain places I check the hostname against a permitted list of vhosts. req.host now includes the port and req.hostname does not, so I had to update it.

Stay up to date

Get notified when I publish something new, and unsubscribe at any time.