From 68d43ad9a29e78f19baa898adc78c8687a5601d3 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Thu, 17 Jan 2019 10:00:55 +0000 Subject: [PATCH] :lipstick: --- src/actions/index.js | 32 ++++---------------------------- src/js/utilities.js | 8 ++++++++ 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index ab96975..cad3fa1 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -1,13 +1,5 @@ -// TODO: move to util lib -function urlFromEnv(ext) { - if (process.env[ext]) { - return `${process.env.SERVER_ROOT}${process.env[ext]}` - } else { - return null - } -} +import { urlFromEnv } from '../js/utilities' -// TODO: relegate these URLs entirely to environment variables const EVENT_DATA_URL = urlFromEnv('EVENT_EXT'); const CATEGORY_URL = urlFromEnv('CATEGORY_EXT'); const TAGS_URL = urlFromEnv('TAGS_EXT'); @@ -16,16 +8,6 @@ const NARRATIVE_URL = urlFromEnv('NARRATIVE_EXT'); const SITES_URL = urlFromEnv('SITES_EXT'); const eventUrlMap = (event) => `${process.env.SERVER_ROOT}${process.env.EVENT_DESC_ROOT}/${(event.id) ? event.id : event}`; - -const DEBUG_GER = 'DEBUG_GER' -function _debugger(value) { - console.log(value) - return { - type: DEBUG_GER, - value - } -} - const domainMsg = (domainType) => `Something went wrong fetching ${domainType}. Check the URL or try disabling them in the config file.` @@ -66,13 +48,10 @@ export function fetchDomain () { let tagsPromise = Promise.resolve([]) if (process.env.features.USE_TAGS) { if (!TAGS_URL) { - tagsPromise = Promise.resolve(handleError('USE_TAGS is true, but you have not provided a TAGS_URL')) + tagsPromise = Promise.resolve(handleError('USE_TAGS is true, but you have not provided a TAGS_EXT')) } else { tagsPromise = fetch(TAGS_URL) - .then(response => { - console.log(response) - return response.json() - }) + .then(response => response.json()) .catch(() => handleError(domainMsg('tags'))) } } @@ -80,7 +59,7 @@ export function fetchDomain () { let sourcesPromise = Promise.resolve([]) if (process.env.features.USE_SOURCES) { if (!SOURCES_URL) { - sourcesPromise = Promise.resolve(makeError('USE_SOURCES is true, but you have not provided a SOURCES_URL')) + sourcesPromise = Promise.resolve(makeError('USE_SOURCES is true, but you have not provided a SOURCES_EXT')) } else { sourcesPromise = fetch(SOURCES_URL) .then(response => response.json()) @@ -152,9 +131,6 @@ export function fetchSource(source) { return response.json() } }) - .then(sources => { - dispatch(_debugger(sources)) - }) .catch(err => { dispatch(fetchSourceError(err.message)) dispatch(toggleFetchingSources()) diff --git a/src/js/utilities.js b/src/js/utilities.js index 924e1f5..5568b17 100644 --- a/src/js/utilities.js +++ b/src/js/utilities.js @@ -116,3 +116,11 @@ export function injectSource(id) { } }) } + +export function urlFromEnv(ext) { + if (process.env[ext]) { + return `${process.env.SERVER_ROOT}${process.env[ext]}` + } else { + return null + } +}