nodes/app/src/routes/runtime/+server.ts
Max Richter cafe9bff84
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 1m20s
feat: add help view
2024-04-26 15:30:52 +02:00

30 lines
906 B
TypeScript

import type { RequestHandler } from "./$types";
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
import { RemoteNodeRegistry } from "$lib/node-registry-client";
import { createPerformanceStore } from "$lib/performance";
const registry = new RemoteNodeRegistry("");
const runtime = new MemoryRuntimeExecutor(registry);
const performanceStore = createPerformanceStore();
runtime.perf = performanceStore;
export const POST: RequestHandler = async ({ request, fetch }) => {
const { graph, settings } = await request.json();
registry.fetch = fetch;
await registry.load(graph.nodes.map(node => node.type))
const res = await runtime.execute(graph, settings);
let headers: Record<string, string> = { "Content-Type": "application/octet-stream" };
if (runtime.perf) {
headers["performance"] = JSON.stringify(runtime.perf.get());
}
return new Response(res, { headers });
}