Skip to content

Commit

Permalink
Merge pull request #60 from Lukasdotcom/github-rate-limit
Browse files Browse the repository at this point in the history
Program still works if github api fails to respond or is rate limiting you
  • Loading branch information
Lukasdotcom authored Jul 11, 2022
2 parents ae8b2c0 + 6bffae0 commit 664a121
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/entrypoint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,18 @@ async function startUp() {
updateData()
// Checks if this is the latest version and if it does adds data
async function updateInfo() {
console.log("Checking for updates")
const releases = await fetch("https://api.github.com/repos/lukasdotcom/Bundesliga/releases").then((res) => res.ok ? res.json() : {})
if (releases[0] === undefined || releases[0].tag_name === undefined) {
console.log("Failed to get version data from github api")
return
}
const connection = createConnection({
host : process.env.MYSQL_HOST,
user : process.env.MYSQL_USER,
password : process.env.MYSQL_PASSWORD,
database : process.env.MYSQL_DATABASE
})
console.log("Checking for updates")
const releases = await fetch("https://api.github.com/repos/lukasdotcom/Bundesliga/releases").then((res) => res.json())
if (version.version !== releases[0].tag_name) {
connection.query("INSERT INTO data (value1, value2) VALUES('updateProgram', ?) ON DUPLICATE KEY UPDATE value2=?",[releases[0].html_url, releases[0].html_url])
} else {
Expand Down

0 comments on commit 664a121

Please sign in to comment.