wip: use db model instead of file system

This commit is contained in:
karishmas6
2024-10-09 23:08:13 +05:30
parent a174e2281c
commit 565d86ec54

View File

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