stacks-network / sbtc-bridge-api

GNU Affero General Public License v3.0
6 stars 4 forks source link

config: process env last to override defaults #72

Closed EmbeddedAndroid closed 1 year ago

EmbeddedAndroid commented 1 year ago

Use the following template to create your pull request When trying to integrate the bridge-api into devenv for https://github.com/stacks-network/sbtc/issues/141 I ran across an issue when the environment variable I set in compose would be processed and then overwritten subsequently.

Here is an example log, which displays the issue.

> bridge-api@1.0.0 start
> node dist/src/app.js

================================================ >> undefined
linode env.. changing CONFIG.mongoDbName = sbtc-bridge-simnet-db
linode env.. changing CONFIG.mongoUser = dockerdev1
linode env.. changing CONFIG.mongoPwd = Fb
linode env.. process.env.mongoDbName = devnet
linode env.. process.env.BTC_NODE = bitcoin:18443
linode env.. changing CONFIG.btcNode = http://localhost:18443
linode env.. changing CONFIG.btcRpcUser = devnet
linode env.. changing CONFIG.btcSchnorrReveal = 93
linode env.. changing CONFIG.btcSchnorrReveal = 62d
linode env.. changing CONFIG.btcSchnorrReclaim = eb
linode env.. changing CONFIG.btcSchnorrReclaim = 98c
================================================ >> undefined
linode env.. changing CONFIG.mongoDbName = sbtc-bridge-simnet-db
linode env.. changing CONFIG.mongoUser = dockerdev1
linode env.. changing CONFIG.mongoPwd = Fb
linode env.. process.env.mongoDbName = devnet
linode env.. process.env.BTC_NODE = bitcoin:18443
linode env.. changing CONFIG.btcNode = http://localhost:18443
linode env.. changing CONFIG.btcRpcUser = devnet
linode env.. changing CONFIG.btcSchnorrReveal = 93
linode env.. changing CONFIG.btcSchnorrReveal = 62d
linode env.. changing CONFIG.btcSchnorrReclaim = eb
linode env.. changing CONFIG.btcSchnorrReclaim = 98c
Express is listening at http://localhost:3010

Type of Change

The main idea here, is to process the ENV variable last, incase there is an override needed.