@lovrozagar/honey 0.5.2 → 0.6.0

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/src/proxy.ts CHANGED
@@ -42,9 +42,9 @@ export type ProxyConfig<TCtx> = {
42
42
  rewriteUrl?: (url: string, ctx: TCtx) => string
43
43
 
44
44
  /**
45
- * Timeout in milliseconds. Default: 30000.
46
- * Accepts a number or a function that receives ctx and returns a number.
47
- * Disabled for WebSocket upgrades.
45
+ * Timeout in milliseconds. Omitted: no abort. `0` or a non-positive
46
+ * value: no abort. Accepts a number or a function that receives ctx
47
+ * and returns a number. Disabled for WebSocket upgrades.
48
48
  */
49
49
  timeout?: number | ((ctx: TCtx) => number)
50
50
  }
@@ -58,7 +58,7 @@ export type ProxyConfig<TCtx> = {
58
58
  * which has both fields — we access them via property access on the object.
59
59
  */
60
60
  export function createProxyHandler<TCtx>(config: ProxyConfig<TCtx>): (ctx: TCtx) => Promise<Response> {
61
- const timeoutOpt = config.timeout ?? 30_000
61
+ const timeoutOpt = config.timeout
62
62
 
63
63
  return async (ctx: TCtx) => {
64
64
  const timeoutMs = typeof timeoutOpt === "function" ? timeoutOpt(ctx) : timeoutOpt
@@ -67,6 +67,7 @@ export function createProxyHandler<TCtx>(config: ProxyConfig<TCtx>): (ctx: TCtx)
67
67
  const request = c["req"] as Request
68
68
  const method = request.method
69
69
  const isWs = request.headers.get("upgrade") === "websocket"
70
+ const abortMs = !isWs && timeoutMs != null && timeoutMs > 0 ? timeoutMs : undefined
70
71
 
71
72
  /* URL resolution — path + query, no new URL() */
72
73
  const rawUrl = request.url
@@ -108,7 +109,7 @@ export function createProxyHandler<TCtx>(config: ProxyConfig<TCtx>): (ctx: TCtx)
108
109
  headers,
109
110
  method,
110
111
  redirect: "manual",
111
- signal: isWs ? undefined : AbortSignal.timeout(timeoutMs),
112
+ signal: abortMs == null ? undefined : AbortSignal.timeout(abortMs),
112
113
  }
113
114
 
114
115
  /* duplex required for streaming body (Node needs it, CF handles implicitly) */
package/src/tree.ts CHANGED
@@ -12,8 +12,8 @@ export type RouteHandler = {
12
12
  _skip?: boolean
13
13
  /** boundary error key — wraps undeclared/unexpected errors (null = use default or internal_server_error) */
14
14
  bek: string | null
15
- /** pre-computed error factory subset (null = use global factory) */
16
- ef: Record<string, (...args: never[]) => unknown> | null
15
+ /** pre-computed error factory subset (omit/`null` = use global factory) */
16
+ ef?: Record<string, (...args: never[]) => unknown> | null
17
17
  /** declared error keys for this route — used for runtime enforcement */
18
18
  ek: Set<string>
19
19
  /** handler function */
@@ -32,9 +32,9 @@ export type RouteHandler = {
32
32
  /** output schemas by content-type (null = no output validation) */
33
33
  os: OutputSchemaDef | null
34
34
  /** output validator function — validates response body against schema */
35
- ov: OutputValidator | null
36
- /** registered path pattern (e.g. "/users/:id") */
37
- rp: string
35
+ ov?: OutputValidator | null
36
+ /** registered path pattern (e.g. "/users/:id"); intern trees omit this */
37
+ rp?: string
38
38
  }
39
39
 
40
40
  export type { OutputSchemaDef }