import type { Context } from "koa"; import type {} from "@koa/bodyparser"; export async function createHeartbeats(ctx: Context) { const results = []; for (const heartbeat of ctx.request.body) { console.log("heartbeat", heartbeat); const time = new Date(heartbeat.time * 1000.0); const resp = await fetch("http://localhost:3000/node", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ attributes: [ ["panorama::time/start", time.toISOString()], ["panorama/codetrack::project", heartbeat.project], ], }), }); const data = await resp.json(); results.push({ id: data.id, }); } ctx.status = 400; // console.log("results", results); ctx.body = {}; }