From 6f427829bc4eac48d659b8898ffab2fe5b47e690 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Thu, 27 Apr 2023 11:34:55 +0200 Subject: [PATCH] Added check for unreachable coords --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index dfbfbc5..eb71be6 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,13 @@ app.use('/rep', async (req, res) => { const code = gl.getContainers(pos).features[0]?.properties["REF"] + if (!code) { + res.json({ + "message": "The requested data couldn't be found. Maybe it was moved or the data isn't generated properly." + }).status(404).end(); + return + } + const repFile = fs.readFileSync(path.join(__dirname, `public/reps/${lookupTable[code]}.json`), 'utf-8'); res.end(repFile);