Skip to content

Commit faaefdf

Browse files
authored
Merge pull request #67 from Dev-Pross/execution-flow-for-both-single-and-multi-nodes
fix: improve user validation and error handling in execution routes
2 parents c80b938 + d449d57 commit faaefdf

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

apps/http-backend/src/routes/userRoutes/executionRoutes.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const execRouter: Router = Router()
77

88
execRouter.post('/node', userMiddleware, async(req: AuthRequest, res: Response)=>{
99
try{
10-
if(!req.user){
10+
if(!req.user?.sub){
1111
return res.status(statusCodes.BAD_REQUEST).json({
1212
message: "User is not logged in ",
1313
});
@@ -30,15 +30,17 @@ execRouter.post('/node', userMiddleware, async(req: AuthRequest, res: Response)
3030
const type = nodeData.AvailableNode.type
3131
const config = dataSafe.data.Config ? dataSafe.data.Config : nodeData.config // for test api data prefered fist then config in db
3232
console.log(`config and type: ${JSON.stringify(config)} & ${type}`)
33+
// if(nodeData.CredentialsID)
3334
const context = {
34-
userId: req.user.sub || "",
35-
config: config
35+
userId: req.user.sub,
36+
config: config ,
37+
// credentialsId: nodeData.CredentialsID || ""
3638
}
3739
const executionResult = await ExecutionRegister.execute(type, context)
3840

3941
console.log(`Execution result: ${executionResult}`)
4042

41-
if(executionResult)
43+
if(executionResult.success)
4244
return res.status(statusCodes.ACCEPTED).json({
4345
message: `${nodeData.name} node execution done` ,
4446
data: executionResult

apps/worker/src/engine/executor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function executeWorkflow(
4747
nodeId: node.id,
4848
workflowExecId: workflowExecutionId,
4949
status: "Start",
50+
inputData: currentInputData ? currentInputData : {},
5051
startedAt: new Date()
5152
}
5253
})

packages/nodes/src/registry/execution.registory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ExecutionRegistry {
2727
} catch (error: any) {
2828
return {
2929
success: false,
30-
error: error,
30+
error: error instanceof Error ? error.message : String(error),
3131
};
3232
}
3333
}
@@ -38,8 +38,8 @@ class ExecutionRegistry {
3838

3939

4040
//wehen visits this next time make sure chang gmail executor implements NodeExecutor
41-
this.register("gmail", new GmailExecutor() as unknown as NodeExecutor);
42-
this.register("google_sheet", new GoogleSheetsNodeExecutor() as unknown as NodeExecutor)
41+
this.register("gmail", new GmailExecutor() as NodeExecutor);
42+
this.register("google_sheet", new GoogleSheetsNodeExecutor() as NodeExecutor)
4343
console.log(`The current Executors are ${this.executors.size}`);
4444
}
4545
}

0 commit comments

Comments
 (0)