@nice-code/commander 0.89.0 → 0.90.0
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/build/cli.cjs +21 -3
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +21 -3
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-BgRBLnvt.js.map +1 -1
- package/package.json +6 -6
package/build/cli.cjs
CHANGED
|
@@ -16224,6 +16224,14 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
16224
16224
|
status: 400,
|
|
16225
16225
|
headers: { "Content-Type": "application/json" }
|
|
16226
16226
|
});
|
|
16227
|
+
const envelopeReply = (reply) => new Response(encodeExchange(reply), {
|
|
16228
|
+
status: 200,
|
|
16229
|
+
headers: { "Content-Type": "application/json" }
|
|
16230
|
+
});
|
|
16231
|
+
const envelopeError = (message) => envelopeReply({
|
|
16232
|
+
k: "err",
|
|
16233
|
+
message
|
|
16234
|
+
});
|
|
16227
16235
|
return async (request) => {
|
|
16228
16236
|
if (request.method === "OPTIONS") return withCors(new Response(null, { status: 204 }));
|
|
16229
16237
|
const url = new URL(request.url);
|
|
@@ -16237,12 +16245,18 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
16237
16245
|
headers: { "Content-Type": "application/json" }
|
|
16238
16246
|
}));
|
|
16239
16247
|
}
|
|
16248
|
+
const text = await request.text();
|
|
16249
|
+
const envelope = decodeExchangeRequest(text);
|
|
16250
|
+
if (envelope?.k === "hs") return withCors(envelopeError("plain endpoint: no handshake here — connect with `{ carrier: httpCarrier(...), secure: false }`"));
|
|
16251
|
+
if (envelope != null && "c" in envelope) return withCors(envelopeError("plain endpoint: cannot open an encrypted frame"));
|
|
16240
16252
|
let body;
|
|
16241
|
-
|
|
16242
|
-
|
|
16253
|
+
if (envelope != null) body = envelope.w;
|
|
16254
|
+
else try {
|
|
16255
|
+
body = JSON.parse(text);
|
|
16243
16256
|
} catch {
|
|
16244
16257
|
return withCors(badRequest("request body is not valid JSON"));
|
|
16245
16258
|
}
|
|
16259
|
+
const answerError = (message) => envelope != null ? envelopeError(message) : badRequest(message);
|
|
16246
16260
|
const report = options.logger != null && isActionPayload_Any_JsonObject(body) && body.type === "request" ? options.logger.onRequest(actionServeRequestInfo(body, { transport: transportLabel })) : void 0;
|
|
16247
16261
|
const startedAt = Date.now();
|
|
16248
16262
|
let running;
|
|
@@ -16256,7 +16270,7 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
16256
16270
|
durationMs: Date.now() - startedAt,
|
|
16257
16271
|
error: serveResultErrorInfo(error)
|
|
16258
16272
|
});
|
|
16259
|
-
return withCors(
|
|
16273
|
+
return withCors(answerError(error.message));
|
|
16260
16274
|
}
|
|
16261
16275
|
throw error;
|
|
16262
16276
|
}
|
|
@@ -16271,6 +16285,10 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
16271
16285
|
durationMs: Date.now() - startedAt,
|
|
16272
16286
|
error: serveResultErrorInfo(result.result.error)
|
|
16273
16287
|
});
|
|
16288
|
+
if (envelope != null) return withCors(envelopeReply({
|
|
16289
|
+
k: "act",
|
|
16290
|
+
w: result.toJsonObject()
|
|
16291
|
+
}));
|
|
16274
16292
|
return withCors(result.toHttpResponse({ useErrorStatus: options.useErrorStatus }));
|
|
16275
16293
|
}
|
|
16276
16294
|
return withCors(new Response("Not found", { status: 404 }));
|