Express.js Tricks Extended - Code with Hugo - May 13th 2019
An update to the Express built-in body-parsing middleware post to fix my misinterpretations, add some structure and show how to parse urlencoded bodies.
Hot off the press
Read and parse POST/PATCH/PUT request JSON or form body with Express and no dependencies: body-parser is a dependency of Express and its main JSON parsing and url encoded body parsing functionality is exposed as express.json() and express.urlencoded() ie. middleware for parsing the most common request bodies is built into Express.
Examples of use in projects, express.urlencoded
at github.com/HugoDF/express-nunjucks-tailwind/blob/master/server.js, express.json
at github.com/HugoDF/express-postgres-starter/blob/master/server.js.
If you missed it
An enterprise-style Node.js REST API setup with Docker Compose, Express and Postgres: The why and how of an enterprise-style Node.js application.
Jest assert over single or specific argument/parameters with .toHaveBeenCalledWith and expect.anything(): With Jest it's possible to assert of single or specific arguments/parameters of a mock function call with .toHaveBeenCalled/.toBeCalled and expect.anything().
Docker Compose Local HTTPS with nginx or Caddy and mkcert: A solution to serve your Dockerized application on Docker Compose with TLS/SSL locally by leveraging a HTTPS reverse-proxy and mkcert.
Mocking/stubbing ES6 classes in tests with examples of Sequelize model unit tests: This post goes through some patterns that can be used to unit test ES6 classes.
From the web
Fix Like No One’s Watching by Dan Abramov (at https://overreacted.io): Some technical debt is in plain sight. An inadequate data structure might lead to convoluted code. When the requirements keep changing, the code might contain traces of previous approaches. Sometimes the code is written in a hurry or is just sloppy.
The Principal Developer by Bennett Miller: Today I had a phone conversation with my ex-colleague Alex. Alex works as a software developer in a fast-growing international organization. Alex: “I did, but my application has been rejected. CTO believes that I am not qualified for that role. He is searching for a better candidate.”
A Conspiracy To Kill IE6: The bittersweet consequence of YouTube’s incredible growth is that so many stories will be lost underneath all of the layers of new paint. This is why I wanted to tell the story of how, ten years ago, a small team of web developers conspired to kill IE6 from inside YouTube and got away with it.