@faapi/faapi 5.3.0 → 5.4.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/dist/cli/index.js +17 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -8418,13 +8418,28 @@ async function createAppBase(options) {
|
|
|
8418
8418
|
reject(new Error("No request handler found"));
|
|
8419
8419
|
return;
|
|
8420
8420
|
}
|
|
8421
|
-
|
|
8421
|
+
let payload;
|
|
8422
|
+
let defaultContentType;
|
|
8423
|
+
if (body !== void 0) {
|
|
8424
|
+
if (typeof body === "string") {
|
|
8425
|
+
payload = Buffer.from(body, "utf-8");
|
|
8426
|
+
defaultContentType = "text/plain";
|
|
8427
|
+
} else if (body instanceof Uint8Array) {
|
|
8428
|
+
payload = Buffer.from(body);
|
|
8429
|
+
defaultContentType = "application/octet-stream";
|
|
8430
|
+
} else {
|
|
8431
|
+
payload = Buffer.from(JSON.stringify(body));
|
|
8432
|
+
defaultContentType = "application/json";
|
|
8433
|
+
}
|
|
8434
|
+
}
|
|
8435
|
+
const mockReq = Readable4.from(payload !== void 0 ? [payload] : []);
|
|
8422
8436
|
mockReq.method = method;
|
|
8423
8437
|
mockReq.url = `${reqPath}${queryStr}`;
|
|
8438
|
+
const hasCallerContentType = "content-type" in reqHeaders || "Content-Type" in reqHeaders;
|
|
8424
8439
|
mockReq.headers = {
|
|
8425
8440
|
...reqHeaders,
|
|
8426
8441
|
host: "localhost",
|
|
8427
|
-
|
|
8442
|
+
...payload !== void 0 && !hasCallerContentType ? { "content-type": defaultContentType } : {}
|
|
8428
8443
|
};
|
|
8429
8444
|
mockReq.socket = { remoteAddress: "127.0.0.1" };
|
|
8430
8445
|
handler(
|