Skip to content

Commit

Permalink
adding failover for pull layer (Fixing issues with Chinese firewall)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventHAN committed Mar 4, 2021
1 parent 727a189 commit d2c2844
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions squad-server/layers/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,23 @@ class Layers {

this.layers = [];

Logger.verbose('Layers', 1, 'Pulling layers...');
const response = await axios.get(
'https://raw.githubusercontent.com/Squad-Wiki-Editorial/squad-wiki-pipeline-map-data/dev/completed_output/_Current%20Version/finished.json'
);
Logger.verbose('Layers', 1, 'Pulling layers from GitHub...');
let response = await axios
.get(
'https://raw.githubusercontent.com/Squad-Wiki-Editorial/squad-wiki-pipeline-map-data/dev/completed_output/_Current%20Version/finished.json'
)
.catch(() => {
Logger.verbose('Layers', 1, 'Failed to pull layers from GitHub moving to JSDelivr');
});
if (!response?.data) {
response = await axios
.get(
'https://cdn.jsdelivr.net/gh/Squad-Wiki-Editorial/squad-wiki-pipeline-map-data@dev/completed_output/_Current%20Version/finished.json'
)
.catch(() => {
throw new Error('Failed to pull layers from Github and JSDelivr!');
});
}

for (const layer of response.data.Maps) {
this.layers.push(new Layer(layer));
Expand Down

0 comments on commit d2c2844

Please sign in to comment.