Skip to content

Commit

Permalink
Merge pull request #30 from polyglot-edu/20-new-execution-api-concept
Browse files Browse the repository at this point in the history
20 new execution api concept
  • Loading branch information
tmaog authored Mar 20, 2024
2 parents a623e8b + 56ecd23 commit b99287a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/controllers/flows.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export async function updateFlow(req: Request, res: Response, next: NextFunction
// await body("flow", "Flow is required").exists().run(req);

try {
req.body.publish=false;
const flow = await updateFlowQuery(req.params.id, req.body);

if (!flow) {
Expand All @@ -220,6 +221,26 @@ export async function updateFlow(req: Request, res: Response, next: NextFunction

}

//function to publish the flow (change publish to true)
export async function publishFlow(req: Request, res: Response, next : NextFunction) {

try {

req.body.publish=true;

const flows = await updateFlowQuery(req.params.id, req.body);

if (!flows) {
return res.status(404).send()
}

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

}

export async function createFlow(req: Request, res: Response, next : NextFunction) {
try {
const newFlow = req.body as PolyglotFlowInfo;
Expand Down
5 changes: 5 additions & 0 deletions src/models/flow.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export const flowSchema = new mongoose.Schema<PolyglotFlow>({
type: String,
required: true
},
publish: {
type: Boolean,
required: true,
default: false,
},
learningPathId: {
type: String
},
Expand Down
2 changes: 2 additions & 0 deletions src/routes/flows.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ router.route("/:ctxId/run") // version of notebook with only ctx information
router.route("/:id/:ctxId/run") //2nd version of notebook with ctx information and flowId
.get(FlowController.downloadNotebookVSC2);

router.route("/:id/publish") //function to publish the flow
.put(checkAuth, FlowController.publishFlow);

export default router;
1 change: 1 addition & 0 deletions src/types/PolyglotFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type PolyglotFlowInfo = {
author: string;
learningPathId: string;
description: string;
publish: boolean;
tags: string[];
execution: PolyglotExecutionData;
}
Expand Down

0 comments on commit b99287a

Please sign in to comment.