@beastmode-develeap/beastmode 0.1.73 → 0.1.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4623,6 +4623,46 @@ function proxyBinaryToBoard(boardUrl, path, query) {
4623
4623
  req.end();
4624
4624
  });
4625
4625
  }
4626
+ function transparentProxyToBoard(boardUrl, method, path, body, query) {
4627
+ return new Promise((resolve20, reject) => {
4628
+ const url = new URL(path, boardUrl);
4629
+ if (query) {
4630
+ for (const [k, v] of Object.entries(query)) {
4631
+ if (v !== void 0 && v !== null && v !== "") {
4632
+ url.searchParams.set(k, v);
4633
+ }
4634
+ }
4635
+ }
4636
+ const postData = body !== void 0 ? JSON.stringify(body) : void 0;
4637
+ const req = http2.request(
4638
+ url,
4639
+ {
4640
+ method,
4641
+ headers: {
4642
+ "Content-Type": "application/json",
4643
+ ...postData ? { "Content-Length": Buffer.byteLength(postData).toString() } : {}
4644
+ }
4645
+ },
4646
+ (res) => {
4647
+ const chunks = [];
4648
+ res.on("data", (chunk) => chunks.push(chunk));
4649
+ res.on("end", () => {
4650
+ resolve20({
4651
+ statusCode: res.statusCode || 502,
4652
+ contentType: res.headers["content-type"] || "application/json",
4653
+ body: Buffer.concat(chunks)
4654
+ });
4655
+ });
4656
+ }
4657
+ );
4658
+ req.on(
4659
+ "error",
4660
+ (err) => reject(new Error(`Board proxy error: ${err.message}`))
4661
+ );
4662
+ if (postData) req.write(postData);
4663
+ req.end();
4664
+ });
4665
+ }
4626
4666
  function scopedQuery(query) {
4627
4667
  if (!query) return void 0;
4628
4668
  const b = query.board;
@@ -6564,6 +6604,22 @@ async function startServer(options = {}) {
6564
6604
  return;
6565
6605
  }
6566
6606
  }
6607
+ if (url.startsWith("/api/") && boardRoutes.length > 0 && options.factoryPath && (method === "GET" || method === "POST" || method === "PATCH" || method === "DELETE")) {
6608
+ try {
6609
+ const body = method === "POST" || method === "PATCH" ? await parseBody(req) : void 0;
6610
+ const proxied = await transparentProxyToBoard(
6611
+ getBoardUrl2(options.factoryPath),
6612
+ method,
6613
+ url.split("?")[0],
6614
+ body,
6615
+ query
6616
+ );
6617
+ res.writeHead(proxied.statusCode, { "Content-Type": proxied.contentType });
6618
+ res.end(proxied.body);
6619
+ return;
6620
+ } catch {
6621
+ }
6622
+ }
6567
6623
  sendJson(res, 404, { error: "Not found" });
6568
6624
  });
6569
6625
  if (chatManager) {