Read the code, and notice how we can switch the Mailer API URL and the database URL form the JSON config files by setting the 'APP_ENVIRONMENT' variable.
For instance:
$ APP_ENVIRONMENT=production ts-node main.ts
Env: production
Connecting to db app at database.example.org
Connecting to mailer API at: https://mailer.example.orgEnv: local
Connecting to db app at localhost
Connecting to mailer API at: http://localhost:8080/mailer/api- Add a "useTls" boolean to the database configuration
- Introduce a pre-production environment in addition to the production env
- Encrypt the password databse and the secret token for the mailer
Relect on how big this changes would be in the state of the current code.
Go read the 12 Factor App documentation, especially the part about configuration:
=> https://12factor.net/config
Then refactor the code, getting rid of the 'configuration.ts' module completly.
Then, try and apply the changes listed in part 1.
Finally, try and run the code using the 'local' database and the "pre-production" mailer API.