Express parameter callbacks

Handy little feature I didn’t know about in Express:
Using app.param([name], callback) you can bind callbacks directly to route parameters, allowing you to move common preprocessing/validation out of each function that uses the parameter, and into a single function (without having to call it explicitly each time.)
You can pass in an array of names, using next() to jump to the next parameter, and the callback is only called once regardless of how many times the parameter appears in route handlers.
The callbacks are local to the router they are defined on, so you can handle things (or not) differently based on the context.

Developing a node app in docker


We want to rapidly develop our node app inside a docker container, being able to install modules, make code changes, and see instant results. The problem is that while the official node image supports a handy onbuild feature which will grab the package.json and install everything we need, this also means having to rebuild the image every time a dependency changes.


Use this image, which places the node_modules folder one level higher, meaning it isn’t overwritten by the docker mount, and you can still mount and install your own node modules on the fly.


An easier but less obvious way to solve the problem is to specify your /usr/src/app/node_modules folder as a volume with no mapping to the host. This preservers the container copy and allows you to keep your local copy