milkio 0.2.10 → 0.2.12

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/c.ts CHANGED
@@ -30,7 +30,9 @@ const commands = {
30
30
  const command = Buffer.from(commandBase64ed, "base64").toString("utf-8");
31
31
  console.log("\x1B[2m%s\x1B[0m", `$ ${command}`);
32
32
  console.log(``);
33
- await $`${{ raw: command }}`;
33
+ try {
34
+ await $`${{ raw: command }}`;
35
+ } catch (e) {}
34
36
  process.on("SIGINT", () => {}); // prevent users from exiting by pressing ctrl + c
35
37
  while (true) await new Promise((resolve) => process.stdin.on("keypress", resolve));
36
38
  },
@@ -92,7 +92,11 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
92
92
  body: rawbody || "no body",
93
93
  });
94
94
 
95
- if (!detail.response.body) detail.response.body = `{"executeId":"${executeId}","success":false,"fail":{"code":"NOT_FOUND","message":${JSON.stringify(failCode.NOT_FOUND())}}}`;
95
+ if (!detail.response.body) {
96
+ if (!detail.response.headers["Content-Type"]) detail.response.headers["Content-Type"] = "application/json";
97
+ if (!detail.response.headers["Cache-Control"]) detail.response.headers["Cache-Control"] = "no-cache";
98
+ detail.response.body = `{"executeId":"${executeId}","success":false,"fail":{"code":"NOT_FOUND","message":"${failCode.NOT_FOUND()}"}}`;
99
+ }
96
100
  await MiddlewareEvent.handle("httpNotFound", [detail]);
97
101
 
98
102
  loggerPushTags(executeId, {
@@ -159,10 +163,12 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
159
163
  };
160
164
  await MiddlewareEvent.handle("beforeHttpResponse", [middlewareResponse, detail]);
161
165
 
166
+ if (!detail.response.headers["Content-Type"]) detail.response.headers["Content-Type"] = "application/json";
162
167
  if (!detail.response.headers["Cache-Control"]) detail.response.headers["Cache-Control"] = "no-cache";
163
168
  if (!detail.response.body) detail.response.body = middlewareResponse.value;
164
169
  } catch (error) {
165
170
  const result = hanldeCatchError(error, executeId);
171
+ if (!response.headers["Content-Type"]) response.headers["Content-Type"] = "application/json";
166
172
  if (!response.headers["Cache-Control"]) response.headers["Cache-Control"] = "no-cache";
167
173
  if (!response.body) response.body = TSON.stringify(result);
168
174
  }
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.10",
5
+ "version": "0.2.12",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },