This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import express from "express"; | |
| import { Resonate } from "@resonatehq/sdk"; | |
| const app = express(); | |
| const resonate = new Resonate({ | |
| url: "http://localhost:8001", | |
| group: "gateway", | |
| }); | |
| // Start a workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Resonate } from "@resonatehq/sdk"; | |
| import type { Context } from "@resonatehq/sdk"; | |
| const resonate = new Resonate({ | |
| url: "http://localhost:8001", | |
| group: "workers", | |
| }); | |
| async function sendEmail(_: Context, promiseId: string) { | |
| const link = "http://localhost:5001/unblock-workflow?promise_id=" + promiseId; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function* approvalWorkflow(ctx: Context, requestId: string) { | |
| // Do some work | |
| const request = yield* ctx.run(fetchRequest, requestId); | |
| // Create a promise and wait for human approval | |
| const approvalPromise = yield* ctx.promise({}); | |
| yield* ctx.run(sendApprovalEmail, approvalPromise.id); | |
| // This line doesn't execute until a human approves | |
| const decision = yield* approvalPromise; |