feat(tasks): manage markdown loops from scheduled tasks

This commit is contained in:
Bohdan Triapitsyn
2026-08-09 21:43:16 +03:00
parent ce6912fe40
commit e13b4526c6
20 changed files with 322 additions and 34 deletions
@@ -81,6 +81,35 @@ export const registerScheduledTaskRoutes = (app, dependencies) => {
}
});
app.patch('/api/projects/:projectId/scheduled-tasks/:taskId/loop-file', async (req, res) => {
const projectID = parseProjectID(req);
const taskID = parseTaskID(req);
if (!projectID) return res.status(400).json({ error: 'projectId is required' });
if (!taskID) return res.status(400).json({ error: 'taskId is required' });
try {
const task = await scheduledTaskService.setLoopEnabled(projectID, taskID, req.body?.enabled);
return res.json({ task });
} catch (error) {
if (error?.statusCode) return res.status(error.statusCode).json({ error: error.message });
console.error('[ScheduledTasks] failed to update loop file:', error);
return res.status(500).json({ error: 'Failed to update loop file' });
}
});
app.delete('/api/projects/:projectId/scheduled-tasks/:taskId/loop-file', async (req, res) => {
const projectID = parseProjectID(req);
const taskID = parseTaskID(req);
if (!projectID) return res.status(400).json({ error: 'projectId is required' });
if (!taskID) return res.status(400).json({ error: 'taskId is required' });
try {
return res.json({ tasks: await scheduledTaskService.removeLoopFile(projectID, taskID) });
} catch (error) {
if (error?.statusCode) return res.status(error.statusCode).json({ error: error.message });
console.error('[ScheduledTasks] failed to delete loop file:', error);
return res.status(500).json({ error: 'Failed to delete loop file' });
}
});
app.post('/api/projects/:projectId/scheduled-tasks/:taskId/run', async (req, res) => {
const projectID = parseProjectID(req);
const taskID = parseTaskID(req);