Add API endpoint for remote reboot of CC:Tweaked computers

This commit is contained in:
MayaTheShy
2026-03-22 03:15:36 -04:00
parent 891fb2a10c
commit 2ac11350e6

View File

@@ -519,6 +519,31 @@ app.post('/api/recipes/disable-all', (req, res) => {
}
});
// Remote reboot CC:Tweaked computers
app.post('/api/reboot', (req, res) => {
try {
const { target, commandId } = req.body || {};
const cached = checkIdempotent(commandId);
if (cached) return res.json(cached);
const validTargets = ['all', 'manager', 'client', 'turtle', 'bridge'];
const t = target || 'all';
// Allow valid role names or numeric computer IDs
if (!validTargets.includes(t) && !/^\d+$/.test(t)) {
return res.status(400).json({ error: 'Invalid target. Use: all, manager, client, turtle, bridge, or a computer ID' });
}
pushCommandToBridge({ type: 'command', action: 'reboot', commandId, target: t });
const result = { success: true, commandId, message: `Reboot sent to: ${t}` };
recordCommand(commandId, result);
console.log(`🔄 Reboot requested: target=${t}`);
res.json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Sort barrel
app.post('/api/sort-barrel', (req, res) => {
try {