diff options
| author | Adam Soltys <[email protected]> | 2020-01-30 21:30:13 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-01-30 21:30:13 -0800 |
| commit | d47f44eeb1af61e55f46d0b95ecd6e55ca5c9558 (patch) | |
| tree | a63d389218e18547d3ec5dad473ee9d7d3efc9a6 /rates.js | |
| parent | 8335074d6e130458f4f85cfa3081dd2947edf351 (diff) | |
| download | coinos-server-d47f44eeb1af61e55f46d0b95ecd6e55ca5c9558.tar.gz coinos-server-d47f44eeb1af61e55f46d0b95ecd6e55ca5c9558.zip | |
hardcode dev rates
Diffstat (limited to 'rates.js')
| -rw-r--r-- | rates.js | 41 |
1 files changed, 22 insertions, 19 deletions
@@ -7,32 +7,35 @@ module.exports = (app, socket) => { let fetchRates; (fetchRates = async () => { - try { - let rates = {}; - let res = await axios.get( - `http://data.fixer.io/api/latest?access_key=${config.fixer}` - ); + let rates = require("./devrates"); - let fx = res.data.rates; + if (process.env.NODE_ENV === "production") { + try { + let res = await axios.get( + `http://data.fixer.io/api/latest?access_key=${config.fixer}` + ); - fx && - Object.keys(fx).map(symbol => { - rates[symbol] = fx[symbol] / fx["USD"]; - }); + let fx = res.data.rates; - res = await axios.get( - "https://api.bitcoinvenezuela.com/?html=no¤cy=VEF" - ); + fx && + Object.keys(fx).map(symbol => { + rates[symbol] = fx[symbol] / fx["USD"]; + }); - rates.VEF = res.data["exchange_rates"].VEF_USD; - rates.VES = res.data["exchange_rates"].VEF_USD / 100000; - rates.KVES = res.data["exchange_rates"].VEF_USD / 100000000; + res = await axios.get( + "https://api.bitcoinvenezuela.com/?html=no¤cy=VEF" + ); - app.set("fxrates", rates); - } catch (e) { - l(e); + rates.VEF = res.data["exchange_rates"].VEF_USD; + rates.VES = res.data["exchange_rates"].VEF_USD / 100000; + rates.KVES = res.data["exchange_rates"].VEF_USD / 100000000; + } catch (e) { + l(e); + } } + app.set("fxrates", rates); + setTimeout(fetchRates, 7200000); })(); |
