From bdeac55c97d1a4e7216edb834adde1666cdb46aa Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 19 Oct 2020 18:47:10 +0700 Subject: [PATCH] Fix for statistics enabled config. --- backend/src/index.ts | 19 ++++++++++++------- backend/src/routes.ts | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 33e4088f6..fe7914680 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -138,16 +138,21 @@ class Server { .get(config.MEMPOOL.API_URL_PREFIX + 'transaction-times', routes.getTransactionTimes) .get(config.MEMPOOL.API_URL_PREFIX + 'fees/recommended', routes.getRecommendedFees) .get(config.MEMPOOL.API_URL_PREFIX + 'fees/mempool-blocks', routes.getMempoolBlocks) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2h', routes.get2HStatistics) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/24h', routes.get24HStatistics.bind(routes)) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1w', routes.get1WHStatistics.bind(routes)) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1m', routes.get1MStatistics.bind(routes)) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3m', routes.get3MStatistics.bind(routes)) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/6m', routes.get6MStatistics.bind(routes)) - .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1y', routes.get1YStatistics.bind(routes)) .get(config.MEMPOOL.API_URL_PREFIX + 'backend-info', routes.getBackendInfo) ; + if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED) { + this.app + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2h', routes.get2HStatistics) + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/24h', routes.get24HStatistics.bind(routes)) + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1w', routes.get1WHStatistics.bind(routes)) + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1m', routes.get1MStatistics.bind(routes)) + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3m', routes.get3MStatistics.bind(routes)) + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/6m', routes.get6MStatistics.bind(routes)) + .get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1y', routes.get1YStatistics.bind(routes)) + ; + } + if (config.BISQ_BLOCKS.ENABLED) { this.app .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', routes.getBisqStats) diff --git a/backend/src/routes.ts b/backend/src/routes.ts index 9ee755ffb..02ac4ce8e 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -16,7 +16,7 @@ class Routes { private cache = {}; constructor() { - if (!config.DATABASE.ENABLED) { + if (config.DATABASE.ENABLED && config.STATISTICS.ENABLED) { this.createCache(); setInterval(this.createCache.bind(this), 600000); }