What we're going to do is to put all of our configurations into a file and load them from the file when we start our app. This is quite simple to get started with, but we'll have to evolve in order to support some important basic needs. We'll start with a config file, which we'll name .env
, which is a commonly used convention, although the name is actually not important. Here are the contents of the file:
TODO_STORE='redis' REDIS_URL='redis://127.0.0.1:6379/0' REDIS_PASSWORD='cantguessthis'
The format is that of variable declarations in a Bash shell script. This is appropriate because using environment variables will force us to use Bash variables in the end. We avoid the confusion of type conversions by declaring the variables in the same way. Had we used JSON or another more powerful format, we would have to contend with conversion of types for integers, arrays, and other non-String types allowed by the format.
The next step is to load these variables into...