Extracting configuration and secrets
Any application, independent of its dimension, will have configuration parameters. By looking at the application we've been building in the previous chapters, even if we look at the simplest version of them all—the Hello World web server—we'll find configuration values, such as the port
value.
It's also not a coincidence that we're sending a full object called configuration
inside the createServer
function, the function that starts up the web server. At the same time, we also have a couple of values that we know should be secret in the application. They're currently living in the code base, as it's been working for our purpose (which is learning), but we want to change it.
We're thinking of things such as the JSON Web Token (JWT) encryption keys, or the MongoDB credentials. Those are definitely not things you want to check out into your version control system. This is what this section is about...