In this tutorial I’ll show how to piece together the required NPM modules to build a REST API in Node.js with proper Swagger documentation. We’re going to use Express as the HTTP framework, and the Swagger documentation will be written as inline comments within the code, as close as possible to the handling endpoint or models that will implement the contract, so it will be harder for them to eventually diverge.
Every single working day I spend between 2 and 2.5 hours in a train. And I feel pretty lucky about this, mostly because is one single train, no need to pay attention for switch overs or other kind of public transports, and that allows me to invest that time in whatever task I want: podcasts, videos, blogging or even programming. And that’s what I want this post to focus in, because there are plenty of posts that explain how to use a Chromebook for day-to-day tasks (even being offline) but not that many that talk about programming in node.
During last year, I had the chance to work as CTO of a startup, working mainly within MEAN stack. I was happy, the technology I was working with was in a great hype and its community grew bigger and bigger with lots of projects popping up everywhere. But life is continuously changing, and I started to work in a new company within Java/JEE technologies. I was back to my first days as a professional computer engineer.
Code modularization, achieved in one way or another, is a technique a good developer must aim for because it helps keeping things small, well-tested and organized. And of course, it follows the DRY directive. So as a Node.js developer (and maybe contributor to the Open Source), creating and publishing an NPM module is one of those steps you will eventually face. Probably if any Node.js developer would have to pick an indispensable tool of the ecosystem, npm would win by far.
The Node.js ecosystem is quite young and prolific: new tools appear almost every day or week, changing and turning upside down your current workflow, always trying to squeeze a little more productivity to your time and effort or simply making your work easier. As an example, take a look on the NodeFramework page, where Azat Mardanov (@azat_co) collects lot’s of frameworks and utilities related to Node.js. Or NodeWebModules, more web oriented than the previous one, from Caio Ribeiro Pereira (@crp_underground).