From d6e799e956650124dda64ef3004b12ef5402625d Mon Sep 17 00:00:00 2001 From: ztimson Date: Wed, 24 Jun 2026 19:49:27 -0400 Subject: [PATCH] Fix error checking --- server/src/server.mjs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/server.mjs b/server/src/server.mjs index 3306d9b..51cf989 100644 --- a/server/src/server.mjs +++ b/server/src/server.mjs @@ -36,17 +36,6 @@ function filterArr(arr, fields) { return arr.map(row => filterFields(row, fields)); } -// ── Errors ──────────────────────────────────────────────────────────────────── - -app.use((req, res, next) => { - res.status(404).json({ error: `Not found: ${req.method} ${req.path}` }) -}) - -app.use((err, req, res, next) => { - console.error(`[ERROR] ${req.method} ${req.path}\n${err.stack}`) - res.status(500).json({ error: err.message, stack: err.stack }) -}) - // ── Current ─────────────────────────────────────────────────────────────────── app.get('/api/current', async (req, res) => { @@ -174,6 +163,17 @@ app.get('*', (req, res) => { else res.status(404).send('Client not built yet — run npm run build in /client'); }); +// ── Errors ──────────────────────────────────────────────────────────────────── + +app.use((req, res, next) => { + res.status(404).json({ error: `Not found: ${req.method} ${req.path}` }) +}) + +app.use((err, req, res, next) => { + console.error(`[ERROR] ${req.method} ${req.path}\n${err.stack}`) + res.status(500).json({ error: err.message, stack: err.stack }) +}) + // ── Start ───────────────────────────────────────────────────────────────────── const c = cfg();