milkio 0.0.29 → 0.0.31

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.
@@ -8,6 +8,7 @@ import { failCode } from "../../../src/fail-code"
8
8
  import { TSON } from "@southern-aurora/tson"
9
9
  import { createUlid } from "../utils/create-ulid"
10
10
  import { configMilkio } from "../../../src/config/milkio"
11
+ import { headerToPlainObject } from "../utils/header-to-plain-object"
11
12
 
12
13
  export type ExecuteHttpServerOptions = {
13
14
  /**
@@ -35,7 +36,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
35
36
  ip,
36
37
  method: request.request.method,
37
38
  // @ts-ignore
38
- requestHeaders: request.request.headers.toJSON(),
39
+ requestHeaders: headerToPlainObject(request.request.headers),
39
40
  timein: new Date().getTime()
40
41
  })
41
42
 
@@ -172,7 +173,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
172
173
 
173
174
  await loggerSubmit(executeId)
174
175
  runtime.execute.executeIds.delete(executeId)
175
-
176
+
176
177
  return new Response(response.body, response)
177
178
  }
178
179
 
package/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./utils/env-to-string"
8
8
  export * from "./utils/env-to-number"
9
9
  export * from "./utils/env-to-boolean"
10
10
  export * from "./utils/create-template"
11
+ export * from "./utils/header-to-plain-object"
11
12
 
12
13
  // defines
13
14
  export * from "./defines/define-use"
package/kernel/milkio.ts CHANGED
@@ -4,6 +4,7 @@ import schema from "../../../generated/api-schema"
4
4
  import type { Context } from "../../../src/context"
5
5
  import { failCode } from "../../../src/fail-code"
6
6
  import type { MilkioContext } from "./context"
7
+ import { headerToPlainObject } from "../utils/header-to-plain-object"
7
8
  import { type Mixin, type ExecuteId, type Fail, type FailEnumerates, loggerPushTags, loggerSubmit, runtime, TSON, type Logger, useLogger } from ".."
8
9
  import { hanldeCatchError } from "../utils/handle-catch-error"
9
10
  import { createUlid } from "../utils/create-ulid"
@@ -98,7 +99,7 @@ async function _execute<Path extends keyof (typeof schema)["apiMethodsTypeSchema
98
99
  logger,
99
100
  onAfterHeaders: (headers) => {
100
101
  loggerPushTags(executeId, {
101
- headers: headers.toJSON()
102
+ headers: headerToPlainObject(headers)
102
103
  })
103
104
  }
104
105
  })
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.0.29",
5
+ "version": "0.0.31",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },
@@ -1,4 +1,4 @@
1
- import { argv } from "bun"
1
+ import { argv } from "node:process"
2
2
  import { camel, hump, hyphen } from "@poech/camel-hump-under"
3
3
 
4
4
  export type CreateTemplateTools = {
@@ -0,0 +1,8 @@
1
+ export const headerToPlainObject = (headers: Headers) => {
2
+ if (headers.toJSON) return headers.toJSON()
3
+ const plainHeaders: Record<string, string> = {}
4
+ headers.forEach((value, key) => {
5
+ plainHeaders[key] = value
6
+ })
7
+ return headers
8
+ }