Managing server tier environments
An application can go through multiple stages throughout its life cycle—two of the most common stages would be development and production. Specific configurations can be set up to host the app in its various stages. These configured habitats are known as server tiers or environments.
Development and production codes have different requirements. For instance, during development we will most likely want a detailed error output to the client, for debugging purposes. In production, we protect ourselves from opportunistic exploitation by revealing as little internal information as possible.
Express has an env
setting that determines its value from an operating system environment variable, NODE_ENV
, falling back to the value of 'development'
if NODE_ENV
isn't set. This allows us to define different settings for different environments within our app.
Getting ready
We'll need our project folder (nca
) from the previous recipe.
How to do it...
Let's take a look at the default...