Fix error checking

This commit is contained in:
2026-06-24 19:49:27 -04:00
parent ff44b7fed5
commit d6e799e956

View File

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