From dbf2da3d0dcc89b802d2eb5f2c33d3d27b507161 Mon Sep 17 00:00:00 2001 From: apotdevin Date: Tue, 28 Sep 2021 14:26:04 +0200 Subject: [PATCH] chore: custom mempool url --- .env | 5 +++++ next.config.js | 5 +++++ server/schema/bitcoin/bitcoin.test.ts | 2 +- server/utils/appUrls.ts | 11 ++++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 800ae8e0..e77b766d 100644 --- a/.env +++ b/.env @@ -12,6 +12,11 @@ # LOG_LEVEL='info' # TOR_PROXY_SERVER=socks://127.0.0.1:9050 +# ----------- +# URLs +# ----------- +# MEMPOOL_URL='https://mempool.space' + # ----------- # Interface Configs # ----------- diff --git a/next.config.js b/next.config.js index 89b551a0..a85a7640 100644 --- a/next.config.js +++ b/next.config.js @@ -24,6 +24,10 @@ const accountConfig = { accountConfigPath: process.env.ACCOUNT_CONFIG_PATH || '', }; +const urls = { + mempoolUrl: process.env.MEMPOOL_URL || 'https://mempool.space', +}; + module.exports = { poweredByHeader: false, basePath: process.env.BASE_PATH || '', @@ -37,6 +41,7 @@ module.exports = { ...ymlEnv, }, publicRuntimeConfig: { + ...urls, nodeEnv: process.env.NODE_ENV || 'development', apiUrl: `${process.env.BASE_PATH || ''}/api/v1`, apiBaseUrl: `${process.env.API_BASE_URL || ''}/api/v1`, diff --git a/server/schema/bitcoin/bitcoin.test.ts b/server/schema/bitcoin/bitcoin.test.ts index e2d31695..554e080c 100644 --- a/server/schema/bitcoin/bitcoin.test.ts +++ b/server/schema/bitcoin/bitcoin.test.ts @@ -58,7 +58,7 @@ describe('Bitcoin Resolvers', () => { expect(res.errors).toBe(undefined); expect(fetchMock).toBeCalledWith( - 'https://mempool.space/api/v1/fees/recommended', + 'undefined/api/v1/fees/recommended', undefined ); expect(res).toMatchSnapshot(); diff --git a/server/utils/appUrls.ts b/server/utils/appUrls.ts index 1263f5de..0fffd7ba 100644 --- a/server/utils/appUrls.ts +++ b/server/utils/appUrls.ts @@ -1,3 +1,8 @@ +import getConfig from 'next/config'; + +const { publicRuntimeConfig } = getConfig() || {}; +const { mempoolUrl } = publicRuntimeConfig || {}; + const tbase = process.env.NODE_ENV === 'development' ? 'http://localhost:3010/dev/v1' @@ -12,9 +17,9 @@ export const appUrls = { tbase, amboss, oneml: 'https://amboss.space/node/', - blockchain: 'https://mempool.space/tx/', - blockchainAddress: 'https://mempool.space/address/', - fees: 'https://mempool.space/api/v1/fees/recommended', + blockchain: `${mempoolUrl}/tx/`, + blockchainAddress: `${mempoolUrl}/address/`, + fees: `${mempoolUrl}/api/v1/fees/recommended`, ticker: 'https://blockchain.info/ticker', github: 'https://api.github.com/repos/apotdevin/thunderhub/releases/latest', update: 'https://github.com/apotdevin/thunderhub#updating',