-
Notifications
You must be signed in to change notification settings - Fork 0
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
Connect TBA #26
base: master
Are you sure you want to change the base?
Connect TBA #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,12 +5,13 @@ import fs from "fs"; | |||||
import path from "path"; | ||||||
import https from "https"; | ||||||
import cors from "cors"; | ||||||
import axios from 'axios'; | ||||||
|
||||||
const app = express(); | ||||||
const hostname = "0.0.0.0"; | ||||||
const port = 4590; | ||||||
|
||||||
const dirName = "/app"; | ||||||
const dirName = ""; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change this back before merge |
||||||
// SSL options for HTTPS | ||||||
export let sslOptions; | ||||||
try { | ||||||
|
@@ -99,10 +100,39 @@ app.get("/Matches/:type/:value", async (req, res) => { | |||||
} | ||||||
}); | ||||||
|
||||||
|
||||||
app.get("/TheBlueAlliance-event-leaderboard/:event", async(req, res) =>{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
try { | ||||||
const headers = { | ||||||
"X-TBA-Auth-Key": String(fs.readFileSync(path.resolve(dirName, "TBAkey.txt"))), | ||||||
"Content-Type": "application/json", | ||||||
|
||||||
}; | ||||||
const params = { | ||||||
param1: req.params.event | ||||||
}; | ||||||
|
||||||
const response = await axios.get(`https://www.thebluealliance.com/api/v3/event/${req.params.event}/rankings`, { | ||||||
headers, | ||||||
params, | ||||||
}); | ||||||
|
||||||
res.json(response.data) | ||||||
}catch (error) { | ||||||
console.error(error); | ||||||
res.status(500).send('Error calling external API'); | ||||||
} | ||||||
|
||||||
|
||||||
}); | ||||||
|
||||||
|
||||||
const server = ( | ||||||
sslOptions.key === "" ? app : https.createServer(sslOptions, app) | ||||||
).listen(port, hostname, () => | ||||||
console.log(`Server is listening on ${hostname}:${port}`) | ||||||
); | ||||||
|
||||||
|
||||||
|
||||||
ViteExpress.bind(app, server); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.