Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #396: add default values to environment variables #550

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
);
humphd marked this conversation as resolved.
Show resolved Hide resolved
}
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