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();