Skip to content

Instantly share code, notes, and snippets.

View flossypurse's full-sized avatar
🦖
Working from home

Cully flossypurse

🦖
Working from home
View GitHub Profile
@flossypurse
flossypurse / gateway.ts
Created January 30, 2026 17:18
Example HTTP gateway using resonate
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
@flossypurse
flossypurse / worker.ts
Created January 30, 2026 17:16
Example of a resonate worker
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;
@flossypurse
flossypurse / approval-workflow.ts
Last active January 30, 2026 17:16
Approval workflow using resonate
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;