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