-
Notifications
You must be signed in to change notification settings - Fork 95
Handle missing config file #80
base: master
Are you sure you want to change the base?
Conversation
Use default values from test config and prevent error if you don't have access rights to HOME dir (e.g. Heroku) and therefore config file was not properly created during installation of bitpay-rest library.
I am generally ok with this solution except that the non-existence of a config.json will lead to the assumption that the user wants to use https://test.bitpay.com:443 as the defaultConf object. This may not be the case and the user may not realize what host is being used. This could lead to bad things happening depending on the use case. Maybe a better solution is to read the config from a static json file that is included with the npm module -or- from an AWS file -or- a response from an api request. But, you do bring up a good point and the solution seems simple enough under a narrow band of circumstances, but I think we need explicit input on what the defaultConf object is under all circumstances. |
Can someone merge this? In the age of serverless computing and the cloud seems counterintuitive to force the existence of a config file on the local "server". |
Better yet would be to load the config file only if exists. Fail if there is not config file and not override given. |
var defaultConf = { | ||
"apiHost": "test.bitpay.com", | ||
"apiPort": 443, | ||
"forceSSL": true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid duplicating default values already present elsewhere, I suggest using this approach instead:
var defaultConf = { | |
"apiHost": "test.bitpay.com", | |
"apiPort": 443, | |
"forceSSL": true | |
} | |
var defaultConf = require('../config/test.json'); |
See: #92 (comment)
Use default values from test config and prevent error if you don't have access rights to HOME dir (e.g. Heroku) and therefore config file was not properly created during installation of bitpay-rest library.