milkio 0.7.0-alpha.12 → 0.7.0-alpha.13
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.
|
@@ -29,12 +29,11 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
|
|
|
29
29
|
runtime.execute.executeIds.add(executeId);
|
|
30
30
|
const logger = useLogger(executeId);
|
|
31
31
|
const ip = options.getRealIp ? options.getRealIp(request.request) : (request.request.headers.get("X-Forwarded-For") as string | undefined)?.split(",")[0] ?? "0.0.0.0";
|
|
32
|
-
const headers = request.request.headers;
|
|
32
|
+
const headers = request.request.headers as Headers;
|
|
33
33
|
|
|
34
34
|
loggerPushTags(executeId, {
|
|
35
35
|
from: "http-server",
|
|
36
36
|
url: fullurl.pathname,
|
|
37
|
-
fullurl: fullurl.pathname,
|
|
38
37
|
ip,
|
|
39
38
|
method: request.request.method,
|
|
40
39
|
// @ts-ignore
|
|
@@ -81,7 +80,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
|
|
|
81
80
|
path: pathstr,
|
|
82
81
|
ip,
|
|
83
82
|
executeId,
|
|
84
|
-
fullurl,
|
|
83
|
+
fullurl: fullurl as URL,
|
|
85
84
|
request: request.request,
|
|
86
85
|
response,
|
|
87
86
|
};
|
|
@@ -221,7 +220,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
|
|
|
221
220
|
cancel() {
|
|
222
221
|
control.close();
|
|
223
222
|
},
|
|
224
|
-
}
|
|
223
|
+
});
|
|
225
224
|
} else {
|
|
226
225
|
// node.js or others
|
|
227
226
|
stream = new ReadableStream({
|
|
@@ -285,7 +284,11 @@ export type MilkioHttpRequest = {
|
|
|
285
284
|
export type MilkioHttpResponse = Mixin<
|
|
286
285
|
ResponseInit,
|
|
287
286
|
{
|
|
288
|
-
body: string
|
|
287
|
+
body: string
|
|
288
|
+
| Blob
|
|
289
|
+
| FormData
|
|
290
|
+
| URLSearchParams
|
|
291
|
+
| ReadableStream<Uint8Array>;
|
|
289
292
|
status: number;
|
|
290
293
|
headers: Record<string, string>;
|
|
291
294
|
}
|
package/kernel/execute.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from "../../../src/context";
|
|
2
2
|
import { failCode } from "../../../src/fail-code";
|
|
3
3
|
import schema from "../../../generated/api-schema";
|
|
4
|
-
import { type ExecuteId, type ExecuteOptions, type ExecuteResult, createUlid, useLogger, runtime, loggerPushTags, headerToPlainObject, loggerSubmit, type ExecuteCoreOptions, TSON, MiddlewareEvent, reject, _validate, ExecuteStreamResult, createStep } from "..";
|
|
4
|
+
import { type ExecuteId, type ExecuteOptions, type ExecuteResult, createUlid, useLogger, runtime, loggerPushTags, headerToPlainObject, loggerSubmit, type ExecuteCoreOptions, TSON, MiddlewareEvent, reject, _validate, ExecuteStreamResult, createStep, Steps } from "..";
|
|
5
5
|
import { handleCatchError } from "../utils/handle-catch-error";
|
|
6
6
|
|
|
7
7
|
const apis = new Map<string, any>();
|
|
@@ -56,7 +56,7 @@ export async function _call(
|
|
|
56
56
|
headers,
|
|
57
57
|
logger: options.logger,
|
|
58
58
|
detail: options?.detail ?? {} as any,
|
|
59
|
-
step: createStep(),
|
|
59
|
+
step: createStep() as any,
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
let result: { value: unknown };
|
|
@@ -126,7 +126,7 @@ export async function _execute<Path extends keyof (typeof schema)["apiMethodsTyp
|
|
|
126
126
|
logger,
|
|
127
127
|
onAfterHeaders: (headers) => {
|
|
128
128
|
loggerPushTags(executeId, {
|
|
129
|
-
|
|
129
|
+
requestHeaders: headerToPlainObject(headers),
|
|
130
130
|
});
|
|
131
131
|
},
|
|
132
132
|
});
|
|
@@ -183,7 +183,7 @@ export async function _executeStream<Path extends keyof (typeof schema)["apiMeth
|
|
|
183
183
|
logger,
|
|
184
184
|
onAfterHeaders: (headers) => {
|
|
185
185
|
loggerPushTags(executeId, {
|
|
186
|
-
|
|
186
|
+
requestHeaders: headerToPlainObject(headers)
|
|
187
187
|
});
|
|
188
188
|
},
|
|
189
189
|
});
|
package/kernel/logger.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export const headerToPlainObject = (headers: Headers) => {
|
|
1
|
+
export const headerToPlainObject = (headers: Headers): Record<string, string> => {
|
|
2
2
|
if (headers.toJSON) return headers.toJSON();
|
|
3
3
|
const plainHeaders: Record<string, string> = {};
|
|
4
4
|
headers.forEach((value, key) => {
|
|
5
5
|
plainHeaders[key] = value;
|
|
6
6
|
});
|
|
7
|
-
return
|
|
7
|
+
return plainHeaders;
|
|
8
8
|
};
|