@jxsuite/server 8.0.0 → 8.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxsuite/server",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Jx development server with live reload, server-side proxy, and studio integration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -54,23 +54,23 @@
54
54
  "upgrade": "bun update --latest && bun install"
55
55
  },
56
56
  "dependencies": {
57
- "@jxsuite/ai": "^0.41.1",
58
- "@jxsuite/catalog": "^0.1.4",
57
+ "@jxsuite/ai": "^0.41.2",
58
+ "@jxsuite/catalog": "^0.1.5",
59
59
  "@jxsuite/collab": "^0.11.4",
60
- "@jxsuite/compiler": "^8.0.0",
61
- "@jxsuite/create": "^1.5.0",
62
- "@jxsuite/import": "^0.42.0",
63
- "@jxsuite/protocol": "^6.0.0",
60
+ "@jxsuite/compiler": "^8.0.1",
61
+ "@jxsuite/create": "^1.5.1",
62
+ "@jxsuite/import": "^0.42.1",
63
+ "@jxsuite/protocol": "^6.1.0",
64
64
  "@jxsuite/runtime": "^6.0.1",
65
65
  "@jxsuite/schema": "^5.0.0",
66
66
  "@jxsuite/site": "^2.2.2",
67
- "@jxsuite/starters": "^3.1.2",
67
+ "@jxsuite/starters": "^3.1.3",
68
68
  "@npmcli/arborist": "^10.0.4",
69
69
  "chokidar": "^6.0.0",
70
70
  "kysely": "^0.29.7",
71
71
  "npm-package-arg": "^14.0.0",
72
- "oxfmt": "^0.74.0",
73
- "ws": "^8.22.0",
72
+ "oxfmt": "^0.75.0",
73
+ "ws": "^8.22.1",
74
74
  "zod": "^4.6.7"
75
75
  },
76
76
  "devDependencies": {
@@ -80,6 +80,6 @@
80
80
  "@jxsuite/test-support": "^0.0.0",
81
81
  "@types/npm-package-arg": "^6.1.4",
82
82
  "@types/npmcli__arborist": "^6.3.3",
83
- "@types/ws": "^8.18.1"
83
+ "@types/ws": "^8.18.2"
84
84
  }
85
85
  }
@@ -24,6 +24,7 @@ import type { JsonObject, JsonValue } from "@jxsuite/schema/types";
24
24
  import type { PackageInfo, PackageOpResult } from "@jxsuite/protocol";
25
25
  import { addPackage, removePackage, setPackageVersions } from "./packages.ts";
26
26
  import type { PackageOpOptions } from "./packages.ts";
27
+ import { problem } from "./problem.ts";
27
28
  import { serve } from "#serve";
28
29
  import type { ServeServer } from "./serve.ts";
29
30
 
@@ -176,29 +177,29 @@ export async function handlePackagesRequest(
176
177
  return Response.json({ ok: true });
177
178
  }
178
179
  if (req.method !== "POST" || pathname !== "/") {
179
- return Response.json({ error: "Not found" }, { status: 404 });
180
+ return problem("notFound");
180
181
  }
181
182
  const length = Number(req.headers.get("content-length") ?? "0");
182
183
  if (length > MAX_BODY_BYTES) {
183
- return Response.json({ error: "Request too large" }, { status: 413 });
184
+ return problem("payloadTooLarge");
184
185
  }
185
186
  let body: JsonValue;
186
187
  try {
187
188
  // SAFETY: JSON.parse yields a JSON value; its shape is checked member by member below.
188
189
  body = JSON.parse(await req.text()) as JsonValue;
189
190
  } catch {
190
- return Response.json({ error: "Body must be JSON" }, { status: 400 });
191
+ return problem("invalidRequest", "Body must be JSON");
191
192
  }
192
193
  if (!isJsonObject(body)) {
193
- return Response.json({ error: "Body must be an object" }, { status: 400 });
194
+ return problem("invalidRequest", "Body must be an object");
194
195
  }
195
196
  const op = parseOp(body);
196
197
  if ("error" in op) {
197
- return Response.json({ error: op.error }, { status: 400 });
198
+ return problem("invalidRequest", op.error);
198
199
  }
199
200
  const files = parseFiles(body.files);
200
201
  if ("error" in files) {
201
- return Response.json({ error: files.error }, { status: 400 });
202
+ return problem("invalidRequest", files.error);
202
203
  }
203
204
  return Response.json(await runServiceOp(op, files, options));
204
205
  }
package/src/serve.node.ts CHANGED
@@ -17,6 +17,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
17
17
  import type { Duplex } from "node:stream";
18
18
  import { WebSocketServer } from "ws";
19
19
  import type { RawData, WebSocket } from "ws";
20
+ import { problem } from "./problem.ts";
20
21
  import type { ServeOptions, ServeServer, ServeSocket } from "./serve.ts";
21
22
 
22
23
  export type * from "./serve.ts";
@@ -260,13 +261,9 @@ export async function serve<Data = undefined>(
260
261
  response = await options.fetch(toRequest(nodeReq, origin, controller.signal), server);
261
262
  } catch (error) {
262
263
  console.error("[serve]", error);
263
- response = new Response("Internal Server Error", { status: 500 });
264
+ response = problem("internalError");
264
265
  }
265
- await writeResponse(
266
- response ?? new Response("Internal Server Error", { status: 500 }),
267
- res,
268
- method,
269
- );
266
+ await writeResponse(response ?? problem("internalError"), res, method);
270
267
  })();
271
268
  });
272
269
 
@@ -280,10 +277,10 @@ export async function serve<Data = undefined>(
280
277
  response = await options.fetch(req, server);
281
278
  } catch (error) {
282
279
  console.error("[serve]", error);
283
- response = new Response("Internal Server Error", { status: 500 });
280
+ response = problem("internalError");
284
281
  }
285
282
  if (!upgrade.taken) {
286
- await rejectUpgrade(socket, response ?? new Response("Upgrade failed", { status: 400 }));
283
+ await rejectUpgrade(socket, response ?? problem("invalidRequest", "Upgrade failed"));
287
284
  }
288
285
  })();
289
286
  });