-
Notifications
You must be signed in to change notification settings - Fork 10
Config File
by Andrew Shell on Dec 21, 2014
I no longer think that a config file is required. On the server-snacks list it was recommended to use node-foreman and a .env file. This then works exactly like a config file would, only it's loaded into the env vars for that particular app. No overlap.
-
If someone wants to host multiple apps on a single VPS then they may not want to rely on global environment variables in order to configure their apps.
-
We don't want to replace environment variables, because they are the way to configure Heroku apps. So the config file would have to be optional.
-
Self documenting. It is obvious what the config variables are available to change. Comments in the file can explain what valid values would be
-
If you're running different apps on the same server you can isolate what options they use. For instance both storage and river4 rely on the environment variables s3Path, PORT, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
-
Extra code to maintain
-
Potential for credentials getting published if user isn't careful (backing up code or committing to forked repo for example)
-
Unsure of real world demand for this feature
// config.js
var config = {};
config.PORT = '8088';
module.exports = config;
// storage.js
try {
// Try to load the config file
var config = require('./config.js');
}
catch (e) {
// If it didn't exist set a default
var config = {};
console.log('No config file');
}
// If config.PORT exists use it, otherwise go with the env var
var myPort = config.PORT | process.env.PORT;
Please edit this document and include your comments/questions. Ideally number them and mention who you are in case we have multiple commenters.
- Andrew: This is a sample comment. :-)