elysia 2.0.0-exp.2 → 2.0.0-exp.21

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.
Files changed (135) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +2 -0
  2. package/dist/adapter/bun/index.d.ts +2 -25
  3. package/dist/adapter/bun/index.js +18 -12
  4. package/dist/adapter/bun/index.mjs +19 -13
  5. package/dist/adapter/bun/router.js +1 -1
  6. package/dist/adapter/bun/router.mjs +1 -1
  7. package/dist/adapter/constants.d.ts +3 -26
  8. package/dist/adapter/index.d.ts +1 -26
  9. package/dist/adapter/index.js +1 -17
  10. package/dist/adapter/index.mjs +1 -17
  11. package/dist/adapter/types.d.ts +1 -0
  12. package/dist/adapter/utils.d.ts +3 -4
  13. package/dist/adapter/utils.js +83 -81
  14. package/dist/adapter/utils.mjs +82 -80
  15. package/dist/adapter/web-standard/handler.js +6 -3
  16. package/dist/adapter/web-standard/handler.mjs +6 -3
  17. package/dist/adapter/web-standard/index.d.ts +2 -26
  18. package/dist/adapter/web-standard/index.js +12 -1
  19. package/dist/adapter/web-standard/index.mjs +12 -1
  20. package/dist/base.d.ts +38 -68
  21. package/dist/base.js +133 -97
  22. package/dist/base.mjs +133 -97
  23. package/dist/compile/aot.d.ts +22 -1
  24. package/dist/compile/aot.js +22 -0
  25. package/dist/compile/aot.mjs +22 -0
  26. package/dist/compile/handler/index.d.ts +2 -2
  27. package/dist/compile/handler/index.js +85 -456
  28. package/dist/compile/handler/index.mjs +86 -457
  29. package/dist/compile/handler/jit.d.ts +35 -0
  30. package/dist/compile/handler/jit.js +445 -0
  31. package/dist/compile/handler/jit.mjs +443 -0
  32. package/dist/compile/handler/params.js +3 -2
  33. package/dist/compile/handler/params.mjs +4 -3
  34. package/dist/compile/handler/reconstruct.d.ts +13 -0
  35. package/dist/compile/handler/reconstruct.js +29 -0
  36. package/dist/compile/handler/reconstruct.mjs +28 -0
  37. package/dist/compile/handler/utils.d.ts +2 -1
  38. package/dist/compile/handler/utils.js +9 -3
  39. package/dist/compile/handler/utils.mjs +9 -4
  40. package/dist/compile/jit-probe.d.ts +19 -0
  41. package/dist/compile/jit-probe.js +38 -0
  42. package/dist/compile/jit-probe.mjs +36 -0
  43. package/dist/cookie/index.d.ts +4 -3
  44. package/dist/cookie/index.js +2 -1
  45. package/dist/cookie/index.mjs +2 -1
  46. package/dist/cookie/serialize.d.ts +6 -0
  47. package/dist/cookie/serialize.js +28 -0
  48. package/dist/cookie/serialize.mjs +27 -0
  49. package/dist/cookie/utils.d.ts +1 -2
  50. package/dist/cookie/utils.js +2 -23
  51. package/dist/cookie/utils.mjs +5 -25
  52. package/dist/handler/error.js +2 -2
  53. package/dist/handler/error.mjs +3 -3
  54. package/dist/handler/fetch.js +49 -42
  55. package/dist/handler/fetch.mjs +50 -43
  56. package/dist/index.d.ts +13 -8
  57. package/dist/index.js +11 -4
  58. package/dist/index.mjs +7 -6
  59. package/dist/parse-query.js +1 -1
  60. package/dist/parse-query.mjs +1 -1
  61. package/dist/plugin/bun.d.ts +10 -0
  62. package/dist/plugin/bun.js +18 -1
  63. package/dist/plugin/bun.mjs +19 -2
  64. package/dist/plugin/core.d.ts +61 -1
  65. package/dist/plugin/core.js +90 -10
  66. package/dist/plugin/core.mjs +90 -12
  67. package/dist/plugin/esbuild.d.ts +10 -0
  68. package/dist/plugin/esbuild.js +18 -1
  69. package/dist/plugin/esbuild.mjs +19 -2
  70. package/dist/plugin/source.d.ts +38 -1
  71. package/dist/plugin/source.js +104 -13
  72. package/dist/plugin/source.mjs +102 -14
  73. package/dist/plugin/vite.d.ts +7 -0
  74. package/dist/plugin/vite.js +22 -1
  75. package/dist/plugin/vite.mjs +23 -2
  76. package/dist/sucrose.js +23 -10
  77. package/dist/sucrose.mjs +23 -10
  78. package/dist/trace.d.ts +1 -1
  79. package/dist/trace.js +4 -6
  80. package/dist/trace.mjs +4 -6
  81. package/dist/type/bridge.d.ts +9 -8
  82. package/dist/type/coerce.d.ts +20 -2
  83. package/dist/type/coerce.js +110 -0
  84. package/dist/type/coerce.mjs +109 -2
  85. package/dist/type/compat.js +4 -3
  86. package/dist/type/compat.mjs +2 -1
  87. package/dist/type/constants.d.ts +1 -1
  88. package/dist/type/elysia/boolean-string.js +1 -1
  89. package/dist/type/elysia/boolean-string.mjs +1 -1
  90. package/dist/type/elysia/file-type.js +1 -1
  91. package/dist/type/elysia/file-type.mjs +1 -1
  92. package/dist/type/elysia/integer-string.js +1 -1
  93. package/dist/type/elysia/integer-string.mjs +1 -1
  94. package/dist/type/exports.js +29 -2059
  95. package/dist/type/exports.mjs +7 -295
  96. package/dist/type/index.d.ts +6 -2
  97. package/dist/type/index.js +4 -0
  98. package/dist/type/index.mjs +3 -1
  99. package/dist/type/types.d.ts +1 -1
  100. package/dist/type/utils.js +4 -4
  101. package/dist/type/utils.mjs +4 -4
  102. package/dist/type/validator/custom-error.d.ts +10 -0
  103. package/dist/type/validator/custom-error.js +113 -0
  104. package/dist/type/validator/custom-error.mjs +110 -0
  105. package/dist/type/validator/default-precompute.d.ts +22 -0
  106. package/dist/type/validator/default-precompute.js +476 -0
  107. package/dist/type/validator/default-precompute.mjs +465 -0
  108. package/dist/type/validator/frozen-check.d.ts +11 -0
  109. package/dist/type/validator/frozen-check.js +19 -0
  110. package/dist/type/validator/frozen-check.mjs +18 -0
  111. package/dist/type/{validator.d.ts → validator/index.d.ts} +7 -20
  112. package/dist/type/validator/index.js +572 -0
  113. package/dist/type/validator/index.mjs +567 -0
  114. package/dist/type/validator/string-codec-aot.d.ts +9 -0
  115. package/dist/type/validator/string-codec-aot.js +106 -0
  116. package/dist/type/validator/string-codec-aot.mjs +102 -0
  117. package/dist/type/validator/validator-cache.d.ts +21 -0
  118. package/dist/type/validator/validator-cache.js +163 -0
  119. package/dist/type/validator/validator-cache.mjs +161 -0
  120. package/dist/types.d.ts +22 -14
  121. package/dist/universal/file.d.ts +1 -1
  122. package/dist/universal/file.js +35 -29
  123. package/dist/universal/file.mjs +35 -29
  124. package/dist/utils.d.ts +12 -1
  125. package/dist/utils.js +89 -45
  126. package/dist/utils.mjs +88 -46
  127. package/dist/validator/index.d.ts +1 -1
  128. package/dist/validator/index.js +15 -2
  129. package/dist/validator/index.mjs +15 -2
  130. package/dist/validator/route.d.ts +0 -1
  131. package/dist/ws/route.js +47 -24
  132. package/dist/ws/route.mjs +48 -25
  133. package/package.json +10 -4
  134. package/dist/type/validator.js +0 -1033
  135. package/dist/type/validator.mjs +0 -1029
