Skip to content

Commit

Permalink
Merge pull request #550 from Silvyre/issue-396
Browse files Browse the repository at this point in the history
Fixes #396: add default values to environment variables
  • Loading branch information
manekenpix authored Jan 24, 2020
2 parents 08c55d4 + c600b5f commit ebf788b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/backend/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const dotenv = require('dotenv');
const { logger } = require('../utils/logger');

dotenv.config();
const result = dotenv.config();

if (result.error && logger) {
logger.error(
'\n\n\t💡 It appears that you have not yet configured a .env file.',
'\n\t Please refer to our documentation regarding environment configuration:',
'\n\t https://github.com/Seneca-CDOT/telescope/blob/master/docs/CONTRIBUTING.md\n'
);
}
11 changes: 8 additions & 3 deletions src/backend/utils/wiki-feed-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { JSDOM } = jsdom;
*/
async function getWikiText(url) {
try {
const response = await fetch(process.env.FEED_URL);
const response = await fetch(url);
const data = await response.text();

const dom = new JSDOM(data);
Expand All @@ -36,8 +36,13 @@ async function getWikiText(url) {
* }
*/
module.exports = async function() {
// NOTE: we expect this URL to the CDOT wiki feed list to exist in .env
const url = process.env.FEED_URL;
let url = process.env.FEED_URL;

if (!url) {
url = 'https://wiki.cdot.senecacollege.ca/wiki/Planet_CDOT_Feed_List';
logger.debug(`No value found for FEED_URL in env, using default ${url} instead`);
}

const nameCheck = /^\s*name/i;
const commentCheck = /^\s*#/;

Expand Down

0 comments on commit ebf788b

Please sign in to comment.