feat: update currently generated workflow file from the storage one
This commit is contained in:
@@ -98,3 +98,26 @@ router.put('/pair/:index', (req, res) => {
|
||||
return res.send(null);
|
||||
});
|
||||
|
||||
/**
|
||||
* PUT endpoint for updating the currently generated workflow file from the one in the storage.
|
||||
*/
|
||||
router.put('/:browserId/:fileName', async (req, res) => {
|
||||
try {
|
||||
const browser = browserPool.getRemoteBrowser(req.params.browserId);
|
||||
logger.log('debug', `Updating workflow file`);
|
||||
if (browser && browser.generator) {
|
||||
const recording = await readFile(`./../storage/recordings/${req.params.fileName}.waw.json`)
|
||||
const parsedRecording = JSON.parse(recording);
|
||||
if (parsedRecording.recording) {
|
||||
browser.generator?.updateWorkflowFile(parsedRecording.recording, parsedRecording.recording_meta);
|
||||
const workflowFile = browser.generator?.getWorkflowFile();
|
||||
return res.send(workflowFile);
|
||||
}
|
||||
}
|
||||
return res.send(null);
|
||||
} catch (e) {
|
||||
const {message} = e as Error;
|
||||
logger.log('info', `Error while reading a recording with name: ${req.params.fileName}.waw.json`);
|
||||
return res.send(null);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user