@@ -0,0 +1,443 @@
1
+ import { hasHeaderShorthand } from "../../universal/constants.mjs";
2
+ import { isDynamicRegex } from "../../constants.mjs";
3
+ import { requestId } from "../../utils.mjs";
4
+ import { tee } from "../../adapter/utils.mjs";
5
+ import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
6
+ import { parseQueryFromURL } from "../../parse-query.mjs";
7
+ import { sucrose } from "../../sucrose.mjs";
8
+ import { Capture } from "../aot.mjs";
9
+ import { isAsyncFunction, isAsyncLifecycle, mayReturnPromise } from "../utils.mjs";
10
+ import { cloneResponse, getQueryParseArgs, hasRequestBody, mapAfterHandle, mapAfterResponse, mapBeforeHandle, mapError, mapMapResponse, mapTransform } from "./utils.mjs";
11
+ import { compileCookieConfig } from "../../cookie/config.mjs";
12
+ import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
13
+ import { forwardError } from "../../handler/utils.mjs";
14
+ import { createTracer } from "../../trace.mjs";
15
+ import { JITProbe } from "../jit-probe.mjs";
16
+
17
+ //#region src/compile/handler/jit.ts
18
+ const parseFormData = "c.body=await pf(c)\n";
19
+ const matchReturnIdentifier = /(?:=>|\breturn)\s+(?!(?:true|false|null|undefined|void|new|typeof|async|await|function|class)\b)[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*(?![\w$([])/;
20
+ const mayReturnIdentifier = (fn) => matchReturnIdentifier.test(fn.toString());
21
+ let captureHeaderShorthand;
22
+ const setCaptureHeaderShorthand = (value) => {
23
+ captureHeaderShorthand = value;
24
+ };
25
+ function builtinParser(adapter, parse, link) {
26
+ switch (parse) {
27
+ case "formdata":
28
+ case "multipart/form-data":
29
+ link(adapter.formData, "pf");
30
+ return parseFormData;
31
+ case "json":
32
+ case "application/json":
33
+ link(adapter.json, "pj");
34
+ return "c.body=await pj(c)\n";
35
+ case "urlencoded":
36
+ case "application/x-www-form-urlencoded":
37
+ link(adapter.urlencoded, "pu");
38
+ return "c.body=await pu(c)\n";
39
+ case "arrayBuffer":
40
+ case "application/octet-stream":
41
+ link(adapter.arrayBuffer, "pa");
42
+ return "c.body=await pa(c)\n";
43
+ case "text":
44
+ case "text/plain":
45
+ link(adapter.text, "pt");
46
+ return "c.body=await pt(c)\n";
47
+ case "none": return "";
48
+ default: throw new Error(`Unsupported content type: ${parse}`);
49
+ }
50
+ }
51
+ function parse(adapter, parsers, bodyVali, hasHeaders, link, report) {
52
+ if (parsers && typeof parsers === "function") parsers = [parsers];
53
+ if (typeof parsers === "string" || parsers?.length === 1 && typeof parsers[0] === "string") {
54
+ if (parsers.length === 1) parsers = parsers[0];
55
+ const builtinName = parsers;
56
+ const child = report?.resolveChild(builtinName);
57
+ const begin = child ? child.begin : "";
58
+ const end = child ? child.end() : "";
59
+ return begin + builtinParser(adapter, parsers, link) + end;
60
+ }
61
+ let hasFn = false;
62
+ let hasType = false;
63
+ if (parsers) {
64
+ for (let i = 0; i < parsers.length; i++) if (typeof parsers[i] === "function") {
65
+ hasFn = true;
66
+ break;
67
+ }
68
+ }
69
+ let code = `let ct=((${hasHeaders ? "c.headers['content-type']" : "c.request.headers.get('content-type')"})||'')\nlet cti=ct.indexOf(";")
70
+ if(cti!==-1)ct=ct.slice(0,cti)
71
+ ` + (hasFn ? "c.contentType=ct\n" : "");
72
+ if (parsers) for (let i = 0; i < parsers.length; i++) {
73
+ const parser = parsers[i];
74
+ if (typeof parser === "function") {
75
+ link(0, "");
76
+ const child = report?.resolveChild(parser.name || "anonymous");
77
+ if (i) code += "if(!hasBody){";
78
+ if (child) code += child.begin;
79
+ code += isAsyncFunction(parser) ? `c.body=await ho.parse[${i}](c,ct)\n` : `_bp=ho.parse[${i}](c,ct)\nif(_bp instanceof Promise)_bp=await _bp\nc.body=_bp\n`;
80
+ code += "hasBody=c.body!==undefined\n";
81
+ if (child) code += child.end();
82
+ if (i) code += "}\n";
83
+ } else {
84
+ hasType = true;
85
+ const child = report?.resolveChild(parser);
86
+ if (i) code += "if(!hasBody){\n";
87
+ if (child) code += child.begin;
88
+ code += builtinParser(adapter, parser, link);
89
+ if (child) code += child.end();
90
+ if (i) code += "}\n";
91
+ break;
92
+ }
93
+ }
94
+ if (!hasType) {
95
+ const child = report?.resolveChild("default");
96
+ const begin = child ? child.begin : "";
97
+ const end = child ? child.end() : "";
98
+ const guard = bodyVali ? "ct" : "ct&&hb(c.request)";
99
+ code += hasFn ? `if(!hasBody&&${guard}){${begin}c.body=ct.charCodeAt(12)===106?await pj(c):await pd(c,ct)\n${end}}\n` : `if(${guard}){${begin}c.body=ct.charCodeAt(12)===106?await pj(c):await pd(c,ct)\n${end}}\n`;
100
+ if (!bodyVali) link(hasRequestBody, "hb");
101
+ link(adapter.json, "pj");
102
+ link(adapter.default, "pd");
103
+ }
104
+ return hasFn ? "let hasBody=false,_bp\n" + code : code;
105
+ }
106
+ const isAsyncValidator = (vali) => vali?.isAsync ?? true;
107
+ const createInlineHandler = (map, h) => ((c) => {
108
+ const r = h(c);
109
+ if (r instanceof Error) throw r;
110
+ if (r instanceof Promise) return r.then((v) => map(forwardError(v), c.request));
111
+ return map(r, c.request);
112
+ });
113
+ const createInlineHandlerWithSet = (map, h) => ((c) => {
114
+ const r = h(c);
115
+ if (r instanceof Error) throw r;
116
+ if (r instanceof Promise) return r.then((v) => map(forwardError(v), c.set, c.request));
117
+ return map(r, c.set, c.request);
118
+ });
119
+ function compileHandlerJit({ method, path, handler, instance, root, hook, adapter, buildValidator, isHandleFunction, isStaticResponse, isPromiseHandler }) {
120
+ const vali = buildValidator();
121
+ JITProbe.record("sucrose");
122
+ const inference = sucrose(handler, hook);
123
+ const params = /* @__PURE__ */ new Set();
124
+ let alias = "";
125
+ function link(v, key) {
126
+ if (v === 0) {
127
+ if (!params.has(hook)) {
128
+ params.add(hook);
129
+ alias += `${alias ? "," : ""}ho`;
130
+ }
131
+ return;
132
+ }
133
+ if (!params.has(v)) {
134
+ params.add(v);
135
+ alias += `${alias ? "," : ""}${key}`;
136
+ }
137
+ }
138
+ if (hook && typeof hook.parse === "function") hook.parse = [hook.parse];
139
+ const parseLength = Array.isArray(hook?.parse) ? hook.parse.length : 0;
140
+ const parseFirst = Array.isArray(hook?.parse) ? hook.parse[0] : hook?.parse;
141
+ const hasStandaloneBody = !!hook?.schemas?.some((s) => s?.body);
142
+ const bodylessMethod = method === "GET" || method === "HEAD";
143
+ const hasBody = !!hook?.body || hasStandaloneBody || !bodylessMethod && (parseLength > 0 || inference.body) && parseFirst !== "none";
144
+ const bodyValiIsAsync = hasBody && isAsyncValidator(vali?.body);
145
+ const headersValiIsAsync = vali?.headers && isAsyncValidator(vali?.headers);
146
+ const paramsValiIsAsync = vali?.params && isAsyncValidator(vali?.params);
147
+ const queryValiIsAsync = vali?.query && isAsyncValidator(vali?.query);
148
+ const cookieValidIsAsync = vali?.cookie && isAsyncValidator(vali?.cookie);
149
+ const appCookieConfig = root["~config"]?.cookie;
150
+ const needsCookie = !!vali?.cookie || !!inference.cookie;
151
+ const cookieConfig = needsCookie ? compileCookieConfig(hook?.cookie, appCookieConfig) : void 0;
152
+ const hasCookieSign = !!cookieConfig?.hasSign;
153
+ const hasErrorHook = !!hook?.error?.length;
154
+ const hasAfterResponse = !!hook?.afterResponse?.length;
155
+ const hasBeforeHandle = !!hook?.beforeHandle?.length;
156
+ const hasAfterHandle = !!hook?.afterHandle?.length;
157
+ const hasMapResponse = !!hook?.mapResponse?.length;
158
+ const hasResponseValidator = !!vali?.response;
159
+ const traceHandlers = hook?.trace ?? void 0;
160
+ const hasTrace = !!traceHandlers?.length;
161
+ const traceCount = hasTrace ? traceHandlers.length : 0;
162
+ const beginTrace = (phase, total) => {
163
+ if (!hasTrace) return "";
164
+ let s = "";
165
+ for (let i = 0; i < traceCount; i++) s += `rp${i}=tr${i}.${phase}({id:c.rid,event:'${phase}',name:'${phase}',begin:performance.now(),total:${total}})\n`;
166
+ return s;
167
+ };
168
+ const endTrace = (errBinding) => {
169
+ if (!hasTrace) return "";
170
+ let s = "";
171
+ for (let i = 0; i < traceCount; i++) s += `rp${i}.resolve(${errBinding ?? ""})\n`;
172
+ return s;
173
+ };
174
+ const buildReport = (phase) => {
175
+ if (!hasTrace) return;
176
+ return { resolveChild(name) {
177
+ let begin = "";
178
+ for (let i = 0; i < traceCount; i++) begin += `rpc${i}=rp${i}.resolveChild?.shift?.()?.({id:c.rid,event:'${phase}',name:${JSON.stringify(name)},begin:performance.now()})\n`;
179
+ return {
180
+ begin,
181
+ end(errBinding) {
182
+ let close = "";
183
+ for (let i = 0; i < traceCount; i++) if (errBinding) close += `if(${errBinding} instanceof Error){rpc${i}?.(${errBinding})}else{rpc${i}?.()}\n`;
184
+ else close += `rpc${i}?.()\n`;
185
+ return close;
186
+ }
187
+ };
188
+ } };
189
+ };
190
+ let responseValiAsync = false;
191
+ if (vali?.response) {
192
+ for (const code in vali.response) if (isAsyncValidator(vali.response[code])) {
193
+ responseValiAsync = true;
194
+ break;
195
+ }
196
+ }
197
+ const handlerIsAsync = isHandleFunction && isAsyncFunction(handler);
198
+ const errorHookForcesAsync = hasErrorHook && (hasAfterHandle || hasMapResponse || hasResponseValidator);
199
+ const responseValiForcesAsync = hasResponseValidator && isHandleFunction && !handlerIsAsync && (mayReturnPromise(handler) || mayReturnIdentifier(handler));
200
+ const afterResponseForcesAsync = hasAfterResponse && (isAsyncLifecycle(hook?.afterResponse) || hasAfterHandle || hasMapResponse || hasResponseValidator || hasErrorHook);
201
+ const isAsync = hasBody || handlerIsAsync || errorHookForcesAsync || responseValiForcesAsync || afterResponseForcesAsync || hasTrace || hasCookieSign || responseValiAsync || hook && (!!isAsyncLifecycle(hook?.afterHandle) || !!isAsyncLifecycle(hook?.beforeHandle) || !!isAsyncLifecycle(hook?.transform) || !!isAsyncLifecycle(hook?.mapResponse) || !!isAsyncLifecycle(hook?.error) || bodyValiIsAsync || headersValiIsAsync || paramsValiIsAsync || queryValiIsAsync || cookieValidIsAsync);
202
+ const callHandlerSyncOnAsync = isAsync && isHandleFunction && !handlerIsAsync;
203
+ const syncErrorHook = hasErrorHook && !isAsync && !hasTrace;
204
+ const syncAfterResponse = hasAfterResponse && !isAsync && !hasTrace && !hasErrorHook;
205
+ const callHandler = isHandleFunction ? callHandlerSyncOnAsync ? `_r=h(c)\nif(_r instanceof Promise)_r=await _r\n` : `_r=${isAsync ? "await " : ""}h(c)\n` : isStaticResponse ? `_r=h.clone()\n` : isPromiseHandler ? `_r=h.then(cr)\n` : `_r=h\n`;
206
+ let code = `${isAsync ? "async " : ""}function route(c){\n`;
207
+ if ((hasAfterResponse || hasTrace) && !syncAfterResponse) code += "let _stl\n";
208
+ if (hasCookieSign) code += "let _sg\n";
209
+ if (hasTrace) {
210
+ link(traceHandlers.map((fn) => createTracer(fn)), "tr");
211
+ link(requestId, "rid");
212
+ code += `c.rid??=rid()\n`;
213
+ for (let i = 0; i < traceCount; i++) code += `let rp${i},rpc${i},_hr${i};\n`;
214
+ code += `c.trace??=[`;
215
+ for (let i = 0; i < traceCount; i++) code += (i ? "," : "") + `tr[${i}](c)`;
216
+ code += `]\n`;
217
+ for (let i = 0; i < traceCount; i++) code += `const tr${i}=c.trace[${i}]\n`;
218
+ code += `let _trs\n`;
219
+ }
220
+ let inlineUnsafe = false;
221
+ if ((hasTrace || inference.route) && isDynamicRegex.test(path)) {
222
+ code += `c.route=${JSON.stringify(path)}\n`;
223
+ inlineUnsafe = true;
224
+ }
225
+ const head = code;
226
+ code = "";
227
+ if (hasErrorHook || hasTrace) code += "try{\n";
228
+ const hasHeaders = inference.headers || !!vali?.headers;
229
+ if (inference.query || vali?.query) {
230
+ const parseArgs = getQueryParseArgs((vali?.query)?.schema);
231
+ code += `c.query=pq(c.request.url,c.qi${parseArgs})\n`;
232
+ link(parseQueryFromURL, "pq");
233
+ }
234
+ if (hasHeaders) {
235
+ if (captureHeaderShorthand === void 0 && Capture.isCapturing()) code += `c.headers=c.request.headers.toJSON?.()??Object.fromEntries(c.request.headers)\n`;
236
+ else code += `c.headers=${captureHeaderShorthand ?? hasHeaderShorthand ? "c.request.headers.toJSON()" : "Object.fromEntries(c.request.headers)"}\n`;
237
+ inlineUnsafe = true;
238
+ }
239
+ if (hasBody) {
240
+ const parseLen = Array.isArray(hook?.parse) ? hook.parse.length : 0;
241
+ if (hasTrace) code += beginTrace("parse", parseLen);
242
+ const parseCode = parse(adapter.parse, hook?.parse, vali?.body, hasHeaders, link, buildReport("parse"));
243
+ link(ParseError, "pe");
244
+ code += "try{\n" + parseCode + "}catch(e){throw new pe(e)}\n";
245
+ if (hasTrace) code += endTrace();
246
+ } else if (hasTrace) code += beginTrace("parse", 0) + endTrace();
247
+ if (hook?.transform?.length || hasTrace) {
248
+ const transformLen = hook?.transform?.length ?? 0;
249
+ code += beginTrace("transform", transformLen);
250
+ if (transformLen) {
251
+ link(hook.transform, "tf");
252
+ code += mapTransform(hook.transform, [buildReport("transform")]);
253
+ }
254
+ code += endTrace();
255
+ }
256
+ if (vali?.body) {
257
+ link(vali, "va");
258
+ code += `c.body=${bodyValiIsAsync ? "await " : ""}va.body.From(c.body,'body')\n`;
259
+ }
260
+ if (vali?.headers) {
261
+ link(vali, "va");
262
+ code += `c.headers=${headersValiIsAsync ? "await " : ""}va.headers.From(c.headers,'headers')\n`;
263
+ }
264
+ if (vali?.params) {
265
+ link(vali, "va");
266
+ code += `c.params=${paramsValiIsAsync ? "await " : ""}va.params.From(c.params,'params')\n`;
267
+ }
268
+ if (vali?.query) {
269
+ link(vali, "va");
270
+ code += `c.query=${queryValiIsAsync ? "await " : ""}va.query.From(c.query,'query')\n`;
271
+ }
272
+ if (cookieConfig) {
273
+ link(buildCookieJar, "bcj");
274
+ link(cookieConfig, "cc");
275
+ if (!hasCookieSign && !cookieValidIsAsync) {
276
+ link(parseCookieRawSync, "pcrs");
277
+ code += `let _ck=pcrs(c.request.headers.get('cookie'),cc)\n`;
278
+ } else {
279
+ link(parseCookieRaw, "pcr");
280
+ code += `let _ck=await pcr(c.request.headers.get('cookie'),cc)\n`;
281
+ }
282
+ if (vali?.cookie) {
283
+ link(vali, "va");
284
+ const cookieIsOptional = !!(hook?.cookie)?.["~optional"];
285
+ const validateExpr = `_ck=${cookieValidIsAsync ? "await " : ""}va.cookie.From(_ck,'cookie')\n`;
286
+ if (cookieIsOptional) code += `if(Object.keys(_ck).length){${validateExpr}}\n`;
287
+ else code += validateExpr;
288
+ }
289
+ code += `c.cookie=bcj(c.set,_ck,cc)\n`;
290
+ }
291
+ const hasSet = inference.cookie || inference.set || !!root["~ext"]?.["headers"] || needsCookie || hasAfterResponse || hasErrorHook || hasResponseValidator || hasTrace;
292
+ const res = adapter.response;
293
+ const map = hasSet ? link(res.map, "rm") ?? "rm" : link(res.compact ?? res.map, "rc") ?? "rc";
294
+ if (isPromiseHandler) link(cloneResponse, "cr");
295
+ const handleInstruction = isHandleFunction ? "h(c)" : isStaticResponse ? "h.clone()" : isPromiseHandler ? "h.then(cr)" : "h";
296
+ const mapReturn = hasSet ? `rm(${handleInstruction},c.set,c.request)\n` : `rc(${handleInstruction},c.request)\n`;
297
+ if (hasAfterResponse) link(hook.afterResponse, "ar");
298
+ const drainTraceStream = hasTrace ? `let _ser\nif(_trs){try{for await(const v of _trs){}}catch(_te){_ser=_te}}\n` : "";
299
+ const resolveHandlePostDrain = hasTrace ? (() => {
300
+ let s = "";
301
+ for (let i = 0; i < traceCount; i++) s += `_hr${i}?.resolve(_ser)\n`;
302
+ return s;
303
+ })() : "";
304
+ const setImmediateFn = Capture.isCapturing() ? ";(typeof setImmediate==='function'?setImmediate:(f)=>Promise.resolve().then(f))" : typeof setImmediate === "function" ? "setImmediate" : "Promise.resolve().then";
305
+ const scheduleAfterResponse = hasAfterResponse || hasTrace ? `c._arf=true\n${setImmediateFn}(async()=>{if(_stl)for await(const v of _stl){}\n` + drainTraceStream + resolveHandlePostDrain + beginTrace("afterResponse", hook?.afterResponse?.length ?? 0) + (hasAfterResponse ? mapAfterResponse(hook.afterResponse, [buildReport("afterResponse")]) : "") + endTrace() + `})\n` : "";
306
+ const dedupSchedule = !!scheduleAfterResponse && (hasErrorHook || hasTrace) && !syncAfterResponse && !syncErrorHook;
307
+ const scheduleDecl = dedupSchedule ? `function _sc(){\n${scheduleAfterResponse}}\n` : "";
308
+ const schedule = dedupSchedule ? `_sc()\n` : scheduleAfterResponse;
309
+ const signPrefix = hasCookieSign ? `_sg=scv(c.set.cookie,cc)\nif(_sg)await _sg\n` : "";
310
+ if (hasCookieSign) link(signCookieValues, "scv");
311
+ let factoryHelpers = "";
312
+ if (hasBeforeHandle || hasAfterHandle || hasMapResponse || hasAfterResponse || hasResponseValidator || hasCookieSign || hasTrace) {
313
+ code += `let _r,tmp\n`;
314
+ if (hasBeforeHandle || hasTrace) {
315
+ const bfLen = hook?.beforeHandle?.length ?? 0;
316
+ code += beginTrace("beforeHandle", bfLen);
317
+ if (hasBeforeHandle) {
318
+ link(hook.beforeHandle, "bf");
319
+ const rootDerive = root["~derive"];
320
+ const instanceDerive = instance?.["~derive"];
321
+ const deriveSet = rootDerive && instanceDerive ? { has: (fn) => rootDerive.has(fn) || instanceDerive.has(fn) } : rootDerive ?? instanceDerive;
322
+ code += mapBeforeHandle(hook.beforeHandle, deriveSet, link, buildReport("beforeHandle"));
323
+ }
324
+ code += endTrace();
325
+ }
326
+ if (hasAfterResponse || hasTrace) link(tee, "tee");
327
+ const teeConsumers = (hasAfterResponse ? 1 : 0) + (hasTrace ? 1 : 0);
328
+ const teeCount = teeConsumers + 1;
329
+ const teeBlock = teeConsumers > 0 && !syncAfterResponse ? `if(_r&&(_r[Symbol.iterator]||_r[Symbol.asyncIterator])&&typeof _r.next==='function'){\nconst _s=await tee(_r,${teeCount})\n_r=_s[0]\n` + (hasAfterResponse ? `_stl=_s[1]\n` : "") + (hasTrace ? `_trs=_s[${1 + (hasAfterResponse ? 1 : 0)}]\n` : "") + `}\n` : "";
330
+ if (hasTrace) {
331
+ const handleName = handler?.name && typeof handler.name === "string" ? handler.name : "anonymous";
332
+ code += beginTrace("handle", 1);
333
+ const handleChild = buildReport("handle").resolveChild(handleName);
334
+ code += handleChild.begin;
335
+ if (hasBeforeHandle) code += `if(_r===undefined){\n${callHandler}${teeBlock}}\n`;
336
+ else code += callHandler + teeBlock;
337
+ code += handleChild.end("_r");
338
+ code += `if(_trs){\n`;
339
+ for (let i = 0; i < traceCount; i++) code += `_hr${i}=rp${i};\n`;
340
+ code += `}else{\n`;
341
+ code += endTrace();
342
+ code += `}\n`;
343
+ } else if (hasBeforeHandle) code += `if(_r===undefined){\n${callHandler}${teeBlock}}\n`;
344
+ else code += callHandler + teeBlock;
345
+ if (syncAfterResponse) {
346
+ link(forwardError, "fe");
347
+ factoryHelpers += `function _fin(c,_r){
348
+ if(_r instanceof Error)throw _r
349
+ if(_r&&(_r[Symbol.iterator]||_r[Symbol.asyncIterator])&&typeof _r.next==='function'){
350
+ return tee(_r,${teeCount}).then((_s)=>_fin2(c,_s[0],_s[1]))\n}\nreturn _fin2(c,_r,undefined)\n}\nfunction _fin2(c,_r,_stl){\nc.responseValue=_r\n` + scheduleAfterResponse + `return ${hasSet ? `${map}(_r,c.set,c.request)` : `${map}(_r,c.request)`}\n}\n`;
351
+ code += "if(_r instanceof Promise)return _r.then(fe).then((_v)=>_fin(c,_v))\nreturn _fin(c,_r)\n";
352
+ } else {
353
+ code += `if(_r instanceof Error)throw _r\n`;
354
+ if (!isAsync) {
355
+ link(forwardError, "fe");
356
+ code += `else if(_r instanceof Promise)_r=_r.then(fe)\n`;
357
+ }
358
+ if (hasAfterHandle || hasMapResponse || hasAfterResponse || hasTrace) code += `c.responseValue=_r\n`;
359
+ if (hasAfterHandle || hasTrace) {
360
+ const afLen = hook?.afterHandle?.length ?? 0;
361
+ code += beginTrace("afterHandle", afLen);
362
+ if (hasAfterHandle) {
363
+ link(hook.afterHandle, "af");
364
+ code += mapAfterHandle(hook.afterHandle, buildReport("afterHandle"));
365
+ }
366
+ code += endTrace();
367
+ }
368
+ if (hasMapResponse || hasTrace) {
369
+ const mrLen = hook?.mapResponse?.length ?? 0;
370
+ code += beginTrace("mapResponse", mrLen);
371
+ if (hasMapResponse) {
372
+ link(hook.mapResponse, "mr");
373
+ code += mapMapResponse(hook.mapResponse, buildReport("mapResponse"));
374
+ }
375
+ code += endTrace();
376
+ }
377
+ if (hasResponseValidator) {
378
+ link(vali, "va");
379
+ link(ElysiaStatus, "es");
380
+ const awaitStr = responseValiAsync ? "await " : "";
381
+ code += `if(_r instanceof es){
382
+ const _vr=va.response[_r.code]
383
+ if(_vr)_r.response=${awaitStr}_vr.EncodeFrom(_r.response,'response')\n}else if(!(_r instanceof Response)&&!(_r instanceof ReadableStream)&&typeof _r?.next!=='function'){\nconst _vr=va.response[c.set.status??200]\nif(_vr)_r=${awaitStr}_vr.EncodeFrom(_r,'response')\n}\n`;
384
+ }
385
+ code += schedule;
386
+ code += signPrefix;
387
+ const finalMap = hasSet ? `${map}(_r,c.set,c.request)` : `${map}(_r,c.request)`;
388
+ if (syncErrorHook) code += `if(_r instanceof Promise)return ${finalMap}.catch((_e)=>_ce(_e,c))\n`;
389
+ code += `return ${finalMap}\n`;
390
+ }
391
+ } else if (isHandleFunction) {
392
+ if (!isAsync) link(forwardError, "fe");
393
+ const mapArgs = hasSet ? "c.set,c.request" : "c.request";
394
+ code += (callHandlerSyncOnAsync ? `let _r=h(c)\nif(_r instanceof Promise)_r=await _r\n` : `let _r=${isAsync ? "await " : ""}h(c)\n`) + `if(_r instanceof Error)throw _r\n` + (isAsync ? `return ${map}(_r,${mapArgs})\n` : syncErrorHook ? `if(_r instanceof Promise)return ${map}(_r.then(fe),${mapArgs}).catch((_e)=>_ce(_e,c))\nreturn ${map}(_r,${mapArgs})\n` : `if(_r instanceof Promise)_r=_r.then(fe)\nreturn ${map}(_r,${mapArgs})\n`);
395
+ } else code += `return ${mapReturn}`;
396
+ if (hasErrorHook || hasTrace) {
397
+ let body = "";
398
+ if (hasTrace) {
399
+ for (let i = 0; i < traceCount; i++) body += `rp${i}?.resolve(e);rpc${i}?.(e)\n`;
400
+ body += beginTrace("error", hook?.error?.length ?? 0);
401
+ }
402
+ if (hasErrorHook) {
403
+ link(hook.error, "er");
404
+ link(ElysiaStatus, "es");
405
+ const allowUnsafeDetail = !!root["~config"]?.allowUnsafeValidationDetails;
406
+ if (allowUnsafeDetail) link(ValidationError, "verr");
407
+ body += `c.error=e\n` + (allowUnsafeDetail ? `if(e instanceof verr)e.allowUnsafeValidationDetails=true\n` : ``) + `if(e?.status)c.set.status=e.status
408
+ else if(c.set.status===undefined||c.set.status===200)c.set.status=500
409
+ let _r${hasMapResponse ? ",tmp" : ""}\n` + mapError(hook.error, [
410
+ map,
411
+ link,
412
+ res.map,
413
+ (hasMapResponse ? `c.responseValue=_r\n` + mapMapResponse(hook.mapResponse, void 0) : "") + endTrace() + schedule,
414
+ signPrefix
415
+ ]) + endTrace() + schedule + `if(typeof e?.toResponse==='function'){const _er=e.toResponse();if(_er instanceof Response){${signPrefix}return ${map}(_er,c.set,c.request)}}\nif(e instanceof es){${signPrefix}return ${map}(e,c.set,c.request)}\nif(e?.status){${signPrefix}return ${map}(e?.response??e?.message??'',c.set,c.request)}\nc.set.status=500\n` + signPrefix + `return ${map}(e?.message!=null?e.message:'Internal Server Error',c.set,c.request)\n`;
416
+ } else {
417
+ body += endTrace() + schedule;
418
+ body += `throw e\n`;
419
+ }
420
+ if (syncErrorHook) {
421
+ factoryHelpers += `function _ce(e,c){\n${body}}\n`;
422
+ code += `}catch(e){return _ce(e,c)}\n`;
423
+ } else code += `}catch(e){\n${body}}\n`;
424
+ }
425
+ code += "}";
426
+ code = head + scheduleDecl + code;
427
+ if (factoryHelpers) code = `(function(){\n${factoryHelpers}return ${code}})()`;
428
+ Capture.handler({
429
+ method,
430
+ path,
431
+ alias,
432
+ code
433
+ });
434
+ if (!hasTrace && isHandleFunction && !inlineUnsafe) {
435
+ if (alias === "rc" || !isAsync && !syncErrorHook && alias === "rc,fe") return createInlineHandler(res.compact ?? res.map, handler);
436
+ else if (alias === "rm" || !isAsync && !syncErrorHook && alias === "rm,fe") return createInlineHandlerWithSet(res.map, handler);
437
+ }
438
+ JITProbe.record("handler:new-function");
439
+ return new Function("h", alias, `return ${code}`)(handler, ...params);
440
+ }
441
+
442
+ //#endregion
443
+ export { compileHandlerJit, setCaptureHeaderShorthand };
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils = require('../../utils.js');
3
- const require_error = require('../../error.js');
4
- const require_cookie_utils = require('../../cookie/utils.js');
5
3
  const require_adapter_utils = require('../../adapter/utils.js');
4
+ const require_error = require('../../error.js');
6
5
  const require_parse_query = require('../../parse-query.js');
7
6
  const require_compile_handler_utils = require('./utils.js');
7
+ const require_cookie_utils = require('../../cookie/utils.js');
8
8
  const require_handler_utils = require('../../handler/utils.js');
9
9
 
10
10
  //#region src/compile/handler/params.ts
@@ -15,6 +15,7 @@ const HANDLER_PARAMS = {
15
15
  pa: (c) => c.parse.arrayBuffer,
16
16
  pt: (c) => c.parse.text,
17
17
  pd: (c) => c.parse.default,
18
+ hb: () => require_compile_handler_utils.hasRequestBody,
18
19
  rm: (c) => c.res.map,
19
20
  rc: (c) => c.res.compact ?? c.res.map,
20
21
  rid: () => require_utils.requestId,
@@ -1,9 +1,9 @@
1
1
  import { requestId } from "../../utils.mjs";
2
- import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
3
- import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
4
2
  import { tee } from "../../adapter/utils.mjs";
3
+ import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
5
4
  import { parseQueryFromURL } from "../../parse-query.mjs";
6
- import { cloneResponse } from "./utils.mjs";
5
+ import { cloneResponse, hasRequestBody } from "./utils.mjs";
6
+ import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
7
7
  import { forwardError } from "../../handler/utils.mjs";
8
8
 
9
9
  //#region src/compile/handler/params.ts
@@ -14,6 +14,7 @@ const HANDLER_PARAMS = {
14
14
  pa: (c) => c.parse.arrayBuffer,
15
15
  pt: (c) => c.parse.text,
16
16
  pd: (c) => c.parse.default,
17
+ hb: () => hasRequestBody,
17
18
  rm: (c) => c.res.map,
18
19
  rc: (c) => c.res.compact ?? c.res.map,
19
20
  rid: () => requestId,
@@ -0,0 +1,13 @@
1
+ import { CompiledCookieConfig } from "../../cookie/config.js";
2
+ import { AnyLocalHook, HTTPMethod } from "../../types.js";
3
+ import { AnyElysia } from "../../base.js";
4
+ import { RouteValidator } from "../../validator/route.js";
5
+
6
+ //#region src/compile/handler/reconstruct.d.ts
7
+ declare abstract class Reconstrct {
8
+ static validator(hook: AnyLocalHook, root: AnyElysia, method: HTTPMethod, path: string): RouteValidator<any>;
9
+ static cookie(hook: AnyLocalHook, root: AnyElysia): CompiledCookieConfig;
10
+ static trace(hook: AnyLocalHook): any;
11
+ }
12
+ //#endregion
13
+ export { Reconstrct };
@@ -0,0 +1,29 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_validator_route = require('../../validator/route.js');
3
+ const require_cookie_config = require('../../cookie/config.js');
4
+ const require_trace = require('../../trace.js');
5
+
6
+ //#region src/compile/handler/reconstruct.ts
7
+ var Reconstrct = class {
8
+ static validator(hook, root, method, path) {
9
+ return new require_validator_route.RouteValidator(hook, {
10
+ models: root["~ext"]?.models,
11
+ normalize: root["~config"]?.normalize,
12
+ sanitize: root["~config"]?.sanitize,
13
+ schemas: hook?.schemas,
14
+ aot: {
15
+ method,
16
+ path
17
+ }
18
+ });
19
+ }
20
+ static cookie(hook, root) {
21
+ return require_cookie_config.compileCookieConfig(hook?.cookie, root["~config"]?.cookie);
22
+ }
23
+ static trace(hook) {
24
+ return (hook?.trace)?.map(require_trace.createTracer);
25
+ }
26
+ };
27
+
28
+ //#endregion
29
+ exports.Reconstrct = Reconstrct;
@@ -0,0 +1,28 @@
1
+ import { RouteValidator } from "../../validator/route.mjs";
2
+ import { compileCookieConfig } from "../../cookie/config.mjs";
3
+ import { createTracer } from "../../trace.mjs";
4
+
5
+ //#region src/compile/handler/reconstruct.ts
6
+ var Reconstrct = class {
7
+ static validator(hook, root, method, path) {
8
+ return new RouteValidator(hook, {
9
+ models: root["~ext"]?.models,
10
+ normalize: root["~config"]?.normalize,
11
+ sanitize: root["~config"]?.sanitize,
12
+ schemas: hook?.schemas,
13
+ aot: {
14
+ method,
15
+ path
16
+ }
17
+ });
18
+ }
19
+ static cookie(hook, root) {
20
+ return compileCookieConfig(hook?.cookie, root["~config"]?.cookie);
21
+ }
22
+ static trace(hook) {
23
+ return (hook?.trace)?.map(createTracer);
24
+ }
25
+ };
26
+
27
+ //#endregion
28
+ export { Reconstrct };
@@ -11,6 +11,7 @@ interface TraceReporter {
11
11
  };
12
12
  }
13
13
  declare const cloneResponse: (r: unknown) => unknown;
14
+ declare function hasRequestBody(request: Request): boolean;
14
15
  declare const mapTransform: (event: MaybeArray<TransformHandler<any, any, undefined, "local">>, rest?: [report?: TraceReporter | undefined] | undefined) => string;
15
16
  declare function extractDeriveKeys(fn: Function): string[] | null;
16
17
  declare function mapBeforeHandle(_hooks: AppHook['beforeHandle'] | AppHook['beforeHandle'][0], derive: AnyElysia['~derive'], link: Link, report?: TraceReporter): string;
@@ -26,4 +27,4 @@ declare function getQueryParseChannels(querySchema: any): QueryWalkState | undef
26
27
  declare function getQueryParseArgs(querySchema: any): string;
27
28
  declare const Await: (fn: Function) => "" | "await ";
28
29
  //#endregion
29
- export { Await, TraceReporter, cloneResponse, extractDeriveKeys, getQueryParseArgs, getQueryParseChannels, mapAfterHandle, mapAfterResponse, mapBeforeHandle, mapError, mapMapResponse, mapTransform };
30
+ export { Await, TraceReporter, cloneResponse, extractDeriveKeys, getQueryParseArgs, getQueryParseChannels, hasRequestBody, mapAfterHandle, mapAfterResponse, mapBeforeHandle, mapError, mapMapResponse, mapTransform };
@@ -10,9 +10,14 @@ const noTrace = {
10
10
  end: () => ""
11
11
  };
12
12
  const cloneResponse = (r) => r instanceof Response ? r.clone() : r;
13
+ function hasRequestBody(request) {
14
+ const length = request.headers.get("content-length");
15
+ if (length !== null) return length !== "0";
16
+ return request.body != null;
17
+ }
13
18
  const trace = (report, fn) => report?.resolveChild(childName(fn)) ?? noTrace;
14
19
  const toArray = (v) => Array.isArray(v) ? v : [v];
15
- const mapTransform = map((i, fn, [report]) => {
20
+ const mapTransform = /* @__PURE__ */ map((i, fn, [report]) => {
16
21
  const t = trace(report, fn);
17
22
  return t.begin + `${Await(fn)}tf${at(i)}(c)\n` + t.end();
18
23
  });
@@ -335,11 +340,11 @@ function mapAfterHandle(_hooks, report) {
335
340
  return mapChainHook(toArray(_hooks), "af", report);
336
341
  }
337
342
  const mapMapResponse = (_hooks, report) => mapChainHook(toArray(_hooks), "mr", report);
338
- const mapAfterResponse = map((i, fn, [report]) => {
343
+ const mapAfterResponse = /* @__PURE__ */ map((i, fn, [report]) => {
339
344
  const t = trace(report, fn);
340
345
  return `try{` + t.begin + `${Await(fn)}ar${at(i)}(c)\n` + t.end() + `}catch(_e){` + t.end("_e") + `}\n`;
341
346
  });
342
- const mapError = map((i, fn, [map, link, mapResponse, schedule, sign]) => {
347
+ const mapError = /* @__PURE__ */ map((i, fn, [map, link, mapResponse, schedule, sign]) => {
343
348
  link(mapResponse, "rm");
344
349
  return `_r=${Await(fn)}er${at(i)}(c)\nif(_r!==undefined){\nif(_r instanceof Response)c.set.status=_r.status\nelse if(c.set.status===undefined||c.set.status===200)c.set.status=500\n` + schedule + sign + `return ${map}(_r,c.set,c.request)\n}\n`;
345
350
  });
@@ -434,6 +439,7 @@ exports.cloneResponse = cloneResponse;
434
439
  exports.extractDeriveKeys = extractDeriveKeys;
435
440
  exports.getQueryParseArgs = getQueryParseArgs;
436
441
  exports.getQueryParseChannels = getQueryParseChannels;
442
+ exports.hasRequestBody = hasRequestBody;
437
443
  exports.mapAfterHandle = mapAfterHandle;
438
444
  exports.mapAfterResponse = mapAfterResponse;
439
445
  exports.mapBeforeHandle = mapBeforeHandle;
@@ -9,9 +9,14 @@ const noTrace = {
9
9
  end: () => ""
10
10
  };
11
11
  const cloneResponse = (r) => r instanceof Response ? r.clone() : r;
12
+ function hasRequestBody(request) {
13
+ const length = request.headers.get("content-length");
14
+ if (length !== null) return length !== "0";
15
+ return request.body != null;
16
+ }
12
17
  const trace = (report, fn) => report?.resolveChild(childName(fn)) ?? noTrace;
13
18
  const toArray = (v) => Array.isArray(v) ? v : [v];
14
- const mapTransform = map((i, fn, [report]) => {
19
+ const mapTransform = /* @__PURE__ */ map((i, fn, [report]) => {
15
20
  const t = trace(report, fn);
16
21
  return t.begin + `${Await(fn)}tf${at(i)}(c)\n` + t.end();
17
22
  });
@@ -334,11 +339,11 @@ function mapAfterHandle(_hooks, report) {
334
339
  return mapChainHook(toArray(_hooks), "af", report);
335
340
  }
336
341
  const mapMapResponse = (_hooks, report) => mapChainHook(toArray(_hooks), "mr", report);
337
- const mapAfterResponse = map((i, fn, [report]) => {
342
+ const mapAfterResponse = /* @__PURE__ */ map((i, fn, [report]) => {
338
343
  const t = trace(report, fn);
339
344
  return `try{` + t.begin + `${Await(fn)}ar${at(i)}(c)\n` + t.end() + `}catch(_e){` + t.end("_e") + `}\n`;
340
345
  });
341
- const mapError = map((i, fn, [map, link, mapResponse, schedule, sign]) => {
346
+ const mapError = /* @__PURE__ */ map((i, fn, [map, link, mapResponse, schedule, sign]) => {
342
347
  link(mapResponse, "rm");
343
348
  return `_r=${Await(fn)}er${at(i)}(c)\nif(_r!==undefined){\nif(_r instanceof Response)c.set.status=_r.status\nelse if(c.set.status===undefined||c.set.status===200)c.set.status=500\n` + schedule + sign + `return ${map}(_r,c.set,c.request)\n}\n`;
344
349
  });
@@ -428,4 +433,4 @@ function getQueryParseArgs(querySchema) {
428
433
  const Await = (fn) => isAsyncFunction(fn) ? "await " : "";
429
434
 
430
435
  //#endregion
431
- export { Await, cloneResponse, extractDeriveKeys, getQueryParseArgs, getQueryParseChannels, mapAfterHandle, mapAfterResponse, mapBeforeHandle, mapError, mapMapResponse, mapTransform };
436
+ export { Await, cloneResponse, extractDeriveKeys, getQueryParseArgs, getQueryParseChannels, hasRequestBody, mapAfterHandle, mapAfterResponse, mapBeforeHandle, mapError, mapMapResponse, mapTransform };