IMHO articles like this played a major role in Node's initial success. After years of working with ever-growing frameworks with huge learning curves, it was so refreshing to get your first thing running in few seconds. Felt like basic in the 1980s or PHP in the late 1990s.
Not 100% related to the article but koa with its maybe 300 LoC is hardly a dependency. However in general nodejs projects definitely suffer from dependency bloat. I encourage anybody to try for themselves to go through node_modules in their own projects, it’s quite englightning to see the scale of the unnecessary, duplicated, reimplementated in different ways crap there. Conscious aim at shallow, minimal or no dependency in packages and end apps is definitely something good; less than 5s installs, code audits, more healthy projects in general. I’m not saying it’s always possible or better to trim the code fat, but if you’re aware of dependency tree single root dep introduces you’re usually able to cut it down a lot.
Great article. Anyone working with Node.js should be familiar with these fundamentals. It also demonstrates the simplicity (and dare I say "elegance", though that's subjective..) of Node.js and its concepts.<p>These days my favorite library for writing an HTTP server is micro [0] (and a few middlewares). I like how it provides a minimal, functional layer of abstraction.<p>[0] <a href="https://github.com/zeit/micro" rel="nofollow">https://github.com/zeit/micro</a>
There are <i>a lot</i> of gotcha's when rolling your own web server based on the http and https packages and I think the conclusion of the article could have gone further in addressing what they are and in what context they might matter. I recently wrote a little zero-dependency NodeJs http/s server[1] with an equally dumb router for some dev tools which could benefit from a simple, promise based api, for most other use cases I'd just pull in express or something more mature.<p>[1]<a href="https://github.com/8eecf0d2/decade" rel="nofollow">https://github.com/8eecf0d2/decade</a>
Love this. There was this project along the same lines, from the olden days of node:<p><a href="https://github.com/Raynos/http-framework" rel="nofollow">https://github.com/Raynos/http-framework</a>
It's nice to get away from frameworks from time to time. If anyone is interested in something similar written in Java I recently created a couple of examples based on Undertow. They are available at <a href="https://github.com/tofflos/undertow-examples" rel="nofollow">https://github.com/tofflos/undertow-examples</a>.
Performance is also a major advantage. Express is extremely slow compared to a basic "native" API without dependencies. If you check out the results in numbers, you'll be amazed.
The crimes of these kinds tutorials:<p>- Downplaying the role of error handling<p>- Treating the subjects they cover as a black box<p>- Not warning that the code examples are not suitable for production