Api trouble
This commit is contained in:
@@ -8,14 +8,11 @@ async function getDatabaseVersion(req, res) {
|
||||
ORDER BY last_update DESC
|
||||
LIMIT 1
|
||||
`);
|
||||
if (!rows.length) return res.json({ database_version: 'unknown' });
|
||||
|
||||
if (rows.length === 0) {
|
||||
return res.status(404).json({ error: 'No database version found' });
|
||||
}
|
||||
|
||||
res.json(rows[0]);
|
||||
res.json({ database_version: rows[0].database_version });
|
||||
} catch (err) {
|
||||
console.error('Error fetching database version:', err);
|
||||
console.error('Failed to fetch DB version:', err);
|
||||
res.status(500).json({ error: 'Failed to fetch database version' });
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,4 +24,4 @@ app.listen(PORT, () => {
|
||||
});
|
||||
|
||||
const versionRoutes = require('./routes/versionRoutes');
|
||||
app.use('/db-version', versionRoutes);
|
||||
app.use('/api/db-version', versionRoutes);
|
||||
Reference in New Issue
Block a user