mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-08-22 08:36:46 -05:00
Check if Trello API is available before updating
This commit is contained in:
2761
package-lock.json
generated
2761
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
"express-handlebars": "^4.0.4",
|
||||
"express-locale": "^2.0.0",
|
||||
"fs-extra": "^9.1.0",
|
||||
"got": "^11.8.2",
|
||||
"gray-matter": "^4.0.3",
|
||||
"ioredis": "^4.26.0",
|
||||
"marked": "^3.0.4",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const Trello =require('trello');
|
||||
const Redis = require('ioredis');
|
||||
const JSONCache = require('redis-json');
|
||||
const got = require('got');
|
||||
const config = require('../config.json');
|
||||
|
||||
const trello = new Trello(config.trello.api_key, config.trello.api_token);
|
||||
@@ -14,7 +15,10 @@ async function getTrelloCache() {
|
||||
}
|
||||
|
||||
if (cache.update_time < Date.now() - (1000 * 60 * 60)) {
|
||||
cache = await updateTrelloCache();
|
||||
const available = await trelloAPIAvailable();
|
||||
if (available) {
|
||||
cache = await updateTrelloCache();
|
||||
}
|
||||
}
|
||||
|
||||
return cache;
|
||||
@@ -64,6 +68,11 @@ async function updateTrelloCache() {
|
||||
return progressData;
|
||||
}
|
||||
|
||||
async function trelloAPIAvailable() {
|
||||
const { status } = await got('https://trello.status.atlassian.com/api/v2/status.json').json();
|
||||
return status.description === 'All Systems Operational';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getTrelloCache,
|
||||
updateTrelloCache
|
||||
|
||||
Reference in New Issue
Block a user