diff --git a/.gitignore b/.gitignore index aa64d69..53197e3 100644 --- a/.gitignore +++ b/.gitignore @@ -25,5 +25,6 @@ application/package-lock.json *.sw? # Secret keys -ssl-key.pem -ssl.pem \ No newline at end of file +application/ssl-key.pem +application/ssl.pem +application/TBAkey.txt \ No newline at end of file diff --git a/application/package.json b/application/package.json index 2396dc5..b8b6c9e 100644 --- a/application/package.json +++ b/application/package.json @@ -4,7 +4,6 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite --host", "full": "npx tsc -b tsconfig.json&& node compiled/server.js", "docker-up": "cd .. && docker-compose up ", @@ -19,9 +18,8 @@ "@mui/material": "^6.1.1", "@mui/styled-engine-sc": "^6.1.1", "@mui/x-data-grid": "^7.18.0", + "axios": "^1.7.9", "chart.js": "^4.4.4", - "react-chartjs-2": "^5.2.0", - "styled-components": "^6.1.13", "cors": "^2.8.5", "express": "^4.21.0", "mongodb": "^6.9.0", @@ -29,10 +27,12 @@ "qrcode": "^1.5.4", "qrcode.react": "^4.0.1", "react": "^18.3.1", + "react-chartjs-2": "^5.2.0", "react-collapsible": "^2.10.0", "react-dom": "^18.3.1", "react-qr-code": "^2.0.15", "react-router-dom": "^6.26.2", + "styled-components": "^6.1.13", "vite-express": "^0.19.0" }, "devDependencies": { @@ -46,7 +46,6 @@ "eslint-plugin-react-hooks": "^5.1.0-rc.0", "eslint-plugin-react-refresh": "^0.4.9", "globals": "^15.9.0", - "typescript": "^5.5.4", "typescript-eslint": "^8.0.1", "vite": "^5.4.1" diff --git a/application/server.ts b/application/server.ts index 0cac300..a314e31 100644 --- a/application/server.ts +++ b/application/server.ts @@ -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 = ""; // 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) =>{ + 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); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c4fa8be --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "GBScouting", + "lockfileVersion": 2, + "requires": true, + "packages": {} +}