Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ application/package-lock.json
*.sw?

# Secret keys
ssl-key.pem
ssl.pem
application/ssl-key.pem
application/ssl.pem
Comment on lines +28 to +29
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
application/ssl-key.pem
application/ssl.pem
application/*.pem

application/TBAkey.txt
7 changes: 3 additions & 4 deletions application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand All @@ -19,20 +18,21 @@
"@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",
"qr-scanner": "^1.4.2",
"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": {
Expand All @@ -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"
Expand Down
32 changes: 31 additions & 1 deletion application/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 {
Expand Down Expand Up @@ -99,10 +100,39 @@ app.get("/Matches/:type/:value", async (req, res) => {
}
});


app.get("/TheBlueAlliance-event-leaderboard/:event", async(req, res) =>{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
app.get("/TheBlueAlliance-event-leaderboard/:event", async(req, res) =>{
app.get("/TBA/: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);
6 changes: 6 additions & 0 deletions package-lock.json
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.