milkio 0.2.14 → 0.2.15

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.
@@ -122,7 +122,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
122
122
  // execute api
123
123
  // after request middleware
124
124
  await MiddlewareEvent.handle("afterHttpRequest", [headers, detail]);
125
- const mode = headers.get("Accept") === "text/event-stream" ? "stream" : "execute";
125
+ const mode = (headers.get("Accept")) === "text/event-stream" ? "stream" : "execute";
126
126
 
127
127
  const rawbody = await request.request.text();
128
128
  loggerPushTags(executeId, {
@@ -130,16 +130,17 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
130
130
  });
131
131
 
132
132
  let params: any;
133
- if (rawbody === "") {
134
- params = undefined;
135
- } else {
136
- try {
137
- params = JSON.parse(rawbody);
138
- } catch (error) {
139
- const logger = useLogger(executeId);
140
- logger.log("TIP: body is not json, the content is not empty, but the content is not in a valid JSON format. The original content value can be retrieved via request.request.text()");
133
+ try {
134
+ if (rawbody) params = JSON.parse(rawbody);
135
+ else if (request.request.method === 'GET' && fullurl.searchParams.get('params')) {
136
+ params = JSON.parse(decodeURIComponent(fullurl.searchParams.get('params')!));
137
+ } else {
141
138
  params = undefined;
142
139
  }
140
+ } catch (error) {
141
+ const logger = useLogger(executeId);
142
+ logger.log("TIP: body is not json, the content is not empty, but the content is not in a valid JSON format. The original content value can be retrieved via request.request.text()");
143
+ params = undefined;
143
144
  }
144
145
 
145
146
  loggerPushTags(executeId, {
package/kernel/execute.ts CHANGED
@@ -90,6 +90,8 @@ export async function _call(
90
90
 
91
91
  if (mode === "execute" && !(result.value as AsyncGenerator)[Symbol.asyncIterator]) return { $type: "result", $result: { executeId, success: true, data: result.value } };
92
92
  if (mode === "stream" && (result.value as AsyncGenerator)[Symbol.asyncIterator]) return { $type: "stream", $result: { executeId, success: true, data: "$" }, $generator: result.value as AsyncGenerator };
93
+ console.log(mode);
94
+
93
95
  throw reject("BUSINESS_FAIL", `It looks like you used the wrong syntax, for this API you should use "client.${mode}(...)"`);
94
96
  } catch (error: any) {
95
97
  const errorResult = handleCatchError(error, executeId);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.2.14",
5
+ "version": "0.2.15",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },