Skip to content

Commit

Permalink
Make config optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom committed Nov 10, 2023
1 parent 5901b4c commit d4edac6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/authed-fetch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const QueuedFetch = require("./caching-queued-fetch");
const { queuedFetch } = QueuedFetch;

const config = require("../config.json") || {};
let config;
try {
config = require("../config.json");
} catch (e) {
config = {};
}

const authedFetch = (url) => {
// this is the value used for the discourse API, and feels like a safe default in general
Expand All @@ -10,7 +15,7 @@ const authedFetch = (url) => {
const headers = {
'User-Agent': 'W3C Group dashboard https://github.com/w3c/cg-monitor'
};
if (u.href.startsWith("https://api.github.com/")) {
if (u.href.startsWith("https://api.github.com/") && config.ghapitoken) {
headers['Authorization'] = 'token ' + config.ghapitoken;
// Roughly matching github API rate limit of 5000 requests per hour
interval = 750;
Expand Down

0 comments on commit d4edac6

Please sign in to comment.