Améliorations mineures

This commit is contained in:
Sébastien Rivière
2025-05-18 15:29:43 +02:00
parent 50c258c540
commit 84239feb4a
7 changed files with 32 additions and 24 deletions

View File

@@ -61,23 +61,25 @@ export function initPhotoUpload() {
//App handler for serving the photo of a team given its secret ID
app.get("/photo/my", (req, res) => {
let team = game.getTeam(Number(req.query.team));
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.id.toString());
if (team) {
res.set("Content-Type", "image/png")
res.set("Access-Control-Allow-Origin", "*");
res.sendFile(process.cwd() + "/" + UPLOAD_DIR + "/" + team.id);
res.sendFile(fs.existsSync(imagePath) ? imagePath : path.join(process.cwd(), "images", "missing_image.jpg"));
} else {
res.send(400, "Team not found")
res.status(400).send("Team not found")
}
})
//App handler for serving the photo of the team chased by the team given by its secret ID
app.get("/photo/enemy", (req, res) => {
let team = game.getTeam(Number(req.query.team));
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.chasing.toString());
if (team) {
res.set("Content-Type", "image/png")
res.set("Access-Control-Allow-Origin", "*");
res.sendFile(process.cwd() + "/" + UPLOAD_DIR + "/" + team.chasing);
res.sendFile(fs.existsSync(imagePath) ? imagePath : path.join(process.cwd(), "images", "missing_image.jpg"));
} else {
res.send(400, "Team not found")
res.status(400).send("Team not found")
}
})
}