Configuring your server for different environments

No matter what you develop, it's certain that you'll work at least with a couple of environments, development and production, and settings for your code won't be the same. For example, you won't use the same configuration for security, to access a database, to log errors, or to connect to analytics services, and so on: when running in your development environment, you'll need a certain setup, and for production there may be many changes. 

You could set everything up in your code, but having users, passwords, IPs, and other sensitive data in plain text and saved in a source code repository that might get hacked isn't a good recipe for security. You should deal exclusively with your development configuration and leave the actual deployment to production to a different team, which will safely deal with that configuration.

Node lets you access environment variables and use them for configuration so that you can move that setup outside of your code. In this chapter, let's look at some ways to deal with all this, which will also indirectly help with our testing, later in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset