nodes/packages/runtime/src/remote-runtime-executor.ts
Max Richter a01a409b97
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m32s
feat: move registry and runtime into separate packages
2024-05-05 15:11:53 +02:00

19 lines
489 B
TypeScript

import type { Graph, RuntimeExecutor } from "@nodes/types";
export class RemoteRuntimeExecutor implements RuntimeExecutor {
constructor(private url: string) { }
async execute(graph: Graph, settings: Record<string, any>): Promise<Int32Array> {
const res = await fetch(this.url, { method: "POST", body: JSON.stringify({ graph, settings }) });
if (!res.ok) {
throw new Error(`Failed to execute graph`);
}
return new Int32Array(await res.arrayBuffer());
}
}