Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up to date #40

Merged
merged 7 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/controllers/execution.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function startExecution(req: Request<{},any,StartExecutionBody>, re
platform: firstNode.platform
})
} catch(err) {
next(err);
res.status(500).send(err);
}


Expand Down Expand Up @@ -105,7 +105,7 @@ export async function getActualNode(req: Request<{},any, GetNextExerciseV2Body>,

return res.status(200).json(actualNode.node);
}catch(err) {
next(err);
res.status(500).send(err);
}
}

Expand Down Expand Up @@ -139,7 +139,7 @@ export async function getNextExercisev2(req: Request<{},any, GetNextExerciseV2Bo

return res.status(200).json(firstNode);
}catch(err) {
next(err);
res.status(500).send(err);
}
}

Expand Down Expand Up @@ -176,7 +176,7 @@ export async function getInitialExercise(req: Request<{}, any, GetInitialExercis

return res.status(200).json(actualNode);
}catch(err) {
next(err);
res.status(500).send(err);
}
}
type GetNextExerciseBody = {
Expand Down Expand Up @@ -222,6 +222,6 @@ export async function getNextExercise(req: Request<{}, any, GetNextExerciseBody>

return res.status(200).json(actualNode);
}catch(err) {
next(err);
res.status(500).send(err);
}
}
37 changes: 25 additions & 12 deletions src/controllers/flows.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import { PolyglotEdge, PolyglotFlowInfo, PolyglotNode } from "../types";
import { PolyglotEdgeModel } from "../models/edge.models";
import { DOMAIN_APP_DEPLOY } from "../utils/secrets";

function customizeErrorMessage(err:any){
console.log(err.message);
if(err.message.search('title')!=-1)
return 'To create a flow a title is required'
if(err.message.search('description')!=-1)
return 'To create a flow a description is required'
if(err.message.search('duration')!=-1)
return 'The duration need to be a number, please correct or remove any characters, you can always change it later on. (For decimals use dot)'
return err.message;
}

export async function deleteFlow(req: Request, res: Response, next: NextFunction) {
try {
const resp = await PolyglotFlowModel.deleteOne({_id: req.params.id, author: req.user?._id})
Expand Down Expand Up @@ -46,8 +57,8 @@ export async function getFlowById(req: Request, res: Response<Document<unknown,
return res.status(404).send();
}
return res.status(200).send(flow);
} catch (err) {
return next(err);
} catch (err: any) {
return res.status(500).send(err);
}

}
Expand Down Expand Up @@ -122,8 +133,8 @@ export async function getFlowList(req: Request, res: Response, next : NextFuncti
return res.status(404).send();
}
return res.status(200).send(flows);
} catch (err) {
return next(err);
} catch (err: any) {
return res.status(500).send(err);
}

}
Expand Down Expand Up @@ -228,8 +239,9 @@ export async function updateFlow(req: Request, res: Response, next: NextFunction
}

return res.status(200).send(flow);
} catch (err) {
return next(err);
} catch (err: any) {
err.message = customizeErrorMessage(err);
return res.status(500).send(err);
}

}
Expand All @@ -249,7 +261,7 @@ export async function publishFlow(req: Request, res: Response, next : NextFuncti

return res.status(200).send(flows);
} catch (err) {
return next(err);
return res.status(500).send(err);
}

}
Expand All @@ -261,9 +273,9 @@ export async function createFlow(req: Request, res: Response, next : NextFunctio

const flow = await PolyglotFlowModel.create(newFlow);
return res.status(200).send(flow);
} catch (err) {
console.log(err);
return next(err);
} catch (err: any) {
err.message = customizeErrorMessage(err);
return res.status(500).send(err);
}
}

Expand All @@ -283,8 +295,9 @@ export async function createFlowJson(req: Request, res: Response, next : NextFun
if (!newFlow) return res.status(500).json({"error": "internal error"})

return res.status(200).send({id: newFlow?._id});
} catch (err) {
} catch (err: any) {
console.log(err);
return next(err);
err.message = customizeErrorMessage(err);
return res.status(500).send(err);
}
}
Loading