@forklaunch/core 0.8.4 → 0.8.5
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/lib/src/http/index.mjs
CHANGED
@@ -831,6 +831,24 @@ var ForklaunchExpressLikeRouter = class {
|
|
831
831
|
body: discriminateBody(this.schemaValidator, request?.body)?.schema ?? {},
|
832
832
|
path: route
|
833
833
|
};
|
834
|
+
function remapFileBody(body) {
|
835
|
+
if (body instanceof File) {
|
836
|
+
return (name, contentType) => {
|
837
|
+
return new File([body], name, { type: contentType });
|
838
|
+
};
|
839
|
+
}
|
840
|
+
Object.entries(body).forEach(([key, value]) => {
|
841
|
+
if (value instanceof File) {
|
842
|
+
body[key] = (name, contentType) => {
|
843
|
+
return new File([value], name, { type: contentType });
|
844
|
+
};
|
845
|
+
} else if (typeof value === "object") {
|
846
|
+
body[key] = remapFileBody(value);
|
847
|
+
}
|
848
|
+
});
|
849
|
+
return body;
|
850
|
+
}
|
851
|
+
req.body = remapFileBody(req.body);
|
834
852
|
const res = {
|
835
853
|
status: (code) => {
|
836
854
|
statusCode = code;
|
@@ -848,8 +866,8 @@ var ForklaunchExpressLikeRouter = class {
|
|
848
866
|
setHeader: (key, value) => {
|
849
867
|
responseHeaders[key] = value;
|
850
868
|
},
|
851
|
-
|
852
|
-
responseMessage = generator;
|
869
|
+
sseEmitter: (generator) => {
|
870
|
+
responseMessage = generator();
|
853
871
|
}
|
854
872
|
};
|
855
873
|
let cursor = handlers.shift();
|