Code with Hugo: JS & Node.js in Prod logo

Code with Hugo: JS & Node.js in Prod

Subscribe
Archives
February 25, 2019

Express body-parsing with no dependencies - Code with Hugo - Feb 25th 2019

Hot off the press

Parse POST/PATCH/PUT request JSON body with Express and no dependencies: I discovered that Express 4.16+ had a built-in JSON body-parser express.json(), here’s a post about how to use it (and ditch body-parser 🤞).

Here’s the moment I first heard about it:

Hugo
@hugo__df

TIL you can use express.json() instead of bodyParser.json(), and miss out on adding body-parser as a dependency. It parses JSON bodies into req.body Express 4.16+ #node #100daysofCode #CodeNewbie


Feb. 18, 2019, 9:07 a.m.

See the codesandbox for that post https://olrn6x3n19.sse.codesandbox.io/

Or run the curl yourself:

$ curl --request POST \
  --url https://olrn6x3n19.sse.codesandbox.io/test \
  --header 'content-type: application/json' \
  --data '{
    "json-parsing": "just with Express",
    "no": "body-parser"
}'

{"json-parsing":"just with Express","no":"body-parser"}

If you missed it

12-factor Node.js application configuration management without the config npm package: Node.js config management done right and my issues with theconfignpm package in the context of trying to keep your application 12-factor

A guide to Express request and response mocking/stubbing with Jest or sinon.

“Testing an Express app with SuperTest, moxios and Jest”.

From the web

Managing JavaScript in the Enterprise: a post about what npm is doing for the enterprise use case.

GitLab might move to a single Rails codebase: GitLab’s musings around keeping their two application (Community Edition and Enterprise Edition) repositories in sync and how they’ll move to a single repository.

Incrementally migrating over one million lines of code from Python 2 to Python 3: Python 2 is coming to end of life, how Dropbox are migrating from Python 2 to 3 (an effort they started in 2015).

Don't miss what's next. Subscribe to Code with Hugo: JS & Node.js in Prod:
Powered by Buttondown, the easiest way to start and grow your newsletter.