fix: verify config field existance and content
This commit is contained in:
parent
a8085f3f1d
commit
0c0ca09b4e
5 changed files with 15 additions and 25 deletions
|
|
@ -8,6 +8,7 @@ const { BTC, ETH, LTC, BCH } = COINS
|
|||
const CRYPTO = [BTC, ETH, LTC, BCH]
|
||||
const FIAT = ['USD', 'EUR']
|
||||
const AMOUNT_PRECISION = 8
|
||||
const REQUIRED_CONFIG_FIELDS = ['key', 'secret', 'clientId']
|
||||
|
||||
const loadConfig = (account) => {
|
||||
const mapper = {
|
||||
|
|
@ -18,10 +19,4 @@ const loadConfig = (account) => {
|
|||
return { ...mapped, timeout: 3000 }
|
||||
}
|
||||
|
||||
const isConfigValid = options => {
|
||||
const requiredOptions = ['key', 'secret', 'clientId']
|
||||
const givenOptions = _.pick(requiredOptions, options)
|
||||
return _.isEqual(_.keys(givenOptions), requiredOptions)
|
||||
}
|
||||
|
||||
module.exports = { loadConfig, isConfigValid, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }
|
||||
module.exports = { loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue