elysia 1.3.19 → 1.3.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.
- package/dist/adapter/bun/compose.mjs +17 -13
- package/dist/adapter/bun/handler-native.mjs +30 -24
- package/dist/adapter/bun/handler.mjs +17 -13
- package/dist/adapter/bun/index.mjs +30 -24
- package/dist/adapter/utils.mjs +17 -13
- package/dist/adapter/web-standard/handler.mjs +96 -13
- package/dist/adapter/web-standard/index.mjs +96 -13
- package/dist/bun/index.js +23 -23
- package/dist/bun/index.js.map +7 -7
- package/dist/cjs/adapter/bun/compose.js +17 -13
- package/dist/cjs/adapter/bun/handler-native.js +30 -24
- package/dist/cjs/adapter/bun/handler.js +17 -13
- package/dist/cjs/adapter/bun/index.js +30 -24
- package/dist/cjs/adapter/utils.js +17 -13
- package/dist/cjs/adapter/web-standard/handler.js +96 -13
- package/dist/cjs/adapter/web-standard/index.js +96 -13
- package/dist/cjs/compose.js +84 -67
- package/dist/cjs/index.js +117 -94
- package/dist/compose.mjs +84 -67
- package/dist/index.mjs +117 -94
- package/package.json +1 -1
package/dist/bun/index.js.map
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"'use strict'\n\nvar UTF8_ACCEPT = 12\nvar UTF8_REJECT = 0\nvar UTF8_DATA = [\n // The first part of the table maps bytes to character to a transition.\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,\n 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,\n 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7,\n 10, 9, 9, 9, 11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n\n // The second part of the table maps a state to a new state when adding a\n // transition.\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 12, 0, 0, 0, 0, 24, 36, 48, 60, 72, 84, 96,\n 0, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\n // The third part maps the current transition to a mask that needs to apply\n // to the byte.\n 0x7F, 0x3F, 0x3F, 0x3F, 0x00, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07\n]\n\nfunction decodeURIComponent (uri) {\n var percentPosition = uri.indexOf('%')\n if (percentPosition === -1) return uri\n\n var length = uri.length\n var decoded = ''\n var last = 0\n var codepoint = 0\n var startOfOctets = percentPosition\n var state = UTF8_ACCEPT\n\n while (percentPosition > -1 && percentPosition < length) {\n var high = hexCodeToInt(uri[percentPosition + 1], 4)\n var low = hexCodeToInt(uri[percentPosition + 2], 0)\n var byte = high | low\n var type = UTF8_DATA[byte]\n state = UTF8_DATA[256 + state + type]\n codepoint = (codepoint << 6) | (byte & UTF8_DATA[364 + type])\n\n if (state === UTF8_ACCEPT) {\n decoded += uri.slice(last, startOfOctets)\n\n decoded += (codepoint <= 0xFFFF)\n ? String.fromCharCode(codepoint)\n : String.fromCharCode(\n (0xD7C0 + (codepoint >> 10)),\n (0xDC00 + (codepoint & 0x3FF))\n )\n\n codepoint = 0\n last = percentPosition + 3\n percentPosition = startOfOctets = uri.indexOf('%', last)\n } else if (state === UTF8_REJECT) {\n return null\n } else {\n percentPosition += 3\n if (percentPosition < length && uri.charCodeAt(percentPosition) === 37) continue\n return null\n }\n }\n\n return decoded + uri.slice(last)\n}\n\nvar HEX = {\n '0': 0,\n '1': 1,\n '2': 2,\n '3': 3,\n '4': 4,\n '5': 5,\n '6': 6,\n '7': 7,\n '8': 8,\n '9': 9,\n 'a': 10,\n 'A': 10,\n 'b': 11,\n 'B': 11,\n 'c': 12,\n 'C': 12,\n 'd': 13,\n 'D': 13,\n 'e': 14,\n 'E': 14,\n 'f': 15,\n 'F': 15\n}\n\nfunction hexCodeToInt (c, shift) {\n var i = HEX[c]\n return i === undefined ? 255 : i << shift\n}\n\nmodule.exports = decodeURIComponent\n",
|
|
6
6
|
"\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parse = parse;\nexports.serialize = serialize;\n/**\n * RegExp to match cookie-name in RFC 6265 sec 4.1.1\n * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2\n * which has been replaced by the token definition in RFC 7230 appendix B.\n *\n * cookie-name = token\n * token = 1*tchar\n * tchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" /\n * \"*\" / \"+\" / \"-\" / \".\" / \"^\" / \"_\" /\n * \"`\" / \"|\" / \"~\" / DIGIT / ALPHA\n *\n * Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191\n * Allow same range as cookie value, except `=`, which delimits end of name.\n */\nconst cookieNameRegExp = /^[\\u0021-\\u003A\\u003C\\u003E-\\u007E]+$/;\n/**\n * RegExp to match cookie-value in RFC 6265 sec 4.1.1\n *\n * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )\n * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E\n * ; US-ASCII characters excluding CTLs,\n * ; whitespace DQUOTE, comma, semicolon,\n * ; and backslash\n *\n * Allowing more characters: https://github.com/jshttp/cookie/issues/191\n * Comma, backslash, and DQUOTE are not part of the parsing algorithm.\n */\nconst cookieValueRegExp = /^[\\u0021-\\u003A\\u003C-\\u007E]*$/;\n/**\n * RegExp to match domain-value in RFC 6265 sec 4.1.1\n *\n * domain-value = <subdomain>\n * ; defined in [RFC1034], Section 3.5, as\n * ; enhanced by [RFC1123], Section 2.1\n * <subdomain> = <label> | <subdomain> \".\" <label>\n * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]\n * Labels must be 63 characters or less.\n * 'let-dig' not 'letter' in the first char, per RFC1123\n * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>\n * <let-dig-hyp> = <let-dig> | \"-\"\n * <let-dig> = <letter> | <digit>\n * <letter> = any one of the 52 alphabetic characters A through Z in\n * upper case and a through z in lower case\n * <digit> = any one of the ten digits 0 through 9\n *\n * Keep support for leading dot: https://github.com/jshttp/cookie/issues/173\n *\n * > (Note that a leading %x2E (\".\"), if present, is ignored even though that\n * character is not permitted, but a trailing %x2E (\".\"), if present, will\n * cause the user agent to ignore the attribute.)\n */\nconst domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;\n/**\n * RegExp to match path-value in RFC 6265 sec 4.1.1\n *\n * path-value = <any CHAR except CTLs or \";\">\n * CHAR = %x01-7F\n * ; defined in RFC 5234 appendix B.1\n */\nconst pathValueRegExp = /^[\\u0020-\\u003A\\u003D-\\u007E]*$/;\nconst __toString = Object.prototype.toString;\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () { };\n C.prototype = Object.create(null);\n return C;\n})();\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n */\nfunction parse(str, options) {\n const obj = new NullObject();\n const len = str.length;\n // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.\n if (len < 2)\n return obj;\n const dec = options?.decode || decode;\n let index = 0;\n do {\n const eqIdx = str.indexOf(\"=\", index);\n if (eqIdx === -1)\n break; // No more cookie pairs.\n const colonIdx = str.indexOf(\";\", index);\n const endIdx = colonIdx === -1 ? len : colonIdx;\n if (eqIdx > endIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(\";\", eqIdx - 1) + 1;\n continue;\n }\n const keyStartIdx = startIndex(str, index, eqIdx);\n const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);\n const key = str.slice(keyStartIdx, keyEndIdx);\n // only assign once\n if (obj[key] === undefined) {\n let valStartIdx = startIndex(str, eqIdx + 1, endIdx);\n let valEndIdx = endIndex(str, endIdx, valStartIdx);\n const value = dec(str.slice(valStartIdx, valEndIdx));\n obj[key] = value;\n }\n index = endIdx + 1;\n } while (index < len);\n return obj;\n}\nfunction startIndex(str, index, max) {\n do {\n const code = str.charCodeAt(index);\n if (code !== 0x20 /* */ && code !== 0x09 /* \\t */)\n return index;\n } while (++index < max);\n return max;\n}\nfunction endIndex(str, index, min) {\n while (index > min) {\n const code = str.charCodeAt(--index);\n if (code !== 0x20 /* */ && code !== 0x09 /* \\t */)\n return index + 1;\n }\n return min;\n}\n/**\n * Serialize data into a cookie header.\n *\n * Serialize a name value pair into a cookie string suitable for\n * http headers. An optional options object specifies cookie parameters.\n *\n * serialize('foo', 'bar', { httpOnly: true })\n * => \"foo=bar; httpOnly\"\n */\nfunction serialize(name, val, options) {\n const enc = options?.encode || encodeURIComponent;\n if (!cookieNameRegExp.test(name)) {\n throw new TypeError(`argument name is invalid: ${name}`);\n }\n const value = enc(val);\n if (!cookieValueRegExp.test(value)) {\n throw new TypeError(`argument val is invalid: ${val}`);\n }\n let str = name + \"=\" + value;\n if (!options)\n return str;\n if (options.maxAge !== undefined) {\n if (!Number.isInteger(options.maxAge)) {\n throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);\n }\n str += \"; Max-Age=\" + options.maxAge;\n }\n if (options.domain) {\n if (!domainValueRegExp.test(options.domain)) {\n throw new TypeError(`option domain is invalid: ${options.domain}`);\n }\n str += \"; Domain=\" + options.domain;\n }\n if (options.path) {\n if (!pathValueRegExp.test(options.path)) {\n throw new TypeError(`option path is invalid: ${options.path}`);\n }\n str += \"; Path=\" + options.path;\n }\n if (options.expires) {\n if (!isDate(options.expires) ||\n !Number.isFinite(options.expires.valueOf())) {\n throw new TypeError(`option expires is invalid: ${options.expires}`);\n }\n str += \"; Expires=\" + options.expires.toUTCString();\n }\n if (options.httpOnly) {\n str += \"; HttpOnly\";\n }\n if (options.secure) {\n str += \"; Secure\";\n }\n if (options.partitioned) {\n str += \"; Partitioned\";\n }\n if (options.priority) {\n const priority = typeof options.priority === \"string\"\n ? options.priority.toLowerCase()\n : undefined;\n switch (priority) {\n case \"low\":\n str += \"; Priority=Low\";\n break;\n case \"medium\":\n str += \"; Priority=Medium\";\n break;\n case \"high\":\n str += \"; Priority=High\";\n break;\n default:\n throw new TypeError(`option priority is invalid: ${options.priority}`);\n }\n }\n if (options.sameSite) {\n const sameSite = typeof options.sameSite === \"string\"\n ? options.sameSite.toLowerCase()\n : options.sameSite;\n switch (sameSite) {\n case true:\n case \"strict\":\n str += \"; SameSite=Strict\";\n break;\n case \"lax\":\n str += \"; SameSite=Lax\";\n break;\n case \"none\":\n str += \"; SameSite=None\";\n break;\n default:\n throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);\n }\n }\n return str;\n}\n/**\n * URL-decode string value. Optimized to skip native call when no %.\n */\nfunction decode(str) {\n if (str.indexOf(\"%\") === -1)\n return str;\n try {\n return decodeURIComponent(str);\n }\n catch (e) {\n return str;\n }\n}\n/**\n * Determine if value is a Date.\n */\nfunction isDate(val) {\n return __toString.call(val) === \"[object Date]\";\n}\n//# sourceMappingURL=index.js.map",
|
|
7
7
|
"// @bun\nvar Y=(v,b)=>{let A=b?.length?{}:null;if(A)for(let Q of b)A[Q.part.charCodeAt(0)]=Q;return{part:v,store:null,inert:A,params:null,wildcardStore:null}},k=(v,b)=>({...v,part:b}),T=(v)=>({name:v,store:null,inert:null});class _{config;root={};history=[];deferred=[];constructor(v={}){this.config=v;if(v.lazy)this.find=this.lazyFind;if(v.onParam&&!Array.isArray(v.onParam))this.config.onParam=[this.config.onParam]}static regex={static:/:.+?(?=\\/|$)/,params:/:.+?(?=\\/|$)/g,optionalParams:/(\\/:\\w+\\?)/g};lazyFind=(v,b)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(v,b)};build(){if(!this.config.lazy)return;for(let[v,b,A]of this.deferred)this.add(v,b,A,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(v,b)=>{let A=this.root[v];if(!A)return null;return $(b,b.length,A,0,this.config.onParam)}}add(v,b,A,{ignoreError:Q=!1,ignoreHistory:O=!1,lazy:V=this.config.lazy}={}){if(V)return this.find=this.lazyFind,this.deferred.push([v,b,A]),A;if(typeof b!==\"string\")throw new TypeError(\"Route path must be a string\");if(b===\"\")b=\"/\";else if(b[0]!==\"/\")b=`/${b}`;let X=b[b.length-1]===\"*\",J=b.match(_.regex.optionalParams);if(J){let F=b.replaceAll(\"?\",\"\");this.add(v,F,A,{ignoreError:Q,ignoreHistory:O,lazy:V});for(let B=0;B<J.length;B++){let D=b.replace(J[B],\"\");this.add(v,D,A,{ignoreError:!0,ignoreHistory:O,lazy:V})}return A}if(J)b=b.replaceAll(\"?\",\"\");if(this.history.find(([F,B,D])=>F===v&&B===b))return A;if(X||J&&b.charCodeAt(b.length-1)===63)b=b.slice(0,-1);if(!O)this.history.push([v,b,A]);let K=b.split(_.regex.static),G=b.match(_.regex.params)||[];if(K[K.length-1]===\"\")K.pop();let q;if(!this.root[v])q=this.root[v]=Y(\"/\");else q=this.root[v];let U=0;for(let F=0;F<K.length;++F){let B=K[F];if(F>0){let D=G[U++].slice(1);if(q.params===null)q.params=T(D);else if(q.params.name!==D)if(Q)return A;else throw new Error(`Cannot create route \"${b}\" with parameter \"${D}\" because a route already exists with a different parameter name (\"${q.params.name}\") in the same location`);let S=q.params;if(S.inert===null){q=S.inert=Y(B);continue}q=S.inert}for(let D=0;;){if(D===B.length){if(D<q.part.length){let S=k(q,q.part.slice(D));Object.assign(q,Y(B,[S]))}break}if(D===q.part.length){if(q.inert===null)q.inert={};let S=q.inert[B.charCodeAt(D)];if(S){q=S,B=B.slice(D),D=0;continue}let Z=Y(B.slice(D));q.inert[B.charCodeAt(D)]=Z,q=Z;break}if(B[D]!==q.part[D]){let S=k(q,q.part.slice(D)),Z=Y(B.slice(D));Object.assign(q,Y(q.part.slice(0,D),[S,Z])),q=Z;break}++D}}if(U<G.length){let B=G[U].slice(1);if(q.params===null)q.params=T(B);else if(q.params.name!==B)if(Q)return A;else throw new Error(`Cannot create route \"${b}\" with parameter \"${B}\" because a route already exists with a different parameter name (\"${q.params.name}\") in the same location`);if(q.params.store===null)q.params.store=A;return q.params.store}if(X){if(q.wildcardStore===null)q.wildcardStore=A;return q.wildcardStore}if(q.store===null)q.store=A;return q.store}find(v,b){let A=this.root[v];if(!A)return null;return $(b,b.length,A,0,this.config.onParam)}}var $=(v,b,A,Q,O)=>{let V=A.part,X=V.length,J=Q+X;if(X>1){if(J>b)return null;if(X<15){for(let K=1,G=Q+1;K<X;++K,++G)if(V.charCodeAt(K)!==v.charCodeAt(G))return null}else if(v.slice(Q,J)!==V)return null}if(J===b){if(A.store!==null)return{store:A.store,params:{}};if(A.wildcardStore!==null)return{store:A.wildcardStore,params:{\"*\":\"\"}};return null}if(A.inert!==null){let K=A.inert[v.charCodeAt(J)];if(K!==void 0){let G=$(v,b,K,J,O);if(G!==null)return G}}if(A.params!==null){let{store:K,name:G,inert:q}=A.params,U=v.indexOf(\"/\",J);if(U!==J){if(U===-1||U>=b){if(K!==null){let F={};if(F[G]=v.substring(J,b),O)for(let B=0;B<O.length;B++){let D=O[B](F[G],G);if(D!==void 0)F[G]=D}return{store:K,params:F}}}else if(q!==null){let F=$(v,b,q,U,O);if(F!==null){if(F.params[G]=v.substring(J,U),O)for(let B=0;B<O.length;B++){let D=O[B](F.params[G],G);if(D!==void 0)F.params[G]=D}return F}}}}if(A.wildcardStore!==null)return{store:A.wildcardStore,params:{\"*\":v.substring(J,b)}};return null},w=_;export{w as default,_ as Memoirist};\n\n//# debugId=7CB9F845001CCC1464756E2164756E21\n",
|
|
8
|
-
"import { Memoirist } from 'memoirist'\nimport {\n\tKind,\n\ttype TObject,\n\ttype Static,\n\ttype TSchema,\n\ttype TModule,\n\ttype TRef,\n\ttype TProperties\n} from '@sinclair/typebox'\n\nimport fastDecodeURIComponent from 'fast-decode-uri-component'\nimport type { Context, PreContext } from './context'\n\nimport { t } from './type-system'\nimport {\n\tclearSucroseCache,\n\tmergeInference,\n\tsucrose,\n\ttype Sucrose\n} from './sucrose'\n\nimport type { WSLocalHook } from './ws/types'\n\nimport { BunAdapter } from './adapter/bun/index'\nimport { WebStandardAdapter } from './adapter/web-standard/index'\nimport type { ElysiaAdapter } from './adapter/types'\n\nimport { env } from './universal/env'\nimport type { ListenCallback, Serve, Server } from './universal/server'\n\nimport {\n\tcloneInference,\n\tdeduplicateChecksum,\n\tfnToContainer,\n\tgetLoosePath,\n\tlocalHookToLifeCycleStore,\n\tmergeDeep,\n\tmergeSchemaValidator,\n\tPromiseGroup,\n\tpromoteEvent,\n\tisNotEmpty,\n\tencodePath,\n\tlifeCycleToArray,\n\tsupportPerMethodInlineHandler,\n\tredirect\n} from './utils'\n\nimport {\n\tcoercePrimitiveRoot,\n\tstringToStructureCoercions,\n\tgetSchemaValidator,\n\tgetResponseSchemaValidator,\n\tgetCookieValidator,\n\tElysiaTypeCheck\n} from './schema'\nimport {\n\tcomposeHandler,\n\tcomposeGeneralHandler,\n\tcomposeErrorHandler\n} from './compose'\n\nimport { createTracer } from './trace'\n\nimport {\n\tmergeHook,\n\tchecksum,\n\tmergeLifeCycle,\n\tfilterGlobalHook,\n\tasHookType,\n\ttraceBackMacro,\n\treplaceUrlPath,\n\tcreateMacroManager\n} from './utils'\n\nimport {\n\tcreateDynamicErrorHandler,\n\tcreateDynamicHandler,\n\ttype DynamicHandler\n} from './dynamic-handle'\n\nimport {\n\tERROR_CODE,\n\tValidationError,\n\ttype ParseError,\n\ttype NotFoundError,\n\ttype InternalServerError,\n\tElysiaCustomStatusResponse,\n\tstatus\n} from './error'\n\nimport type { TraceHandler } from './trace'\n\nimport type {\n\tElysiaConfig,\n\tSingletonBase,\n\tDefinitionBase,\n\tHandler,\n\tComposedHandler,\n\tInputSchema,\n\tLocalHook,\n\tAnyLocalHook,\n\tMergeSchema,\n\tRouteSchema,\n\tUnwrapRoute,\n\tInternalRoute,\n\tHTTPMethod,\n\tSchemaValidator,\n\tPreHandler,\n\tBodyHandler,\n\tOptionalHandler,\n\tErrorHandler,\n\tLifeCycleStore,\n\tMaybePromise,\n\tPrettify,\n\tPrettify2,\n\tAddPrefix,\n\tAddSuffix,\n\tAddPrefixCapitalize,\n\tAddSuffixCapitalize,\n\tMaybeArray,\n\tGracefulHandler,\n\tMapResponse,\n\tChecksum,\n\tMacroManager,\n\tMacroToProperty,\n\tTransformHandler,\n\tMetadataBase,\n\tRouteBase,\n\tCreateEden,\n\tComposeElysiaResponse,\n\tInlineHandler,\n\tHookContainer,\n\tLifeCycleType,\n\tMacroQueue,\n\tEphemeralType,\n\tExcludeElysiaResponse,\n\tModelValidator,\n\tBaseMacroFn,\n\tContextAppendType,\n\tReconcile,\n\tAfterResponseHandler,\n\tHigherOrderFunction,\n\tResolvePath,\n\tJoinPath,\n\tValidatorLayer,\n\tMergeElysiaInstances,\n\tHookMacroFn,\n\tResolveHandler,\n\tResolveResolutions,\n\tUnwrapTypeModule,\n\tMacroToContext,\n\tStandaloneValidator,\n\tGuardSchemaType,\n\tOr,\n\tPrettifySchema,\n\tMergeStandaloneSchema,\n\tIsNever,\n\tDocumentDecoration,\n\tAfterHandler\n} from './types'\n\nexport type AnyElysia = Elysia<any, any, any, any, any, any, any>\n\n/**\n * ### Elysia Server\n * Main instance to create web server using Elysia\n *\n * ---\n * @example\n * ```typescript\n * import { Elysia } from 'elysia'\n *\n * new Elysia()\n * .get(\"/\", () => \"Hello\")\n * .listen(3000)\n * ```\n */\nexport default class Elysia<\n\tconst in out BasePath extends string = '',\n\tconst in out Singleton extends SingletonBase = {\n\t\tdecorator: {}\n\t\tstore: {}\n\t\tderive: {}\n\t\tresolve: {}\n\t},\n\tconst in out Definitions extends DefinitionBase = {\n\t\ttypebox: {}\n\t\terror: {}\n\t},\n\tconst in out Metadata extends MetadataBase = {\n\t\tschema: {}\n\t\tstandaloneSchema: {}\n\t\tmacro: {}\n\t\tmacroFn: {}\n\t\tparser: {}\n\t},\n\tconst out Routes extends RouteBase = {},\n\t// ? scoped\n\tconst in out Ephemeral extends EphemeralType = {\n\t\tderive: {}\n\t\tresolve: {}\n\t\tschema: {}\n\t\tstandaloneSchema: {}\n\t},\n\t// ? local\n\tconst in out Volatile extends EphemeralType = {\n\t\tderive: {}\n\t\tresolve: {}\n\t\tschema: {}\n\t\tstandaloneSchema: {}\n\t}\n> {\n\tconfig: ElysiaConfig<BasePath>\n\n\tserver: Server | null = null\n\tprivate dependencies: { [key in string]: Checksum[] } = {}\n\n\t'~Prefix' = '' as BasePath\n\t'~Singleton' = null as unknown as Singleton\n\t'~Definitions' = null as unknown as Definitions\n\t'~Metadata' = null as unknown as Metadata\n\t'~Ephemeral' = null as unknown as Ephemeral\n\t'~Volatile' = null as unknown as Volatile\n\t'~Routes' = null as unknown as Routes\n\n\tprotected singleton = {\n\t\tdecorator: {},\n\t\tstore: {},\n\t\tderive: {},\n\t\tresolve: {}\n\t} as SingletonBase\n\n\tget store(): Singleton['store'] {\n\t\treturn this.singleton.store\n\t}\n\n\tget decorator(): Singleton['decorator'] {\n\t\treturn this.singleton.decorator\n\t}\n\n\tprotected definitions = {\n\t\ttypebox: t.Module({}),\n\t\ttype: {} as Record<string, TSchema>,\n\t\terror: {} as Record<string, Error>\n\t}\n\n\tprotected extender = {\n\t\tmacros: <MacroQueue[]>[],\n\t\thigherOrderFunctions: <HookContainer<HigherOrderFunction>[]>[]\n\t}\n\n\tprotected validator: ValidatorLayer = {\n\t\tglobal: null,\n\t\tscoped: null,\n\t\tlocal: null,\n\t\tgetCandidate() {\n\t\t\tif (!this.global && !this.scoped && !this.local)\n\t\t\t\treturn {\n\t\t\t\t\tbody: undefined,\n\t\t\t\t\theaders: undefined,\n\t\t\t\t\tparams: undefined,\n\t\t\t\t\tquery: undefined,\n\t\t\t\t\tcookie: undefined,\n\t\t\t\t\tresponse: undefined\n\t\t\t\t}\n\n\t\t\treturn mergeSchemaValidator(\n\t\t\t\tmergeSchemaValidator(this.global, this.scoped),\n\t\t\t\tthis.local\n\t\t\t)\n\t\t}\n\t}\n\n\tprotected standaloneValidator: StandaloneValidator = {\n\t\tglobal: null,\n\t\tscoped: null,\n\t\tlocal: null\n\t}\n\n\tevent: Partial<LifeCycleStore> = {}\n\n\tprotected telemetry:\n\t\t| undefined\n\t\t| {\n\t\t\t\tstack: string | undefined\n\t\t }\n\n\trouter = {\n\t\t'~http': undefined as\n\t\t\t| Memoirist<{\n\t\t\t\t\tcompile: Function\n\t\t\t\t\thandler?: ComposedHandler\n\t\t\t }>\n\t\t\t| undefined,\n\t\tget http() {\n\t\t\tif (!this['~http'])\n\t\t\t\tthis['~http'] = new Memoirist({\n\t\t\t\t\tlazy: true,\n\t\t\t\t\tonParam: fastDecodeURIComponent\n\t\t\t\t})\n\n\t\t\treturn this['~http']\n\t\t},\n\t\t'~dynamic': undefined as Memoirist<DynamicHandler> | undefined,\n\t\t// Use in non-AOT mode\n\t\tget dynamic() {\n\t\t\tif (!this['~dynamic'])\n\t\t\t\tthis['~dynamic'] = new Memoirist({\n\t\t\t\t\tonParam: fastDecodeURIComponent\n\t\t\t\t})\n\n\t\t\treturn this['~dynamic']\n\t\t},\n\t\t// Static Router\n\t\tstatic: {} as { [path in string]: { [method in string]: number } },\n\t\t// Native Static Response\n\t\tresponse: {} as {\n\t\t\t[path: string]:\n\t\t\t\t| MaybePromise<Response | undefined>\n\t\t\t\t| { [method: string]: MaybePromise<Response | undefined> }\n\t\t},\n\t\thistory: [] as InternalRoute[]\n\t}\n\n\tprotected routeTree: Record<string, number> = {}\n\n\tget routes(): InternalRoute[] {\n\t\treturn this.router.history\n\t}\n\n\tprotected getGlobalRoutes(): InternalRoute[] {\n\t\treturn this.router.history\n\t}\n\n\tprotected getGlobalDefinitions() {\n\t\treturn this.definitions\n\t}\n\n\tprotected inference: Sucrose.Inference = {\n\t\tbody: false,\n\t\tcookie: false,\n\t\theaders: false,\n\t\tquery: false,\n\t\tset: false,\n\t\tserver: false,\n\t\tpath: false,\n\t\troute: false,\n\t\turl: false\n\t}\n\n\tprivate getServer() {\n\t\treturn this.server\n\t}\n\n\tprivate getParent(): Elysia | null {\n\t\treturn null\n\t}\n\n\t'~parser': { [K in string]: BodyHandler<any, any> } = {}\n\n\tprivate _promisedModules: PromiseGroup | undefined\n\tprivate get promisedModules() {\n\t\tif (!this._promisedModules)\n\t\t\tthis._promisedModules = new PromiseGroup(console.error, () => {\n\t\t\t\t// this.compile()\n\t\t\t})\n\n\t\treturn this._promisedModules\n\t}\n\n\tconstructor(config: ElysiaConfig<BasePath> = {}) {\n\t\tif (config.tags) {\n\t\t\tif (!config.detail)\n\t\t\t\tconfig.detail = {\n\t\t\t\t\ttags: config.tags\n\t\t\t\t}\n\t\t\telse config.detail.tags = config.tags\n\t\t}\n\n\t\tthis.config = {\n\t\t\taot: env.ELYSIA_AOT !== 'false',\n\t\t\tnativeStaticResponse: true,\n\t\t\tsystemRouter: true,\n\t\t\tencodeSchema: true,\n\t\t\tnormalize: true,\n\t\t\t...config,\n\t\t\tprefix: config.prefix\n\t\t\t\t? config.prefix.charCodeAt(0) === 47\n\t\t\t\t\t? config.prefix\n\t\t\t\t\t: `/${config.prefix}`\n\t\t\t\t: (undefined as any),\n\t\t\tcookie: {\n\t\t\t\tpath: '/',\n\t\t\t\t...config?.cookie\n\t\t\t},\n\t\t\texperimental: config?.experimental ?? {},\n\t\t\tseed: config?.seed === undefined ? '' : config?.seed\n\t\t}\n\n\t\tthis['~adapter'] =\n\t\t\tconfig.adapter ??\n\t\t\t(typeof Bun !== 'undefined' ? BunAdapter : WebStandardAdapter)\n\n\t\tif (config?.analytic && (config?.name || config?.seed !== undefined))\n\t\t\tthis.telemetry = {\n\t\t\t\tstack: new Error().stack\n\t\t\t}\n\t}\n\n\t'~adapter': ElysiaAdapter\n\n\tenv(model: TObject<any>, _env = env) {\n\t\tconst validator = getSchemaValidator(model, {\n\t\t\tmodules: this.definitions.typebox,\n\t\t\tdynamic: true,\n\t\t\tadditionalProperties: true,\n\t\t\tcoerce: true,\n\t\t\tsanitize: () => this.config.sanitize\n\t\t})\n\n\t\tif (validator.Check(_env) === false) {\n\t\t\tconst error = new ValidationError('env', model, _env)\n\n\t\t\tthrow new Error(error.all.map((x) => x.summary).join('\\n'))\n\t\t}\n\n\t\treturn this\n\t}\n\n\t/**\n\t * @private DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n\t * @version 1.1.0\n\t *\n\t * ! Do not use unless you know exactly what you are doing\n\t * ? Add Higher order function to Elysia.fetch\n\t */\n\twrap(fn: HigherOrderFunction) {\n\t\tthis.extender.higherOrderFunctions.push({\n\t\t\tchecksum: checksum(\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tname: this.config.name,\n\t\t\t\t\tseed: this.config.seed,\n\t\t\t\t\tcontent: fn.toString()\n\t\t\t\t})\n\t\t\t),\n\t\t\tfn\n\t\t})\n\n\t\treturn this\n\t}\n\n\tprivate applyMacro(localHook: AnyLocalHook) {\n\t\tif (this.extender.macros.length) {\n\t\t\tconst manage = createMacroManager({\n\t\t\t\tglobalHook: this.event,\n\t\t\t\tlocalHook\n\t\t\t})\n\n\t\t\tconst manager: MacroManager = {\n\t\t\t\tevents: {\n\t\t\t\t\tglobal: this.event,\n\t\t\t\t\tlocal: localHook\n\t\t\t\t},\n\t\t\t\tget onParse() {\n\t\t\t\t\treturn manage('parse') as any\n\t\t\t\t},\n\t\t\t\tget onTransform() {\n\t\t\t\t\treturn manage('transform') as any\n\t\t\t\t},\n\t\t\t\tget onBeforeHandle() {\n\t\t\t\t\treturn manage('beforeHandle') as any\n\t\t\t\t},\n\t\t\t\tget onAfterHandle() {\n\t\t\t\t\treturn manage('afterHandle') as any\n\t\t\t\t},\n\t\t\t\tget mapResponse() {\n\t\t\t\t\treturn manage('mapResponse') as any\n\t\t\t\t},\n\t\t\t\tget onAfterResponse() {\n\t\t\t\t\treturn manage('afterResponse') as any\n\t\t\t\t},\n\t\t\t\tget onError() {\n\t\t\t\t\treturn manage('error') as any\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const macro of this.extender.macros)\n\t\t\t\ttraceBackMacro(macro.fn(manager), localHook, manage)\n\t\t}\n\t}\n\n\tget models(): {\n\t\t[K in keyof Definitions['typebox']]: ModelValidator<\n\t\t\tDefinitions['typebox'][K]\n\t\t>\n\t} & {\n\t\tmodules: TModule<Definitions['typebox']>\n\t} {\n\t\tconst models: Record<string, ElysiaTypeCheck<TSchema>> = {}\n\n\t\tfor (const name of Object.keys(this.definitions.type))\n\t\t\tmodels[name] = getSchemaValidator(\n\t\t\t\tthis.definitions.typebox.Import(name as never)\n\t\t\t)\n\n\t\t// @ts-expect-error\n\t\tmodels.modules = this.definitions.typebox\n\n\t\treturn models as any\n\t}\n\n\tprivate add(\n\t\tmethod: HTTPMethod,\n\t\tpath: string,\n\t\thandle: Handler<any, any, any> | any,\n\t\tlocalHook?: AnyLocalHook,\n\t\toptions?: {\n\t\t\tallowMeta?: boolean\n\t\t\tskipPrefix?: boolean\n\t\t},\n\t\tstandaloneValidators?: InputSchema<string>[]\n\t) {\n\t\tconst skipPrefix = options?.skipPrefix ?? false\n\t\tconst allowMeta = options?.allowMeta ?? false\n\n\t\tlocalHook ??= {}\n\n\t\tif (standaloneValidators === undefined) {\n\t\t\tstandaloneValidators = []\n\n\t\t\tif (this.standaloneValidator.local)\n\t\t\t\tstandaloneValidators = standaloneValidators.concat(\n\t\t\t\t\tthis.standaloneValidator.local\n\t\t\t\t)\n\n\t\t\tif (this.standaloneValidator.scoped)\n\t\t\t\tstandaloneValidators = standaloneValidators.concat(\n\t\t\t\t\tthis.standaloneValidator.scoped\n\t\t\t\t)\n\n\t\t\tif (this.standaloneValidator.global)\n\t\t\t\tstandaloneValidators = standaloneValidators.concat(\n\t\t\t\t\tthis.standaloneValidator.global\n\t\t\t\t)\n\t\t}\n\n\t\tif (path !== '' && path.charCodeAt(0) !== 47) path = '/' + path\n\t\tif (this.config.prefix && !skipPrefix) path = this.config.prefix + path\n\n\t\tif (localHook?.type)\n\t\t\tswitch (localHook.type) {\n\t\t\t\tcase 'text':\n\t\t\t\t\tlocalHook.type = 'text/plain'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'json':\n\t\t\t\t\tlocalHook.type = 'application/json'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'formdata':\n\t\t\t\t\tlocalHook.type = 'multipart/form-data'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'urlencoded':\n\t\t\t\t\tlocalHook.type = 'application/x-www-form-urlencoded'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'arrayBuffer':\n\t\t\t\t\tlocalHook.type = 'application/octet-stream'\n\t\t\t\t\tbreak\n\n\t\t\t\tdefault:\n\t\t\t\t\tbreak\n\t\t\t}\n\n\t\tconst instanceValidator = this.validator.getCandidate()\n\n\t\tconst cloned = {\n\t\t\tbody: localHook?.body ?? (instanceValidator?.body as any),\n\t\t\theaders: localHook?.headers ?? (instanceValidator?.headers as any),\n\t\t\tparams: localHook?.params ?? (instanceValidator?.params as any),\n\t\t\tquery: localHook?.query ?? (instanceValidator?.query as any),\n\t\t\tcookie: localHook?.cookie ?? (instanceValidator?.cookie as any),\n\t\t\tresponse:\n\t\t\t\tlocalHook?.response ?? (instanceValidator?.response as any)\n\t\t}\n\n\t\tconst shouldPrecompile =\n\t\t\tthis.config.precompile === true ||\n\t\t\t(typeof this.config.precompile === 'object' &&\n\t\t\t\tthis.config.precompile.compose === true)\n\n\t\tconst createValidator = () => {\n\t\t\tconst models = this.definitions.type\n\t\t\tconst dynamic = !this.config.aot\n\n\t\t\tconst normalize = this.config.normalize\n\t\t\tconst modules = this.definitions.typebox\n\n\t\t\tconst sanitize = () => this.config.sanitize\n\n\t\t\tconst cookieValidator = () => {\n\t\t\t\tif (cloned.cookie || standaloneValidators.find((x) => x.cookie))\n\t\t\t\t\treturn getCookieValidator({\n\t\t\t\t\t\tmodules,\n\t\t\t\t\t\tvalidator: cloned.cookie,\n\t\t\t\t\t\tdefaultConfig: this.config.cookie,\n\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\tconfig: cloned.cookie?.config ?? {},\n\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\tmodels,\n\t\t\t\t\t\tvalidators: standaloneValidators.map((x) => x.cookie),\n\t\t\t\t\t\tsanitize\n\t\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn shouldPrecompile\n\t\t\t\t? {\n\t\t\t\t\t\tbody: getSchemaValidator(cloned.body, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\tadditionalCoerce: coercePrimitiveRoot(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map((x) => x.body),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\theaders: getSchemaValidator(cloned.headers, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.headers\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tparams: getSchemaValidator(cloned.params, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.params\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tquery: getSchemaValidator(cloned.query, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.query\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tcookie: cookieValidator(),\n\t\t\t\t\t\tresponse: getResponseSchemaValidator(cloned.response, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.response\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t: ({\n\t\t\t\t\t\tcreateBody() {\n\t\t\t\t\t\t\tif (this.body) return this.body\n\n\t\t\t\t\t\t\treturn (this.body = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.body,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tadditionalCoerce: coercePrimitiveRoot(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.body\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateHeaders() {\n\t\t\t\t\t\t\tif (this.headers) return this.headers\n\n\t\t\t\t\t\t\treturn (this.headers = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.headers,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tadditionalProperties: !normalize,\n\t\t\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\t\t\tadditionalCoerce:\n\t\t\t\t\t\t\t\t\t\tstringToStructureCoercions(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.headers\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateParams() {\n\t\t\t\t\t\t\tif (this.params) return this.params\n\n\t\t\t\t\t\t\treturn (this.params = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.params,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\t\t\tadditionalCoerce:\n\t\t\t\t\t\t\t\t\t\tstringToStructureCoercions(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.params\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateQuery() {\n\t\t\t\t\t\t\tif (this.query) return this.query\n\n\t\t\t\t\t\t\treturn (this.query = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.query,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\t\t\tadditionalCoerce:\n\t\t\t\t\t\t\t\t\t\tstringToStructureCoercions(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.query\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateCookie() {\n\t\t\t\t\t\t\tif (this.cookie) return this.cookie\n\n\t\t\t\t\t\t\treturn (this.cookie = cookieValidator())\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateResponse() {\n\t\t\t\t\t\t\tif (this.response) return this.response\n\n\t\t\t\t\t\t\treturn (this.response = getResponseSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.response,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.response\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t}\n\t\t\t\t\t} as any)\n\t\t}\n\n\t\tif (\n\t\t\tinstanceValidator.body ||\n\t\t\tinstanceValidator.cookie ||\n\t\t\tinstanceValidator.headers ||\n\t\t\tinstanceValidator.params ||\n\t\t\tinstanceValidator.query ||\n\t\t\tinstanceValidator.response\n\t\t)\n\t\t\tlocalHook = mergeHook(localHook, instanceValidator)\n\n\t\tif (localHook.tags) {\n\t\t\tif (!localHook.detail)\n\t\t\t\tlocalHook.detail = {\n\t\t\t\t\ttags: localHook.tags\n\t\t\t\t}\n\t\t\telse localHook.detail.tags = localHook.tags\n\t\t}\n\n\t\tif (isNotEmpty(this.config.detail))\n\t\t\tlocalHook.detail = mergeDeep(\n\t\t\t\tObject.assign({}, this.config.detail!),\n\t\t\t\tlocalHook.detail\n\t\t\t)\n\n\t\tthis.applyMacro(localHook)\n\n\t\tconst hooks = isNotEmpty(this.event)\n\t\t\t? mergeHook(this.event, localHookToLifeCycleStore(localHook))\n\t\t\t: lifeCycleToArray(localHookToLifeCycleStore(localHook))\n\n\t\tif (this.config.aot === false) {\n\t\t\tconst validator = createValidator()\n\n\t\t\tthis.router.dynamic.add(method, path, {\n\t\t\t\tvalidator,\n\t\t\t\thooks,\n\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\thandle,\n\t\t\t\troute: path\n\t\t\t})\n\n\t\t\tconst encoded = encodePath(path, { dynamic: true })\n\t\t\tif (path !== encoded) {\n\t\t\t\tthis.router.dynamic.add(method, encoded, {\n\t\t\t\t\tvalidator,\n\t\t\t\t\thooks,\n\t\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\t\thandle,\n\t\t\t\t\troute: path\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (this.config.strictPath === false) {\n\t\t\t\tconst loosePath = getLoosePath(path)\n\t\t\t\tthis.router.dynamic.add(method, loosePath, {\n\t\t\t\t\tvalidator,\n\t\t\t\t\thooks,\n\t\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\t\thandle,\n\t\t\t\t\troute: path\n\t\t\t\t})\n\n\t\t\t\tconst encoded = encodePath(loosePath)\n\t\t\t\tif (loosePath !== encoded)\n\t\t\t\t\tthis.router.dynamic.add(method, loosePath, {\n\t\t\t\t\t\tvalidator,\n\t\t\t\t\t\thooks,\n\t\t\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t\troute: path\n\t\t\t\t\t})\n\t\t\t}\n\n\t\t\tthis.router.history.push({\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tcomposed: null,\n\t\t\t\thandler: handle,\n\t\t\t\tcompile: undefined as any,\n\t\t\t\thooks,\n\t\t\t\tstandaloneValidators\n\t\t\t})\n\n\t\t\treturn\n\t\t}\n\n\t\tconst adapter = this['~adapter'].handler\n\n\t\tconst nativeStaticHandler =\n\t\t\ttypeof handle !== 'function'\n\t\t\t\t? () => {\n\t\t\t\t\t\tconst context: PreContext = {\n\t\t\t\t\t\t\tredirect,\n\t\t\t\t\t\t\trequest: this['~adapter'].isWebStandard\n\t\t\t\t\t\t\t\t? new Request(`http://e.ly${path}`, {\n\t\t\t\t\t\t\t\t\t\tmethod\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: (undefined as any as Request),\n\t\t\t\t\t\t\tserver: null,\n\t\t\t\t\t\t\tset: {\n\t\t\t\t\t\t\t\theaders: Object.assign({}, this.setHeaders)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\terror: status,\n\t\t\t\t\t\t\tstore: this.store\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tthis.event.request?.map((x) => {\n\t\t\t\t\t\t\t\tif (typeof x.fn === 'function')\n\t\t\t\t\t\t\t\t\treturn x.fn(context)\n\n\t\t\t\t\t\t\t\t// @ts-ignore just in case\n\t\t\t\t\t\t\t\tif (typeof x === 'function') return x(context)\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tlet res\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcontext.error = error\n\n\t\t\t\t\t\t\tthis.event.error?.some((x) => {\n\t\t\t\t\t\t\t\tif (typeof x.fn === 'function')\n\t\t\t\t\t\t\t\t\treturn (res = x.fn(context))\n\n\t\t\t\t\t\t\t\tif (typeof x === 'function')\n\t\t\t\t\t\t\t\t\t// @ts-ignore just in case\n\t\t\t\t\t\t\t\t\treturn (res = x(context))\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\tif (res !== undefined) handle = res\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst fn = adapter.createNativeStaticHandler?.(\n\t\t\t\t\t\t\thandle,\n\t\t\t\t\t\t\thooks,\n\t\t\t\t\t\t\tcontext.set as Context['set']\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn fn instanceof Promise\n\t\t\t\t\t\t\t? fn.then((fn) => {\n\t\t\t\t\t\t\t\t\tif (fn) return fn\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: fn?.()\n\t\t\t\t\t}\n\t\t\t\t: undefined\n\n\t\tconst useNativeStaticResponse =\n\t\t\tthis.config.nativeStaticResponse === true\n\n\t\tconst addResponsePath = (path: string) => {\n\t\t\tif (!useNativeStaticResponse || !nativeStaticHandler) return\n\n\t\t\tif (supportPerMethodInlineHandler) {\n\t\t\t\tif (this.router.response[path])\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tthis.router.response[path]![method] = nativeStaticHandler()\n\t\t\t\telse\n\t\t\t\t\tthis.router.response[path] = {\n\t\t\t\t\t\t[method]: nativeStaticHandler()\n\t\t\t\t\t}\n\t\t\t} else this.router.response[path] = nativeStaticHandler()\n\t\t}\n\n\t\taddResponsePath(path)\n\n\t\tlet _compiled: ComposedHandler\n\t\tconst compile = () => {\n\t\t\tif (_compiled) return _compiled\n\n\t\t\treturn (_compiled = composeHandler({\n\t\t\t\tapp: this,\n\t\t\t\tpath,\n\t\t\t\tmethod,\n\t\t\t\thooks,\n\t\t\t\tvalidator: createValidator(),\n\t\t\t\thandler:\n\t\t\t\t\ttypeof handle !== 'function' &&\n\t\t\t\t\ttypeof adapter.createStaticHandler !== 'function'\n\t\t\t\t\t\t? () => handle\n\t\t\t\t\t\t: handle,\n\t\t\t\tallowMeta,\n\t\t\t\tinference: this.inference\n\t\t\t}))\n\t\t}\n\n\t\tlet oldIndex: number | undefined\n\t\tif (`${method}_${path}` in this.routeTree)\n\t\t\tfor (let i = 0; i < this.router.history.length; i++) {\n\t\t\t\tconst route = this.router.history[i]\n\t\t\t\tif (route.path === path && route.method === method) {\n\t\t\t\t\toldIndex = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\telse this.routeTree[`${method}_${path}`] = this.router.history.length\n\n\t\tconst index = oldIndex ?? this.router.history.length\n\n\t\tconst mainHandler = shouldPrecompile\n\t\t\t? compile()\n\t\t\t: (ctx: Context) =>\n\t\t\t\t\t(\n\t\t\t\t\t\t(this.router.history[index].composed =\n\t\t\t\t\t\t\tcompile!()) as ComposedHandler\n\t\t\t\t\t)(ctx)\n\n\t\tif (oldIndex !== undefined)\n\t\t\tthis.router.history[oldIndex] = Object.assign(\n\t\t\t\t{\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath,\n\t\t\t\t\tcomposed: mainHandler,\n\t\t\t\t\tcompile: compile!,\n\t\t\t\t\thandler: handle,\n\t\t\t\t\thooks\n\t\t\t\t},\n\t\t\t\tstandaloneValidators.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tlocalHook.webSocket\n\t\t\t\t\t? { websocket: localHook.websocket as any }\n\t\t\t\t\t: undefined\n\t\t\t)\n\t\telse\n\t\t\tthis.router.history.push(\n\t\t\t\tObject.assign(\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tcomposed: mainHandler,\n\t\t\t\t\t\tcompile: compile!,\n\t\t\t\t\t\thandler: handle,\n\t\t\t\t\t\thooks\n\t\t\t\t\t},\n\t\t\t\t\tstandaloneValidators.length\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tlocalHook.webSocket\n\t\t\t\t\t\t? { websocket: localHook.websocket as any }\n\t\t\t\t\t\t: undefined\n\t\t\t\t)\n\t\t\t)\n\n\t\tconst handler = {\n\t\t\thandler: shouldPrecompile ? mainHandler : undefined,\n\t\t\tcompile() {\n\t\t\t\treturn (this.handler = compile!())\n\t\t\t}\n\t\t}\n\n\t\tconst staticRouter = this.router.static\n\t\tconst isStaticPath =\n\t\t\tpath.indexOf(':') === -1 && path.indexOf('*') === -1\n\n\t\tif (method === 'WS') {\n\t\t\tif (isStaticPath) {\n\t\t\t\tif (path in staticRouter) staticRouter[path][method] = index\n\t\t\t\telse\n\t\t\t\t\tstaticRouter[path] = {\n\t\t\t\t\t\t[method]: index\n\t\t\t\t\t}\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.router.http.add('WS', path, handler)\n\n\t\t\tif (!this.config.strictPath)\n\t\t\t\tthis.router.http.add('WS', getLoosePath(path), handler)\n\n\t\t\tconst encoded = encodePath(path, { dynamic: true })\n\t\t\tif (path !== encoded) this.router.http.add('WS', encoded, handler)\n\n\t\t\t// Static path doesn't need encode as it's done in compilation process\n\n\t\t\treturn\n\t\t}\n\n\t\tif (isStaticPath) {\n\t\t\tif (path in staticRouter) staticRouter[path][method] = index\n\t\t\telse\n\t\t\t\tstaticRouter[path] = {\n\t\t\t\t\t[method]: index\n\t\t\t\t} as const\n\n\t\t\tif (!this.config.strictPath) addResponsePath(getLoosePath(path))\n\n\t\t\t// Static path doesn't need encode as it's done in compilation process\n\t\t} else {\n\t\t\tthis.router.http.add(method, path, handler)\n\n\t\t\tif (!this.config.strictPath) {\n\t\t\t\tconst loosePath = getLoosePath(path)\n\n\t\t\t\taddResponsePath(loosePath)\n\t\t\t\tthis.router.http.add(method, loosePath, handler)\n\t\t\t}\n\n\t\t\tconst encoded = encodePath(path, { dynamic: true })\n\t\t\tif (path !== encoded) {\n\t\t\t\tthis.router.http.add(method, encoded, handler)\n\n\t\t\t\taddResponsePath(encoded)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setHeaders?: Context['set']['headers']\n\theaders(header: Context['set']['headers'] | undefined) {\n\t\tif (!header) return this\n\n\t\tif (!this.setHeaders) this.setHeaders = {}\n\n\t\tthis.setHeaders = mergeDeep(this.setHeaders, header)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### start | Life cycle event\n\t * Called after server is ready for serving\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onStart(({ server }) => {\n\t * console.log(\"Running at ${server?.url}:${server?.port}\")\n\t * })\n\t * .listen(3000)\n\t * ```\n\t */\n\tonStart(handler: MaybeArray<GracefulHandler<this>>) {\n\t\tthis.on('start', handler as any)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### request | Life cycle event\n\t * Called on every new request is accepted\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onRequest(({ method, url }) => {\n\t * saveToAnalytic({ method, url })\n\t * })\n\t * ```\n\t */\n\tonRequest<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tPreHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: {}\n\t\t\t\t\tresolve: {}\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t) {\n\t\tthis.on('request', handler as any)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### parse | Life cycle event\n\t * Callback function to handle body parsing\n\t *\n\t * If truthy value is returned, will be assigned to `context.body`\n\t * Otherwise will skip the callback and look for the next one.\n\t *\n\t * Equivalent to Express's body parser\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onParse((request, contentType) => {\n\t * if(contentType === \"application/json\")\n\t * return request.json()\n\t * })\n\t * ```\n\t */\n\tonParse<const Schema extends RouteSchema>(\n\t\tparser: MaybeArray<\n\t\t\tBodyHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\tresolve: {}\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### parse | Life cycle event\n\t * Callback function to handle body parsing\n\t *\n\t * If truthy value is returned, will be assigned to `context.body`\n\t * Otherwise will skip the callback and look for the next one.\n\t *\n\t * Equivalent to Express's body parser\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onParse((request, contentType) => {\n\t * if(contentType === \"application/json\")\n\t * return request.json()\n\t * })\n\t * ```\n\t */\n\tonParse<const Schema extends RouteSchema, const Type extends LifeCycleType>(\n\t\toptions: { as?: Type },\n\t\tparser: MaybeArray<\n\t\t\tBodyHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\t'global' extends Type\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\tPartial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t}\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\tonParse<const Parsers extends keyof Metadata['parser']>(\n\t\tparser: Parsers\n\t): this\n\n\tonParse(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function> | string,\n\t\thandler?: MaybeArray<Function>\n\t): unknown {\n\t\tif (!handler) {\n\t\t\tif (typeof options === 'string')\n\t\t\t\treturn this.on('parse', this['~parser'][options] as any)\n\n\t\t\treturn this.on('parse', options as any)\n\t\t}\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'parse',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### parse | Life cycle event\n\t * Callback function to handle body parsing\n\t *\n\t * If truthy value is returned, will be assigned to `context.body`\n\t * Otherwise will skip the callback and look for the next one.\n\t *\n\t * Equivalent to Express's body parser\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onParse((request, contentType) => {\n\t * if(contentType === \"application/json\")\n\t * return request.json()\n\t * })\n\t * ```\n\t */\n\tparser<\n\t\tconst Parser extends string,\n\t\tconst Schema extends RouteSchema,\n\t\tconst Handler extends BodyHandler<\n\t\t\tMergeSchema<\n\t\t\t\tSchema,\n\t\t\t\tMergeSchema<\n\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t>,\n\t\t\t\tBasePath\n\t\t\t> &\n\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t{\n\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\tstore: Singleton['store']\n\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\tVolatile['derive']\n\t\t\t\tresolve: {}\n\t\t\t}\n\t\t>\n\t>(\n\t\tname: Parser,\n\t\tparser: Handler\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: Metadata['schema']\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro']\n\t\t\tmacroFn: Metadata['macroFn']\n\t\t\tparser: Metadata['parser'] & { [K in Parser]: Handler }\n\t\t},\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis['~parser'][name] = parser as any\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### transform | Life cycle event\n\t * Assign or transform anything related to context before validation.\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onTransform(({ params }) => {\n\t * if(params.id)\n\t * params.id = +params.id\n\t * })\n\t * ```\n\t */\n\tonTransform<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tTransformHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\tresolve: {}\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### transform | Life cycle event\n\t * Assign or transform anything related to context before validation.\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onTransform(({ params }) => {\n\t * if(params.id)\n\t * params.id = +params.id\n\t * })\n\t * ```\n\t */\n\tonTransform<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tTransformHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\t'global' extends Type\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t}\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tPartial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\tonTransform(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('transform', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'transform',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tresolve<\n\t\tconst Resolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\tresolver: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t\t'global' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\tSingleton &\n\t\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Resolver | void>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\tSingleton['resolve'] & ExcludeElysiaResponse<Resolver>\n\t\t\t\t\t>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Resolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Resolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tresolve<\n\t\tconst Resolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t\t\t| void\n\t>(\n\t\tresolver: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t\tSingleton & {\n\t\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t},\n\t\t\t\t\tBasePath\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Resolver | void>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: Prettify<\n\t\t\t\tVolatile['resolve'] & ExcludeElysiaResponse<Resolver>\n\t\t\t>\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\tresolve(\n\t\toptionsOrResolve: { as?: LifeCycleType } | Function,\n\t\tresolve?: Function\n\t) {\n\t\tif (!resolve) {\n\t\t\tresolve = optionsOrResolve as any\n\t\t\toptionsOrResolve = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'resolve',\n\t\t\tfn: resolve!\n\t\t}\n\n\t\treturn this.onBeforeHandle(optionsOrResolve as any, hook as any) as any\n\t}\n\n\tmapResolve<\n\t\tconst NewResolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t>(\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t},\n\t\t\t\tBasePath\n\t\t\t>\n\t\t) => MaybePromise<NewResolver | void>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: ExcludeElysiaResponse<NewResolver>\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\tmapResolve<\n\t\tconst NewResolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t) => MaybePromise<NewResolver | void>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: ExcludeElysiaResponse<NewResolver>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewResolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewResolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\tmapResolve(\n\t\toptionsOrResolve: Function | { as?: LifeCycleType },\n\t\tmapper?: Function\n\t) {\n\t\tif (!mapper) {\n\t\t\tmapper = optionsOrResolve as any\n\t\t\toptionsOrResolve = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'mapResolve',\n\t\t\tfn: mapper!\n\t\t}\n\n\t\treturn this.onBeforeHandle(optionsOrResolve as any, hook as any) as any\n\t}\n\n\t/**\n\t * ### Before Handle | Life cycle event\n\t * Execute after validation and before the main route handler.\n\t *\n\t * If truthy value is returned, will be assigned as `Response` and skip the main handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onBeforeHandle(({ params: { id }, status }) => {\n\t * if(id && !isExisted(id)) {\n\t * \t status(401)\n\t *\n\t * return \"Unauthorized\"\n\t * \t }\n\t * })\n\t * ```\n\t */\n\tonBeforeHandle<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tOptionalHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### Before Handle | Life cycle event\n\t * Execute after validation and before the main route handler.\n\t *\n\t * If truthy value is returned, will be assigned as `Response` and skip the main handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onBeforeHandle(({ params: { id }, status }) => {\n\t * if(id && !isExisted(id)) {\n\t * \t status(401)\n\t *\n\t * return \"Unauthorized\"\n\t * \t }\n\t * })\n\t * ```\n\t */\n\tonBeforeHandle<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tOptionalHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t}),\n\t\t\t\tBasePath\n\t\t\t>\n\t\t>\n\t): this\n\n\tonBeforeHandle(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('beforeHandle', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'beforeHandle',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tonAfterHandle<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tAfterHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tonAfterHandle<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: LifeCycleType },\n\t\thandler: MaybeArray<\n\t\t\tAfterHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t>\n\t): this\n\n\tonAfterHandle(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('afterHandle', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'afterHandle',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .mapResponse((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tmapResponse<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tMapResponse<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .mapResponse((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tmapResponse<const Schema extends RouteSchema, Type extends LifeCycleType>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tMapResponse<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t>\n\t): this\n\n\tmapResponse(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('mapResponse', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'mapResponse',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### response | Life cycle event\n\t * Call AFTER main handler is executed\n\t * Good for analytic metrics\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterResponse(() => {\n\t * cleanup()\n\t * })\n\t * ```\n\t */\n\tonAfterResponse<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tAfterResponseHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### response | Life cycle event\n\t * Call AFTER main handler is executed\n\t * Good for analytic metrics\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterResponse(() => {\n\t * cleanup()\n\t * \t })\n\t * ```\n\t */\n\n\tonAfterResponse<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tAfterResponseHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t>\n\t): this\n\n\tonAfterResponse(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('afterResponse', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'afterResponse',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\ttrace<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<TraceHandler<Schema, Singleton>>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\ttrace<const Schema extends RouteSchema>(\n\t\toptions: { as?: LifeCycleType },\n\t\thandler: MaybeArray<TraceHandler<Schema, Singleton>>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\ttrace(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) {\n\t\t\thandler = options as MaybeArray<Function>\n\t\t\toptions = { as: 'local' }\n\t\t}\n\n\t\tif (!Array.isArray(handler)) handler = [handler] as Function[]\n\n\t\tfor (const fn of handler)\n\t\t\tthis.on(\n\t\t\t\toptions as { as?: LifeCycleType },\n\t\t\t\t'trace',\n\t\t\t\tcreateTracer(fn as any) as any\n\t\t\t)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * Register errors\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * class CustomError extends Error {\n\t * constructor() {\n\t * super()\n\t * }\n\t * }\n\t *\n\t * new Elysia()\n\t * .error('CUSTOM_ERROR', CustomError)\n\t * ```\n\t */\n\terror<\n\t\tconst Errors extends Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tprototype: Error\n\t\t\t}\n\t\t>\n\t>(\n\t\terrors: Errors\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox']\n\t\t\terror: Definitions['error'] & {\n\t\t\t\t[K in keyof Errors]: Errors[K] extends {\n\t\t\t\t\tprototype: infer LiteralError extends Error\n\t\t\t\t}\n\t\t\t\t\t? LiteralError\n\t\t\t\t\t: Errors[K]\n\t\t\t}\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * Register errors\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * class CustomError extends Error {\n\t * constructor() {\n\t * super()\n\t * }\n\t * }\n\t *\n\t * new Elysia()\n\t * .error({\n\t * CUSTOM_ERROR: CustomError\n\t * })\n\t * ```\n\t */\n\terror<\n\t\tName extends string,\n\t\tconst CustomError extends {\n\t\t\tprototype: Error\n\t\t}\n\t>(\n\t\tname: Name,\n\t\terrors: CustomError\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox']\n\t\t\terror: Definitions['error'] & {\n\t\t\t\t[name in Name]: CustomError extends {\n\t\t\t\t\tprototype: infer LiteralError extends Error\n\t\t\t\t}\n\t\t\t\t\t? LiteralError\n\t\t\t\t\t: CustomError\n\t\t\t}\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * Register errors\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * class CustomError extends Error {\n\t * constructor() {\n\t * super()\n\t * }\n\t * }\n\t *\n\t * new Elysia()\n\t * .error('CUSTOM_ERROR', CustomError)\n\t * ```\n\t */\n\terror<const NewErrors extends Record<string, Error>>(\n\t\tmapper: (decorators: Definitions['error']) => NewErrors\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox']\n\t\t\terror: {\n\t\t\t\t[K in keyof NewErrors]: NewErrors[K] extends {\n\t\t\t\t\tprototype: infer LiteralError extends Error\n\t\t\t\t}\n\t\t\t\t\t? LiteralError\n\t\t\t\t\t: never\n\t\t\t}\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\terror(\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tname:\n\t\t\t| string\n\t\t\t| Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t{\n\t\t\t\t\t\tprototype: Error\n\t\t\t\t\t}\n\t\t\t >\n\t\t\t| Function,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\terror?: {\n\t\t\tprototype: Error\n\t\t}\n\t): AnyElysia {\n\t\tswitch (typeof name) {\n\t\t\tcase 'string':\n\t\t\t\t// @ts-ignore\n\t\t\t\terror.prototype[ERROR_CODE] = name\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.definitions.error[name] = error\n\n\t\t\t\treturn this\n\n\t\t\tcase 'function':\n\t\t\t\tthis.definitions.error = name(this.definitions.error)\n\n\t\t\t\treturn this as any\n\t\t}\n\n\t\tfor (const [code, error] of Object.entries(name)) {\n\t\t\t// @ts-ignore\n\t\t\terror.prototype[ERROR_CODE] = code as any\n\n\t\t\tthis.definitions.error[code] = error as any\n\t\t}\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### Error | Life cycle event\n\t * Called when error is thrown during processing request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onError(({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\tonError<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tErrorHandler<\n\t\t\t\tDefinitions['error'],\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### Error | Life cycle event\n\t * Called when error is thrown during processing request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onError(({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\tonError<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Scope extends LifeCycleType\n\t>(\n\t\toptions: { as?: Scope },\n\t\thandler: MaybeArray<\n\t\t\tErrorHandler<\n\t\t\t\tDefinitions['error'],\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tScope extends 'global'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\tresolve: Singleton['resolve'] &\n\t\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t}\n\t\t\t\t\t: Scope extends 'scoped'\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive']\n\t\t\t\t\t\t\t\tresolve: Singleton['resolve'] &\n\t\t\t\t\t\t\t\t\tEphemeral['resolve']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: Singleton,\n\t\t\t\tScope extends 'global'\n\t\t\t\t\t? Ephemeral\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tderive: Partial<Ephemeral['derive']>\n\t\t\t\t\t\t\tresolve: Partial<Ephemeral['resolve']>\n\t\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t\t},\n\t\t\t\tScope extends 'global'\n\t\t\t\t\t? Ephemeral\n\t\t\t\t\t: Scope extends 'scoped'\n\t\t\t\t\t\t? Ephemeral\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tderive: Partial<Ephemeral['derive']>\n\t\t\t\t\t\t\t\tresolve: Partial<Ephemeral['resolve']>\n\t\t\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### Error | Life cycle event\n\t * Called when error is thrown during processing request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onError(({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\tonError(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('error', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'error',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### stop | Life cycle event\n\t * Called after server stop serving request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onStop((app) => {\n\t * cleanup()\n\t * })\n\t * ```\n\t */\n\tonStop(handler: MaybeArray<GracefulHandler<this>>) {\n\t\tthis.on('stop', handler as any)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### on\n\t * Syntax sugar for attaching life cycle event by name\n\t *\n\t * Does the exact same thing as `.on[Event]()`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .on('error', ({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\ton<Event extends keyof LifeCycleStore>(\n\t\ttype: Event,\n\t\thandlers: MaybeArray<\n\t\t\tExtract<LifeCycleStore[Event], HookContainer[]>[0]['fn']\n\t\t>\n\t): this\n\n\t/**\n\t * ### on\n\t * Syntax sugar for attaching life cycle event by name\n\t *\n\t * Does the exact same thing as `.on[Event]()`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .on('error', ({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\ton<const Event extends keyof LifeCycleStore>(\n\t\toptions: { as?: LifeCycleType },\n\t\ttype: Event,\n\t\thandlers: MaybeArray<Extract<LifeCycleStore[Event], Function[]>[0]>\n\t): this\n\n\ton(\n\t\toptionsOrType: { as?: LifeCycleType } | string,\n\t\ttypeOrHandlers: MaybeArray<Function | HookContainer> | string,\n\t\thandlers?: MaybeArray<Function | HookContainer>\n\t) {\n\t\tlet type: keyof LifeCycleStore\n\n\t\tswitch (typeof optionsOrType) {\n\t\t\tcase 'string':\n\t\t\t\ttype = optionsOrType as any\n\t\t\t\thandlers = typeOrHandlers as any\n\n\t\t\t\tbreak\n\n\t\t\tcase 'object':\n\t\t\t\ttype = typeOrHandlers as any\n\n\t\t\t\tif (\n\t\t\t\t\t!Array.isArray(typeOrHandlers) &&\n\t\t\t\t\ttypeof typeOrHandlers === 'object'\n\t\t\t\t)\n\t\t\t\t\thandlers = typeOrHandlers\n\n\t\t\t\tbreak\n\t\t}\n\n\t\tif (Array.isArray(handlers)) handlers = fnToContainer(handlers)\n\t\telse {\n\t\t\tif (typeof handlers === 'function')\n\t\t\t\thandlers = [\n\t\t\t\t\t{\n\t\t\t\t\t\tfn: handlers\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\telse handlers = [handlers!]\n\t\t}\n\n\t\tconst handles = handlers as HookContainer[]\n\n\t\tfor (const handle of handles) {\n\t\t\thandle.scope =\n\t\t\t\ttypeof optionsOrType === 'string'\n\t\t\t\t\t? 'local'\n\t\t\t\t\t: (optionsOrType?.as ?? 'local')\n\n\t\t\t// @ts-expect-error\n\t\t\tif (type === 'resolve' || type === 'derive') handle.subType = type\n\t\t}\n\n\t\tif (type !== 'trace')\n\t\t\tthis.inference = sucrose(\n\t\t\t\t{\n\t\t\t\t\t[type]: handles.map((x) => x.fn)\n\t\t\t\t},\n\t\t\t\tthis.inference\n\t\t\t)\n\n\t\tfor (const handle of handles) {\n\t\t\tconst fn = asHookType(handle, 'global', { skipIfHasType: true })\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'start':\n\t\t\t\t\tthis.event.start ??= []\n\t\t\t\t\tthis.event.start.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'request':\n\t\t\t\t\tthis.event.request ??= []\n\t\t\t\t\tthis.event.request.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'parse':\n\t\t\t\t\tthis.event.parse ??= []\n\t\t\t\t\tthis.event.parse.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'transform':\n\t\t\t\t\tthis.event.transform ??= []\n\t\t\t\t\tthis.event.transform.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tcase 'derive':\n\t\t\t\t\tthis.event.transform ??= []\n\t\t\t\t\tthis.event.transform.push(\n\t\t\t\t\t\tfnToContainer(fn as any, 'derive') as any\n\t\t\t\t\t)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'beforeHandle':\n\t\t\t\t\tthis.event.beforeHandle ??= []\n\t\t\t\t\tthis.event.beforeHandle.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\t// eslint-disable-next-line sonarjs/no-duplicated-branches\n\t\t\t\tcase 'resolve':\n\t\t\t\t\tthis.event.beforeHandle ??= []\n\t\t\t\t\tthis.event.beforeHandle.push(\n\t\t\t\t\t\tfnToContainer(fn as any, 'resolve') as any\n\t\t\t\t\t)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'afterHandle':\n\t\t\t\t\tthis.event.afterHandle ??= []\n\t\t\t\t\tthis.event.afterHandle.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'mapResponse':\n\t\t\t\t\tthis.event.mapResponse ??= []\n\t\t\t\t\tthis.event.mapResponse.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'afterResponse':\n\t\t\t\t\tthis.event.afterResponse ??= []\n\t\t\t\t\tthis.event.afterResponse.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'trace':\n\t\t\t\t\tthis.event.trace ??= []\n\t\t\t\t\tthis.event.trace.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'error':\n\t\t\t\t\tthis.event.error ??= []\n\t\t\t\t\tthis.event.error.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'stop':\n\t\t\t\t\tthis.event.stop ??= []\n\t\t\t\t\tthis.event.stop.push(fn as any)\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\treturn this\n\t}\n\n\tas(type: 'global'): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Prettify<\n\t\t\t\tSingleton['derive'] & Ephemeral['derive'] & Volatile['derive']\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\tVolatile['resolve']\n\t\t\t>\n\t\t},\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: MergeSchema<\n\t\t\t\tMergeSchema<Volatile['schema'], Ephemeral['schema']>,\n\t\t\t\tMetadata['schema']\n\t\t\t>\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro']\n\t\t\tmacroFn: Metadata['macroFn']\n\t\t\tparser: Metadata['parser']\n\t\t},\n\t\tRoutes,\n\t\t{\n\t\t\tderive: {}\n\t\t\tresolve: {}\n\t\t\tschema: {}\n\t\t\tstandaloneSchema: {}\n\t\t},\n\t\t{\n\t\t\tderive: {}\n\t\t\tresolve: {}\n\t\t\tschema: {}\n\t\t\tstandaloneSchema: {}\n\t\t}\n\t>\n\n\tas(type: 'scoped'): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\t{\n\t\t\tderive: Prettify<Ephemeral['derive'] & Volatile['derive']>\n\t\t\tresolve: Prettify<Ephemeral['resolve'] & Volatile['resolve']>\n\t\t\tschema: MergeSchema<Volatile['schema'], Ephemeral['schema']>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tVolatile['standaloneSchema'] & Ephemeral['standaloneSchema']\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\tderive: {}\n\t\t\tresolve: {}\n\t\t\tschema: {}\n\t\t\tstandaloneSchema: {}\n\t\t}\n\t>\n\n\tas(type: 'global' | 'scoped') {\n\t\tpromoteEvent(this.event.parse, type)\n\t\tpromoteEvent(this.event.transform, type)\n\t\tpromoteEvent(this.event.beforeHandle, type)\n\t\tpromoteEvent(this.event.afterHandle, type)\n\t\tpromoteEvent(this.event.mapResponse, type)\n\t\tpromoteEvent(this.event.afterResponse, type)\n\t\tpromoteEvent(this.event.trace, type)\n\t\tpromoteEvent(this.event.error, type)\n\n\t\tif (type === 'scoped') {\n\t\t\tthis.validator.scoped = mergeSchemaValidator(\n\t\t\t\tthis.validator.scoped,\n\t\t\t\tthis.validator.local\n\t\t\t)\n\t\t\tthis.validator.local = null\n\n\t\t\tif (this.standaloneValidator.local !== null) {\n\t\t\t\tthis.standaloneValidator.scoped ||= []\n\t\t\t\tthis.standaloneValidator.scoped.push(\n\t\t\t\t\t...this.standaloneValidator.local\n\t\t\t\t)\n\t\t\t\tthis.standaloneValidator.local = null\n\t\t\t}\n\t\t} else if (type === 'global') {\n\t\t\tthis.validator.global = mergeSchemaValidator(\n\t\t\t\tthis.validator.global,\n\t\t\t\tmergeSchemaValidator(\n\t\t\t\t\tthis.validator.scoped,\n\t\t\t\t\tthis.validator.local\n\t\t\t\t) as SchemaValidator\n\t\t\t) as SchemaValidator\n\n\t\t\tthis.validator.scoped = null\n\t\t\tthis.validator.local = null\n\n\t\t\tif (this.standaloneValidator.local !== null) {\n\t\t\t\tthis.standaloneValidator.scoped ||= []\n\t\t\t\tthis.standaloneValidator.scoped.push(\n\t\t\t\t\t...this.standaloneValidator.local\n\t\t\t\t)\n\t\t\t\tthis.standaloneValidator.local = null\n\t\t\t}\n\t\t\tif (this.standaloneValidator.scoped !== null) {\n\t\t\t\tthis.standaloneValidator.global ||= []\n\t\t\t\tthis.standaloneValidator.global.push(\n\t\t\t\t\t...this.standaloneValidator.scoped\n\t\t\t\t)\n\t\t\t\tthis.standaloneValidator.scoped = null\n\t\t\t}\n\t\t}\n\n\t\treturn this as any\n\t}\n\n\tgroup<const Prefix extends string, const NewElysia extends AnyElysia>(\n\t\tprefix: Prefix,\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tJoinPath<BasePath, Prefix>,\n\t\t\t\tSingleton,\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: MergeSchema<\n\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\tJoinPath<BasePath, Prefix>\n\t\t\t\t\t\t>,\n\t\t\t\t\t\tMetadata['schema']\n\t\t\t\t\t>\n\t\t\t\t\tstandaloneSchema: Prettify<\n\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\tJoinPath<BasePath, Prefix>\n\t\t\t\t\t\t> &\n\t\t\t\t\t\t\tMetadata['standaloneSchema']\n\t\t\t\t\t>\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tPrettify<Routes & NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tgroup<\n\t\tconst Prefix extends string,\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Input extends InputSchema<keyof Definitions['typebox'] & string>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tInput,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Prefix>\n\t\t\t>,\n\t\t\tMetadata['schema']\n\t\t> &\n\t\t\tMetadata['standaloneSchema'],\n\t\tconst Resolutions extends MaybeArray<\n\t\t\tResolveHandler<\n\t\t\t\tSchema,\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t>(\n\t\tprefix: Prefix,\n\t\tschema: LocalHook<\n\t\t\tInput,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMetadata['macro'],\n\t\t\tkeyof Metadata['parser']\n\t\t>,\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tJoinPath<BasePath, Prefix>,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\tSingleton['derive'] &\n\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t>\n\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\tResolveResolutions<Resolutions>\n\t\t\t\t\t>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: Prettify<Schema>\n\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes & NewElysia['~Routes'],\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### group\n\t * Encapsulate and group path with prefix\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .group('/v1', app => app\n\t * .get('/', () => 'Hi')\n\t * .get('/name', () => 'Elysia')\n\t * })\n\t * ```\n\t */\n\tgroup(\n\t\tprefix: string,\n\t\tschemaOrRun: AnyLocalHook | ((group: AnyElysia) => AnyElysia),\n\t\trun?: (group: AnyElysia) => AnyElysia\n\t): AnyElysia {\n\t\tconst instance = new Elysia({\n\t\t\t...this.config,\n\t\t\tprefix: ''\n\t\t})\n\n\t\tinstance.singleton = { ...this.singleton }\n\t\tinstance.definitions = { ...this.definitions }\n\t\tinstance.getServer = () => this.getServer()\n\t\tinstance.inference = cloneInference(this.inference)\n\t\tinstance.extender = { ...this.extender }\n\t\tinstance['~parser'] = this['~parser']\n\t\tinstance.standaloneValidator = {\n\t\t\tlocal: [...(this.standaloneValidator.local ?? [])],\n\t\t\tscoped: [...(this.standaloneValidator.scoped ?? [])],\n\t\t\tglobal: [...(this.standaloneValidator.global ?? [])]\n\t\t}\n\n\t\tconst isSchema = typeof schemaOrRun === 'object'\n\t\tconst sandbox = (isSchema ? run! : schemaOrRun)(instance)\n\t\tthis.singleton = mergeDeep(this.singleton, instance.singleton) as any\n\t\tthis.definitions = mergeDeep(this.definitions, instance.definitions)\n\n\t\tif (sandbox.event.request?.length)\n\t\t\tthis.event.request = [\n\t\t\t\t...(this.event.request || []),\n\t\t\t\t...((sandbox.event.request || []) as any)\n\t\t\t]\n\n\t\tif (sandbox.event.mapResponse?.length)\n\t\t\tthis.event.mapResponse = [\n\t\t\t\t...(this.event.mapResponse || []),\n\t\t\t\t...((sandbox.event.mapResponse || []) as any)\n\t\t\t]\n\n\t\tthis.model(sandbox.definitions.type)\n\n\t\tObject.values(instance.router.history).forEach(\n\t\t\t({ method, path, handler, hooks, standaloneValidators }) => {\n\t\t\t\tpath =\n\t\t\t\t\t(isSchema ? '' : (this.config.prefix ?? '')) + prefix + path\n\n\t\t\t\tif (isSchema) {\n\t\t\t\t\tconst hook = schemaOrRun\n\t\t\t\t\tconst localHook = hooks as AnyLocalHook\n\n\t\t\t\t\tthis.add(\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\thandler,\n\t\t\t\t\t\tmergeHook(hook, {\n\t\t\t\t\t\t\t...(localHook || {}),\n\t\t\t\t\t\t\terror: !localHook.error\n\t\t\t\t\t\t\t\t? sandbox.event.error\n\t\t\t\t\t\t\t\t: Array.isArray(localHook.error)\n\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t...(localHook.error ?? []),\n\t\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\tlocalHook.error,\n\t\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tthis.add(\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\thandler,\n\t\t\t\t\t\tmergeHook(hooks as AnyLocalHook, {\n\t\t\t\t\t\t\terror: sandbox.event.error\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tskipPrefix: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\n\t\treturn this as any\n\t}\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>,\n\t\tconst GuardType extends GuardSchemaType,\n\t\tconst AsType extends LifeCycleType\n\t>(\n\t\thook: {\n\t\t\t/**\n\t\t\t * @default 'override'\n\t\t\t */\n\t\t\tas?: AsType\n\t\t\t/**\n\t\t\t * @default 'standalone'\n\t\t\t * @since 1.3.0\n\t\t\t */\n\t\t\tschema?: GuardType\n\t\t} & LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Or<\n\t\tGuardSchemaType extends GuardType ? true : false,\n\t\tGuardType extends 'override' ? true : false\n\t> extends true\n\t\t? Or<\n\t\t\t\tLifeCycleType extends AsType ? true : false,\n\t\t\t\tAsType extends 'local' ? true : false\n\t\t\t> extends true\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\t\t\t\tschema: Prettify<\n\t\t\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\t\tDefinitions['typebox']\n\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\tMetadata['schema']\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t: AsType extends 'global'\n\t\t\t\t? Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tSingleton['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t},\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tschema: Prettify<\n\t\t\t\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\t\t\t\tBasePath\n\t\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\t\tMetadata['schema']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\tEphemeral,\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\t\t\t\t: Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\tSingleton,\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\tMetadata,\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tEphemeral['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tschema: Prettify<\n\t\t\t\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\t\t\tDefinitions['typebox']\n\t\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\t\tMetadata['schema'] & Ephemeral['schema']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\t\t: Or<\n\t\t\t\t\tLifeCycleType extends AsType ? true : false,\n\t\t\t\t\tAsType extends 'local' ? true : false\n\t\t\t > extends true\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema'] &\n\t\t\t\t\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox']>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t: AsType extends 'global'\n\t\t\t\t? Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tSingleton['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t},\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tschema: Metadata['schema']\n\t\t\t\t\t\t\tstandaloneSchema: UnwrapRoute<\n\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\t\tBasePath\n\t\t\t\t\t\t\t> &\n\t\t\t\t\t\t\t\tMetadata['standaloneSchema']\n\t\t\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\tEphemeral,\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\t\t\t\t: Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\tSingleton,\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\tMetadata,\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tEphemeral['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema'] &\n\t\t\t\t\t\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox']>\n\t\t\t\t\t\t},\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>\n\t>(\n\t\thook: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\tMacroContext\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\tschema: Prettify<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t>\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t}\n\t>\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>\n\t>(\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Singleton['resolve'] & MacroContext\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: Prettify<Schema>\n\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tPrettify<Routes & NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>\n\t>(\n\t\tschema: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>,\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Prettify<Singleton['resolve'] & MacroContext>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: Prettify<Schema>\n\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tPrettify<Routes & NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\t/**\n\t * ### guard\n\t * Encapsulate and pass hook into all child handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .guard({\n\t * schema: {\n\t * body: t.Object({\n\t * username: t.String(),\n\t * password: t.String()\n\t * })\n\t * }\n\t * }, app => app\n\t * .get(\"/\", () => 'Hi')\n\t * .get(\"/name\", () => 'Elysia')\n\t * })\n\t * ```\n\t */\n\tguard(\n\t\thook:\n\t\t\t| (AnyLocalHook & {\n\t\t\t\t\tas: LifeCycleType\n\t\t\t })\n\t\t\t| ((group: AnyElysia) => AnyElysia),\n\t\trun?: (group: AnyElysia) => AnyElysia\n\t): AnyElysia {\n\t\tif (!run) {\n\t\t\tif (typeof hook === 'object') {\n\t\t\t\tthis.applyMacro(hook)\n\n\t\t\t\tif (hook.detail) {\n\t\t\t\t\tif (this.config.detail)\n\t\t\t\t\t\tthis.config.detail = mergeDeep(\n\t\t\t\t\t\t\tObject.assign({}, this.config.detail),\n\t\t\t\t\t\t\thook.detail\n\t\t\t\t\t\t)\n\t\t\t\t\telse this.config.detail = hook.detail\n\t\t\t\t}\n\n\t\t\t\tif (hook.tags) {\n\t\t\t\t\tif (!this.config.detail)\n\t\t\t\t\t\tthis.config.detail = {\n\t\t\t\t\t\t\ttags: hook.tags\n\t\t\t\t\t\t}\n\t\t\t\t\telse this.config.detail.tags = hook.tags\n\t\t\t\t}\n\n\t\t\t\tconst type: LifeCycleType = hook.as ?? 'local'\n\n\t\t\t\tif (hook.schema === 'standalone') {\n\t\t\t\t\tif (!this.standaloneValidator[type])\n\t\t\t\t\t\tthis.standaloneValidator[type] = []\n\n\t\t\t\t\tconst response =\n\t\t\t\t\t\thook?.response ||\n\t\t\t\t\t\ttypeof hook?.response === 'string' ||\n\t\t\t\t\t\t(hook?.response && Kind in hook.response)\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t200: hook.response\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: hook?.response\n\n\t\t\t\t\tthis.standaloneValidator[type].push({\n\t\t\t\t\t\tbody: hook.body,\n\t\t\t\t\t\theaders: hook.headers,\n\t\t\t\t\t\tparams: hook.params,\n\t\t\t\t\t\tquery: hook.query,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tcookie: hook.cookie\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tthis.validator[type] = {\n\t\t\t\t\t\tbody: hook.body ?? this.validator[type]?.body,\n\t\t\t\t\t\theaders: hook.headers ?? this.validator[type]?.headers,\n\t\t\t\t\t\tparams: hook.params ?? this.validator[type]?.params,\n\t\t\t\t\t\tquery: hook.query ?? this.validator[type]?.query,\n\t\t\t\t\t\tresponse:\n\t\t\t\t\t\t\thook.response ?? this.validator[type]?.response,\n\t\t\t\t\t\tcookie: hook.cookie ?? this.validator[type]?.cookie\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (hook.parse) this.on({ as: type }, 'parse', hook.parse)\n\t\t\t\tif (hook.transform)\n\t\t\t\t\tthis.on({ as: type }, 'transform', hook.transform)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (hook.derive) this.on({ as: type }, 'derive', hook.derive)\n\t\t\t\tif (hook.beforeHandle)\n\t\t\t\t\tthis.on({ as: type }, 'beforeHandle', hook.beforeHandle)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (hook.resolve) this.on({ as: type }, 'resolve', hook.resolve)\n\t\t\t\tif (hook.afterHandle)\n\t\t\t\t\tthis.on({ as: type }, 'afterHandle', hook.afterHandle)\n\t\t\t\tif (hook.mapResponse)\n\t\t\t\t\tthis.on({ as: type }, 'mapResponse', hook.mapResponse)\n\t\t\t\tif (hook.afterResponse)\n\t\t\t\t\tthis.on({ as: type }, 'afterResponse', hook.afterResponse)\n\t\t\t\tif (hook.error) this.on({ as: type }, 'error', hook.error)\n\n\t\t\t\treturn this\n\t\t\t}\n\n\t\t\treturn this.guard({} as any, hook)\n\t\t}\n\n\t\tconst instance = new Elysia({\n\t\t\t...this.config,\n\t\t\tprefix: ''\n\t\t})\n\t\tinstance.singleton = { ...this.singleton }\n\t\tinstance.definitions = { ...this.definitions }\n\t\tinstance.inference = cloneInference(this.inference)\n\t\tinstance.extender = { ...this.extender }\n\t\tinstance.getServer = () => this.getServer()\n\n\t\tconst sandbox = run(instance)\n\t\tthis.singleton = mergeDeep(this.singleton, instance.singleton) as any\n\t\tthis.definitions = mergeDeep(this.definitions, instance.definitions)\n\n\t\t// ? Inject getServer for websocket and trace (important, do not remove)\n\t\tsandbox.getServer = () => this.server\n\n\t\tif (sandbox.event.request?.length)\n\t\t\tthis.event.request = [\n\t\t\t\t...(this.event.request || []),\n\t\t\t\t...(sandbox.event.request || [])\n\t\t\t]\n\n\t\tif (sandbox.event.mapResponse?.length)\n\t\t\tthis.event.mapResponse = [\n\t\t\t\t...(this.event.mapResponse || []),\n\t\t\t\t...(sandbox.event.mapResponse || [])\n\t\t\t]\n\n\t\tthis.model(sandbox.definitions.type)\n\n\t\tObject.values(instance.router.history).forEach(\n\t\t\t({ method, path, handler, hooks: localHook }) => {\n\t\t\t\tthis.add(\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath,\n\t\t\t\t\thandler,\n\t\t\t\t\tmergeHook(hook as AnyLocalHook, {\n\t\t\t\t\t\t...((localHook || {}) as AnyLocalHook),\n\t\t\t\t\t\terror: !localHook.error\n\t\t\t\t\t\t\t? sandbox.event.error\n\t\t\t\t\t\t\t: Array.isArray(localHook.error)\n\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t...(localHook.error ?? []),\n\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\tlocalHook.error,\n\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t}\n\t\t)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * Inline fn\n\t */\n\tuse<\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Param extends AnyElysia = this\n\t>(\n\t\tplugin: (app: Param) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Singleton & NewElysia['~Singleton']>,\n\t\tPrettify<Definitions & NewElysia['~Definitions']>,\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\tPrettify2<Ephemeral & NewElysia['~Ephemeral']>,\n\t\tPrettify2<Volatile & NewElysia['~Volatile']>\n\t>\n\n\t/**\n\t * Inline async fn\n\t */\n\tuse<\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Param extends AnyElysia = this\n\t>(\n\t\tplugin:\n\t\t\t| ((app: Param) => Promise<NewElysia>)\n\t\t\t| Promise<(app: Param) => NewElysia>\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<\n\t\t\t\tSingleton['decorator'] &\n\t\t\t\t\tPartial<NewElysia['~Singleton']['decorator']>\n\t\t\t>\n\t\t\tstore: Prettify<\n\t\t\t\tSingleton['store'] & Partial<NewElysia['~Singleton']['store']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tSingleton['derive'] & Partial<NewElysia['~Singleton']['derive']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\tPartial<NewElysia['~Singleton']['resolve']>\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\terror: Prettify<\n\t\t\t\tDefinitions['error'] & NewElysia['~Definitions']['error']\n\t\t\t>\n\t\t\ttypebox: Prettify<\n\t\t\t\tDefinitions['typebox'] & NewElysia['~Definitions']['typebox']\n\t\t\t>\n\t\t},\n\t\t// @ts-expect-error this is truly ideal\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\t{\n\t\t\tschema: Prettify<\n\t\t\t\tEphemeral['schema'] & Partial<NewElysia['~Ephemeral']['schema']>\n\t\t\t>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tPartial<NewElysia['~Ephemeral']['standaloneSchema']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\tPartial<NewElysia['~Ephemeral']['resolve']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tEphemeral['derive'] & Partial<NewElysia['~Ephemeral']['derive']>\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\tschema: Prettify<\n\t\t\t\tVolatile['schema'] & Partial<NewElysia['~Volatile']['schema']>\n\t\t\t>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\tPartial<NewElysia['~Volatile']['standaloneSchema']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tVolatile['resolve'] & Partial<NewElysia['~Volatile']['resolve']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tVolatile['derive'] & Partial<NewElysia['~Volatile']['derive']>\n\t\t\t>\n\t\t}\n\t>\n\n\t/**\n\t * Entire Instance\n\t **/\n\tuse<const NewElysia extends AnyElysia>(\n\t\tinstance: MaybePromise<NewElysia>\n\t): Elysia<\n\t\tBasePath,\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Singleton & NewElysia['~Singleton']>,\n\t\tPrettify2<Definitions & NewElysia['~Definitions']>,\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\tPrettify2<Volatile & NewElysia['~Ephemeral']>\n\t>\n\n\t/**\n\t * Entire multiple Instance\n\t **/\n\tuse<const Instances extends AnyElysia[]>(\n\t\tinstance: MaybePromise<Instances>\n\t): MergeElysiaInstances<Instances, BasePath>\n\n\t/**\n\t * Import fn\n\t */\n\tuse<const NewElysia extends AnyElysia>(\n\t\tplugin: Promise<{\n\t\t\tdefault: (elysia: AnyElysia) => MaybePromise<NewElysia>\n\t\t}>\n\t): Elysia<\n\t\tBasePath,\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Singleton & NewElysia['~Singleton']>,\n\t\t{\n\t\t\terror: Prettify<\n\t\t\t\tDefinitions['error'] & NewElysia['~Definitions']['error']\n\t\t\t>\n\t\t\ttypebox: Prettify<\n\t\t\t\tDefinitions['typebox'] & NewElysia['~Definitions']['typebox']\n\t\t\t>\n\t\t},\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\tPrettify2<Ephemeral & NewElysia['~Ephemeral']>,\n\t\tPrettify2<Volatile & NewElysia['~Volatile']>\n\t>\n\n\t/**\n\t * Import entire instance\n\t */\n\tuse<const LazyLoadElysia extends AnyElysia>(\n\t\tplugin: Promise<{\n\t\t\tdefault: LazyLoadElysia\n\t\t}>\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<\n\t\t\t\tSingleton['decorator'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['decorator']>\n\t\t\t>\n\t\t\tstore: Prettify<\n\t\t\t\tSingleton['store'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['store']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tSingleton['derive'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['derive']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['resolve']>\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\terror: Prettify<\n\t\t\t\tDefinitions['error'] & LazyLoadElysia['~Definitions']['error']\n\t\t\t>\n\t\t\ttypebox: Prettify<\n\t\t\t\tDefinitions['typebox'] &\n\t\t\t\t\tLazyLoadElysia['~Definitions']['typebox']\n\t\t\t>\n\t\t},\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Metadata & LazyLoadElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & LazyLoadElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, LazyLoadElysia['~Routes']>,\n\t\tEphemeral,\n\t\tPrettify2<{\n\t\t\tschema: Prettify<\n\t\t\t\tVolatile['schema'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['schema']>\n\t\t\t>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['standaloneSchema']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['resolve']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tVolatile['derive'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['derive']>\n\t\t\t>\n\t\t}>\n\t>\n\n\t/**\n\t * conditional undefined ignore type\n\t */\n\tuse(\n\t\tinstance:\n\t\t\t| MaybeArray<MaybePromise<AnyElysia>>\n\t\t\t| MaybePromise<\n\t\t\t\t\tAnyElysia | ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t >\n\t\t\t| Promise<{\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t| AnyElysia\n\t\t\t\t\t\t| ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t }>\n\t\t\t| undefined\n\t\t\t| false\n\t): this\n\n\t/**\n\t * ### use\n\t * Merge separate logic of Elysia with current\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * const plugin = (app: Elysia) => app\n\t * .get('/plugin', () => 'hi')\n\t *\n\t * new Elysia()\n\t * .use(plugin)\n\t * ```\n\t */\n\tuse(\n\t\tplugin:\n\t\t\t| MaybeArray<MaybePromise<AnyElysia>>\n\t\t\t| MaybePromise<\n\t\t\t\t\tAnyElysia | ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t >\n\t\t\t| Promise<{\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t| AnyElysia\n\t\t\t\t\t\t| ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t }>\n\t\t\t| undefined\n\t\t\t| false\n\t): AnyElysia {\n\t\tif (!plugin) return this\n\n\t\tif (Array.isArray(plugin)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\n\t\t\tlet app = this\n\t\t\tfor (const p of plugin) app = app.use(p) as any\n\t\t\treturn app\n\t\t}\n\n\t\tif (plugin instanceof Promise) {\n\t\t\tthis.promisedModules.add(\n\t\t\t\tplugin\n\t\t\t\t\t.then((plugin) => {\n\t\t\t\t\t\tif (typeof plugin === 'function') return plugin(this)\n\n\t\t\t\t\t\tif (plugin instanceof Elysia)\n\t\t\t\t\t\t\treturn this._use(plugin).compile()\n\n\t\t\t\t\t\tif (plugin.constructor.name === 'Elysia')\n\t\t\t\t\t\t\treturn this._use(\n\t\t\t\t\t\t\t\tplugin as unknown as Elysia\n\t\t\t\t\t\t\t).compile()\n\n\t\t\t\t\t\tif (typeof plugin.default === 'function')\n\t\t\t\t\t\t\treturn plugin.default(this)\n\n\t\t\t\t\t\tif (plugin.default instanceof Elysia)\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\n\t\t\t\t\t\tif (plugin.constructor.name === 'Elysia')\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\n\t\t\t\t\t\tif (plugin.constructor.name === '_Elysia')\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t'Invalid plugin type. Expected Elysia instance, function, or module with \"default\" as Elysia instance or function that returns Elysia instance.'\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tthrow error\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.then((v) => {\n\t\t\t\t\t\tif (v && typeof v.compile === 'function') v.compile()\n\n\t\t\t\t\t\treturn v\n\t\t\t\t\t})\n\t\t\t)\n\n\t\t\treturn this\n\t\t}\n\n\t\treturn this._use(plugin)\n\t}\n\n\tprivate propagatePromiseModules(plugin: Elysia) {\n\t\tif (plugin.promisedModules.size <= 0) return this\n\n\t\tfor (const promise of plugin.promisedModules.promises)\n\t\t\tthis.promisedModules.add(\n\t\t\t\tpromise.then((v) => {\n\t\t\t\t\tif (!v) return\n\n\t\t\t\t\tconst t = this._use(v)\n\t\t\t\t\tif (t instanceof Promise)\n\t\t\t\t\t\treturn t.then((v2) => {\n\t\t\t\t\t\t\tif (v2) v2.compile()\n\t\t\t\t\t\t\telse v.compile()\n\t\t\t\t\t\t})\n\n\t\t\t\t\treturn v.compile()\n\t\t\t\t})\n\t\t\t)\n\n\t\treturn this\n\t}\n\n\tprivate _use(\n\t\tplugin: AnyElysia | ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t) {\n\t\tif (typeof plugin === 'function') {\n\t\t\tconst instance = plugin(this as unknown as any) as unknown as any\n\n\t\t\tif (instance instanceof Promise) {\n\t\t\t\tthis.promisedModules.add(\n\t\t\t\t\tinstance\n\t\t\t\t\t\t.then((plugin) => {\n\t\t\t\t\t\t\tif (plugin instanceof Elysia) {\n\t\t\t\t\t\t\t\tplugin.getServer = () => this.getServer()\n\t\t\t\t\t\t\t\tplugin.getGlobalRoutes = () =>\n\t\t\t\t\t\t\t\t\tthis.getGlobalRoutes()\n\t\t\t\t\t\t\t\tplugin.getGlobalDefinitions = () =>\n\t\t\t\t\t\t\t\t\tthis.getGlobalDefinitions()\n\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Model and error is required for Swagger generation\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tplugin.model(this.definitions.type as any)\n\t\t\t\t\t\t\t\tplugin.error(this.definitions.error as any)\n\n\t\t\t\t\t\t\t\t// Recompile async plugin routes\n\t\t\t\t\t\t\t\tfor (const {\n\t\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\thandler,\n\t\t\t\t\t\t\t\t\thooks,\n\t\t\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t\t\t} of Object.values(plugin.router.history))\n\t\t\t\t\t\t\t\t\tthis.add(\n\t\t\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\t\thandler,\n\t\t\t\t\t\t\t\t\t\thooks,\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\tif (plugin === this) return\n\n\t\t\t\t\t\t\t\tthis.propagatePromiseModules(plugin)\n\n\t\t\t\t\t\t\t\treturn plugin\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (typeof plugin === 'function')\n\t\t\t\t\t\t\t\treturn plugin(\n\t\t\t\t\t\t\t\t\tthis as unknown as any\n\t\t\t\t\t\t\t\t) as unknown as Elysia\n\n\t\t\t\t\t\t\tif (typeof plugin.default === 'function')\n\t\t\t\t\t\t\t\treturn plugin.default(\n\t\t\t\t\t\t\t\t\tthis as unknown as any\n\t\t\t\t\t\t\t\t) as unknown as Elysia\n\n\t\t\t\t\t\t\treturn this._use(plugin)\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then((v) => {\n\t\t\t\t\t\t\tif (v && typeof v.compile === 'function')\n\t\t\t\t\t\t\t\tv.compile()\n\n\t\t\t\t\t\t\treturn v\n\t\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\treturn this as unknown as any\n\t\t\t}\n\n\t\t\treturn instance\n\t\t}\n\n\t\tthis.propagatePromiseModules(plugin)\n\n\t\tconst name = plugin.config.name\n\t\tconst seed = plugin.config.seed\n\n\t\tplugin.getParent = () => this as any\n\t\tplugin.getServer = () => this.getServer()\n\t\tplugin.getGlobalRoutes = () => this.getGlobalRoutes()\n\t\tplugin.getGlobalDefinitions = () => this.getGlobalDefinitions()\n\n\t\tif (plugin.standaloneValidator?.scoped) {\n\t\t\tif (this.standaloneValidator.local)\n\t\t\t\tthis.standaloneValidator.local =\n\t\t\t\t\tthis.standaloneValidator.local.concat(\n\t\t\t\t\t\tplugin.standaloneValidator.scoped\n\t\t\t\t\t)\n\t\t\telse\n\t\t\t\tthis.standaloneValidator.local =\n\t\t\t\t\tplugin.standaloneValidator.scoped\n\t\t}\n\n\t\tif (plugin.standaloneValidator?.global) {\n\t\t\tif (this.standaloneValidator.global)\n\t\t\t\tthis.standaloneValidator.global =\n\t\t\t\t\tthis.standaloneValidator.global.concat(\n\t\t\t\t\t\tplugin.standaloneValidator.global\n\t\t\t\t\t)\n\t\t\telse\n\t\t\t\tthis.standaloneValidator.global =\n\t\t\t\t\tplugin.standaloneValidator.global\n\t\t}\n\n\t\t/**\n\t\t * Model and error is required for Swagger generation\n\t\t */\n\t\t// plugin.model(this.definitions.type as any)\n\t\t// plugin.error(this.definitions.error as any)\n\n\t\tif (isNotEmpty(plugin['~parser']))\n\t\t\tthis['~parser'] = {\n\t\t\t\t...plugin['~parser'],\n\t\t\t\t...this['~parser']\n\t\t\t}\n\n\t\tif (plugin.setHeaders) this.headers(plugin.setHeaders)\n\n\t\tif (name) {\n\t\t\tif (!(name in this.dependencies)) this.dependencies[name] = []\n\n\t\t\tconst current =\n\t\t\t\tseed !== undefined ? checksum(name + JSON.stringify(seed)) : 0\n\n\t\t\tif (\n\t\t\t\t!this.dependencies[name].some(\n\t\t\t\t\t({ checksum }) => current === checksum\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthis.extender.macros = this.extender.macros.concat(\n\t\t\t\t\tplugin.extender.macros\n\t\t\t\t)\n\n\t\t\t\tthis.extender.higherOrderFunctions =\n\t\t\t\t\tthis.extender.higherOrderFunctions.concat(\n\t\t\t\t\t\tplugin.extender.higherOrderFunctions\n\t\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\tif (plugin.extender.macros.length)\n\t\t\t\tthis.extender.macros = this.extender.macros.concat(\n\t\t\t\t\tplugin.extender.macros\n\t\t\t\t)\n\n\t\t\tif (plugin.extender.higherOrderFunctions.length)\n\t\t\t\tthis.extender.higherOrderFunctions =\n\t\t\t\t\tthis.extender.higherOrderFunctions.concat(\n\t\t\t\t\t\tplugin.extender.higherOrderFunctions\n\t\t\t\t\t)\n\t\t}\n\n\t\t// ! Deduplicate current instance\n\t\tdeduplicateChecksum(this.extender.macros)\n\n\t\tif (plugin.extender.higherOrderFunctions.length) {\n\t\t\tdeduplicateChecksum(this.extender.higherOrderFunctions)\n\n\t\t\t// ! Deduplicate current instance\n\t\t\tconst hofHashes: number[] = []\n\t\t\tfor (\n\t\t\t\tlet i = 0;\n\t\t\t\ti < this.extender.higherOrderFunctions.length;\n\t\t\t\ti++\n\t\t\t) {\n\t\t\t\tconst hof = this.extender.higherOrderFunctions[i]\n\n\t\t\t\tif (hof.checksum) {\n\t\t\t\t\tif (hofHashes.includes(hof.checksum)) {\n\t\t\t\t\t\tthis.extender.higherOrderFunctions.splice(i, 1)\n\t\t\t\t\t\ti--\n\t\t\t\t\t}\n\n\t\t\t\t\thofHashes.push(hof.checksum)\n\t\t\t\t}\n\t\t\t}\n\t\t\thofHashes.length = 0\n\t\t}\n\n\t\tthis.inference = mergeInference(this.inference, plugin.inference)\n\n\t\tif (isNotEmpty(plugin.singleton.decorator))\n\t\t\tthis.decorate(plugin.singleton.decorator)\n\n\t\tif (isNotEmpty(plugin.singleton.store))\n\t\t\tthis.state(plugin.singleton.store)\n\n\t\tif (isNotEmpty(plugin.definitions.type))\n\t\t\tthis.model(plugin.definitions.type)\n\n\t\tif (isNotEmpty(plugin.definitions.error))\n\t\t\tthis.error(plugin.definitions.error as any)\n\n\t\tif (isNotEmpty(plugin.definitions.error))\n\t\t\tplugin.extender.macros = this.extender.macros.concat(\n\t\t\t\tplugin.extender.macros\n\t\t\t)\n\n\t\tfor (const {\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\thandler,\n\t\t\thooks,\n\t\t\tstandaloneValidators\n\t\t} of Object.values(plugin.router.history)) {\n\t\t\tthis.add(\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\thandler,\n\t\t\t\thooks,\n\t\t\t\tundefined,\n\t\t\t\tstandaloneValidators\n\t\t\t)\n\t\t}\n\n\t\tif (name) {\n\t\t\tif (!(name in this.dependencies)) this.dependencies[name] = []\n\n\t\t\tconst current =\n\t\t\t\tseed !== undefined ? checksum(name + JSON.stringify(seed)) : 0\n\n\t\t\tif (\n\t\t\t\tthis.dependencies[name].some(\n\t\t\t\t\t({ checksum }) => current === checksum\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn this\n\n\t\t\tthis.dependencies[name].push(\n\t\t\t\tthis.config?.analytic\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\tname: plugin.config.name,\n\t\t\t\t\t\t\tseed: plugin.config.seed,\n\t\t\t\t\t\t\tchecksum: current,\n\t\t\t\t\t\t\tdependencies: plugin.dependencies,\n\t\t\t\t\t\t\tstack: plugin.telemetry?.stack,\n\t\t\t\t\t\t\troutes: plugin.router.history,\n\t\t\t\t\t\t\tdecorators: plugin.singleton,\n\t\t\t\t\t\t\tstore: plugin.singleton.store,\n\t\t\t\t\t\t\terror: plugin.definitions.error,\n\t\t\t\t\t\t\tderive: plugin.event.transform\n\t\t\t\t\t\t\t\t?.filter((x) => x?.subType === 'derive')\n\t\t\t\t\t\t\t\t.map((x) => ({\n\t\t\t\t\t\t\t\t\tfn: x.toString(),\n\t\t\t\t\t\t\t\t\tstack: new Error().stack ?? ''\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tresolve: plugin.event.transform\n\t\t\t\t\t\t\t\t?.filter((x) => x?.subType === 'resolve')\n\t\t\t\t\t\t\t\t.map((x) => ({\n\t\t\t\t\t\t\t\t\tfn: x.toString(),\n\t\t\t\t\t\t\t\t\tstack: new Error().stack ?? ''\n\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t} as any)\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tname: plugin.config.name,\n\t\t\t\t\t\t\tseed: plugin.config.seed,\n\t\t\t\t\t\t\tchecksum: current,\n\t\t\t\t\t\t\tdependencies: plugin.dependencies\n\t\t\t\t\t\t}\n\t\t\t)\n\n\t\t\tif (isNotEmpty(plugin.event))\n\t\t\t\tthis.event = mergeLifeCycle(\n\t\t\t\t\tthis.event,\n\t\t\t\t\tfilterGlobalHook(plugin.event),\n\t\t\t\t\tcurrent\n\t\t\t\t)\n\t\t} else {\n\t\t\tif (isNotEmpty(plugin.event))\n\t\t\t\tthis.event = mergeLifeCycle(\n\t\t\t\t\tthis.event,\n\t\t\t\t\tfilterGlobalHook(plugin.event)\n\t\t\t\t)\n\t\t}\n\n\t\tif (plugin.validator.global)\n\t\t\t// @ts-ignore\n\t\t\tthis.validator.global = mergeHook(this.validator.global, {\n\t\t\t\t...plugin.validator.global\n\t\t\t}) as any\n\n\t\tif (plugin.validator.scoped)\n\t\t\t// @ts-ignore\n\t\t\tthis.validator.local = mergeHook(this.validator.local, {\n\t\t\t\t...plugin.validator.scoped\n\t\t\t})\n\n\t\treturn this\n\t}\n\n\tmacro<const NewMacro extends BaseMacroFn>(\n\t\tmacro: (\n\t\t\troute: MacroManager<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Partial<Ephemeral['derive'] & Volatile['derive']>\n\t\t\t\t\tresolve: Partial<Ephemeral['resolve'] & Volatile['resolve']>\n\t\t\t\t},\n\t\t\t\tDefinitions['error']\n\t\t\t>\n\t\t) => NewMacro\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: Metadata['schema']\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro'] & Partial<MacroToProperty<NewMacro>>\n\t\t\tmacroFn: Metadata['macroFn'] & NewMacro\n\t\t\tparser: Metadata['parser']\n\t\t},\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmacro<\n\t\tconst NewMacro extends HookMacroFn<\n\t\t\tMetadata['schema'],\n\t\t\tSingleton & {\n\t\t\t\tderive: Partial<Ephemeral['derive'] & Volatile['derive']>\n\t\t\t\tresolve: Partial<Ephemeral['resolve'] & Volatile['resolve']>\n\t\t\t},\n\t\t\tDefinitions['error']\n\t\t>\n\t>(\n\t\tmacro: NewMacro\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: Metadata['schema']\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro'] & Partial<MacroToProperty<NewMacro>>\n\t\t\tmacroFn: Metadata['macroFn'] & NewMacro\n\t\t\tparser: Metadata['parser']\n\t\t},\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmacro(macro: Function | Record<keyof any, Function>) {\n\t\tif (typeof macro === 'function') {\n\t\t\tconst hook: MacroQueue = {\n\t\t\t\tchecksum: checksum(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tname: this.config.name,\n\t\t\t\t\t\tseed: this.config.seed,\n\t\t\t\t\t\tcontent: macro.toString()\n\t\t\t\t\t})\n\t\t\t\t),\n\t\t\t\tfn: macro as any\n\t\t\t}\n\n\t\t\tthis.extender.macros.push(hook)\n\t\t} else if (typeof macro === 'object') {\n\t\t\tfor (const name of Object.keys(macro))\n\t\t\t\tif (typeof macro[name] === 'object') {\n\t\t\t\t\tconst actualValue = { ...(macro[name] as Object) }\n\n\t\t\t\t\tmacro[name] = (v: boolean) => {\n\t\t\t\t\t\tif (v === true) return actualValue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tconst hook: MacroQueue = {\n\t\t\t\tchecksum: checksum(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tname: this.config.name,\n\t\t\t\t\t\tseed: this.config.seed,\n\t\t\t\t\t\tcontent: Object.entries(macro)\n\t\t\t\t\t\t\t.map(([k, v]) => `${k}+${v}`)\n\t\t\t\t\t\t\t.join(',')\n\t\t\t\t\t})\n\t\t\t\t),\n\t\t\t\tfn: () => macro\n\t\t\t}\n\n\t\t\tthis.extender.macros.push(hook)\n\t\t}\n\n\t\treturn this as any\n\t}\n\n\tmount(\n\t\thandle: ((request: Request) => MaybePromise<Response>) | AnyElysia,\n\t\tdetail?: { detail?: DocumentDecoration }\n\t): this\n\tmount(\n\t\tpath: string,\n\t\thandle: ((request: Request) => MaybePromise<Response>) | AnyElysia,\n\t\tdetail?: { detail?: DocumentDecoration }\n\t): this\n\n\tmount(\n\t\tpath:\n\t\t\t| string\n\t\t\t| ((request: Request) => MaybePromise<Response>)\n\t\t\t| AnyElysia,\n\t\thandleOrConfig?:\n\t\t\t| ((request: Request) => MaybePromise<Response>)\n\t\t\t| AnyElysia\n\t\t\t| { detail?: DocumentDecoration },\n\t\tconfig?: { detail?: DocumentDecoration }\n\t) {\n\t\tif (\n\t\t\tpath instanceof Elysia ||\n\t\t\ttypeof path === 'function' ||\n\t\t\tpath.length === 0 ||\n\t\t\tpath === '/'\n\t\t) {\n\t\t\tconst run =\n\t\t\t\ttypeof path === 'function'\n\t\t\t\t\t? path\n\t\t\t\t\t: path instanceof Elysia\n\t\t\t\t\t\t? path.compile().fetch\n\t\t\t\t\t\t: handleOrConfig instanceof Elysia\n\t\t\t\t\t\t\t? handleOrConfig.compile().fetch\n\t\t\t\t\t\t\t: typeof handleOrConfig === 'function'\n\t\t\t\t\t\t\t\t? handleOrConfig\n\t\t\t\t\t\t\t\t: (() => {\n\t\t\t\t\t\t\t\t\t\tthrow new Error('Invalid handler')\n\t\t\t\t\t\t\t\t\t})()\n\n\t\t\tconst handler: Handler = ({ request, path }) =>\n\t\t\t\trun(\n\t\t\t\t\tnew Request(replaceUrlPath(request.url, path), {\n\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\tcredentials: request.credentials,\n\t\t\t\t\t\treferrerPolicy: request.referrerPolicy as any,\n\t\t\t\t\t\tduplex: request.duplex,\n\t\t\t\t\t\tredirect: request.redirect,\n\t\t\t\t\t\tmode: request.mode,\n\t\t\t\t\t\tkeepalive: request.keepalive,\n\t\t\t\t\t\tintegrity: request.integrity,\n\t\t\t\t\t\tbody: request.body\n\t\t\t\t\t})\n\t\t\t\t)\n\n\t\t\tthis.route('ALL', '/*', handler as any, {\n\t\t\t\tparse: 'none',\n\t\t\t\t...config,\n\t\t\t\tdetail: {\n\t\t\t\t\t...config?.detail,\n\t\t\t\t\thide: true\n\t\t\t\t},\n\t\t\t\tconfig: {\n\t\t\t\t\tmount: run\n\t\t\t\t}\n\t\t\t})\n\n\t\t\treturn this\n\t\t}\n\n\t\tconst handle =\n\t\t\thandleOrConfig instanceof Elysia\n\t\t\t\t? handleOrConfig.compile().fetch\n\t\t\t\t: typeof handleOrConfig === 'function'\n\t\t\t\t\t? handleOrConfig\n\t\t\t\t\t: (() => {\n\t\t\t\t\t\t\tthrow new Error('Invalid handler')\n\t\t\t\t\t\t})()\n\n\t\tconst length = path.length - (path.endsWith('*') ? 1 : 0)\n\n\t\tconst handler: Handler = ({ request, path }) =>\n\t\t\thandle(\n\t\t\t\tnew Request(\n\t\t\t\t\treplaceUrlPath(request.url, path.slice(length) || '/'),\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\tcredentials: request.credentials,\n\t\t\t\t\t\treferrerPolicy: request.referrerPolicy as any,\n\t\t\t\t\t\tduplex: request.duplex,\n\t\t\t\t\t\tredirect: request.redirect,\n\t\t\t\t\t\tmode: request.mode,\n\t\t\t\t\t\tkeepalive: request.keepalive,\n\t\t\t\t\t\tintegrity: request.integrity,\n\t\t\t\t\t\tbody: request.body\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t)\n\n\t\tthis.route('ALL', path, handler as any, {\n\t\t\tparse: 'none',\n\t\t\t...config,\n\t\t\tdetail: {\n\t\t\t\t...config?.detail,\n\t\t\t\thide: true\n\t\t\t},\n\t\t\tconfig: {\n\t\t\t\tmount: handle\n\t\t\t}\n\t\t})\n\n\t\tthis.route(\n\t\t\t'ALL',\n\t\t\tpath + (path.endsWith('/') ? '*' : '/*'),\n\t\t\thandler as any,\n\t\t\t{\n\t\t\t\tparse: 'none',\n\t\t\t\t...config,\n\t\t\t\tdetail: {\n\t\t\t\t\t...config?.detail,\n\t\t\t\t\thide: true\n\t\t\t\t},\n\t\t\t\tconfig: {\n\t\t\t\t\tmount: handle\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### get\n\t * Register handler for path with method [GET]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .get('/', () => 'hi')\n\t * .get('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tget<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tget: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('GET', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### post\n\t * Register handler for path with method [POST]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .post('/', () => 'hi')\n\t * .post('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tpost<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tpost: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('POST', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### put\n\t * Register handler for path with method [PUT]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .put('/', () => 'hi')\n\t * .put('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tput<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tput: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('PUT', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### patch\n\t * Register handler for path with method [PATCH]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .patch('/', () => 'hi')\n\t * .patch('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tpatch<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tpatch: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('PATCH', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### delete\n\t * Register handler for path with method [DELETE]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .delete('/', () => 'hi')\n\t * .delete('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tdelete<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tdelete: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('DELETE', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### options\n\t * Register handler for path with method [POST]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .options('/', () => 'hi')\n\t * .options('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\toptions<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('OPTIONS', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### all\n\t * Register handler for path with method [ALL]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .all('/', () => 'hi')\n\t * .all('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tall<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\t[method in string]: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('ALL', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### head\n\t * Register handler for path with method [HEAD]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .head('/', () => 'hi')\n\t * .head('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\thead<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\thead: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('HEAD', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### connect\n\t * Register handler for path with method [CONNECT]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .connect('/', () => 'hi')\n\t * .connect('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tconnect<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tconnect: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('CONNECT', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### route\n\t * Register handler for path with method [ROUTE]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .route('/', () => 'hi')\n\t * .route('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\troute<\n\t\tconst Method extends HTTPMethod,\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tmethod: Method,\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t> & {\n\t\t\tconfig?: {\n\t\t\t\tallowMeta?: boolean\n\t\t\t\tmount?: Function\n\t\t\t}\n\t\t}\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\t[method in Method]: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add(method.toUpperCase(), path, handler as any, hook, hook?.config)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### ws\n\t * Register handler for path with method [ws]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .ws('/', {\n\t * message(ws, message) {\n\t * ws.send(message)\n\t * }\n\t * })\n\t * ```\n\t */\n\tws<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t>,\n\t\tconst Macro extends Metadata['macro']\n\t>(\n\t\tpath: Path,\n\t\toptions: WSLocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t\t},\n\t\t\tMacro\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tsubscribe: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: {} extends Schema['response']\n\t\t\t\t\t\t\t? unknown\n\t\t\t\t\t\t\t: Schema['response'] extends { [200]: any }\n\t\t\t\t\t\t\t\t? Schema['response'][200]\n\t\t\t\t\t\t\t\t: unknown\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tif (this['~adapter'].ws) this['~adapter'].ws(this, path, options as any)\n\t\telse console.warn(`Current adapter doesn't support WebSocket`)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state('counter', 0)\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<const Name extends string | number | symbol, Value>(\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Prettify<\n\t\t\t\tSingleton['store'] & {\n\t\t\t\t\t[name in Name]: Value\n\t\t\t\t}\n\t\t\t>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state({ counter: 0 })\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<Store extends Record<string, unknown>>(\n\t\tstore: Store\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Prettify<Singleton['store'] & Store>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state('counter', 0)\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<\n\t\tconst Type extends ContextAppendType,\n\t\tconst Name extends string | number | symbol,\n\t\tValue\n\t>(\n\t\toptions: { as: Type },\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Type extends 'override'\n\t\t\t\t? Reconcile<\n\t\t\t\t\t\tSingleton['store'],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue\n\t\t\t\t\t>\n\t\t\t\t: Prettify<\n\t\t\t\t\t\tSingleton['store'] & {\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state({ counter: 0 })\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<\n\t\tconst Type extends ContextAppendType,\n\t\tStore extends Record<string, unknown>\n\t>(\n\t\toptions: { as: Type },\n\t\tstore: Store\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Type extends 'override'\n\t\t\t\t? Reconcile<Singleton['store'], Store>\n\t\t\t\t: Prettify<Singleton['store'] & Store>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tstate<NewStore extends Record<string, unknown>>(\n\t\tmapper: (decorators: Singleton['store']) => NewStore\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: NewStore\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state('counter', 0)\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate(\n\t\toptions:\n\t\t\t| { as: ContextAppendType }\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function,\n\t\tname?:\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function\n\t\t\t| { as: ContextAppendType },\n\t\tvalue?: unknown\n\t) {\n\t\tif (name === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ name: value })\n\t\t\t */\n\t\t\tvalue = options\n\t\t\toptions = { as: 'append' }\n\t\t\tname = ''\n\t\t} else if (value === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ as: 'override' }, { name: value })\n\t\t\t * - decorate('name', value)\n\t\t\t */\n\n\t\t\t// decorate('name', value)\n\t\t\tif (typeof options === 'string') {\n\t\t\t\tvalue = name\n\t\t\t\tname = options\n\t\t\t\toptions = { as: 'append' }\n\t\t\t} else if (typeof options === 'object') {\n\t\t\t\t// decorate({ as: 'override' }, { name: value })\n\t\t\t\tvalue = name\n\t\t\t\tname = ''\n\t\t\t}\n\t\t}\n\n\t\tconst { as } = options as { as: ContextAppendType }\n\n\t\tif (typeof name !== 'string') return this\n\n\t\tswitch (typeof value) {\n\t\t\tcase 'object':\n\t\t\t\tif (!value || !isNotEmpty(value)) return this\n\n\t\t\t\tif (name) {\n\t\t\t\t\tif (name in this.singleton.store)\n\t\t\t\t\t\tthis.singleton.store[name] = mergeDeep(\n\t\t\t\t\t\t\tthis.singleton.store[name] as any,\n\t\t\t\t\t\t\tvalue!,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toverride: as === 'override'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\telse this.singleton.store[name] = value\n\n\t\t\t\t\treturn this\n\t\t\t\t}\n\n\t\t\t\tif (value === null) return this\n\n\t\t\t\tthis.singleton.store = mergeDeep(this.singleton.store, value, {\n\t\t\t\t\toverride: as === 'override'\n\t\t\t\t})\n\n\t\t\t\treturn this as any\n\n\t\t\tcase 'function':\n\t\t\t\tif (name) {\n\t\t\t\t\tif (as === 'override' || !(name in this.singleton.store))\n\t\t\t\t\t\tthis.singleton.store[name] = value\n\t\t\t\t} else this.singleton.store = value(this.singleton.store)\n\n\t\t\t\treturn this as any\n\n\t\t\tdefault:\n\t\t\t\tif (as === 'override' || !(name in this.singleton.store))\n\t\t\t\t\tthis.singleton.store[name] = value\n\n\t\t\t\treturn this\n\t\t}\n\t}\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<const Name extends string, Value>(\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<\n\t\t\t\tSingleton['decorator'] & {\n\t\t\t\t\t[name in Name]: Value\n\t\t\t\t}\n\t\t\t>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<NewDecorators extends Record<string, unknown>>(\n\t\tdecorators: NewDecorators\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<Singleton['decorator'] & NewDecorators>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tdecorate<NewDecorators extends Record<string, unknown>>(\n\t\tmapper: (decorators: Singleton['decorator']) => NewDecorators\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: NewDecorators\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate({ as: 'override' }, 'getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<\n\t\tconst Type extends ContextAppendType,\n\t\tconst Name extends string,\n\t\tValue\n\t>(\n\t\toptions: { as: Type },\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Type extends 'override'\n\t\t\t\t? Reconcile<\n\t\t\t\t\t\tSingleton['decorator'],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue\n\t\t\t\t\t>\n\t\t\t\t: Prettify<\n\t\t\t\t\t\tSingleton['decorator'] & {\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<\n\t\tconst Type extends ContextAppendType,\n\t\tNewDecorators extends Record<string, unknown>\n\t>(\n\t\toptions: { as: Type },\n\t\tdecorators: NewDecorators\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Type extends 'override'\n\t\t\t\t? Reconcile<Singleton['decorator'], NewDecorators, true>\n\t\t\t\t: Prettify<Singleton['decorator'] & NewDecorators>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate(\n\t\toptions:\n\t\t\t| { as: ContextAppendType }\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function,\n\t\tname?:\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function\n\t\t\t| { as: ContextAppendType },\n\t\tvalue?: unknown\n\t) {\n\t\tif (name === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ name: value })\n\t\t\t */\n\t\t\tvalue = options\n\t\t\toptions = { as: 'append' }\n\t\t\tname = ''\n\t\t} else if (value === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ as: 'override' }, { name: value })\n\t\t\t * - decorate('name', value)\n\t\t\t */\n\n\t\t\t// decorate('name', value)\n\t\t\tif (typeof options === 'string') {\n\t\t\t\tvalue = name\n\t\t\t\tname = options\n\t\t\t\toptions = { as: 'append' }\n\t\t\t} else if (typeof options === 'object') {\n\t\t\t\t// decorate({ as: 'override' }, { name: value })\n\t\t\t\tvalue = name\n\t\t\t\tname = ''\n\t\t\t}\n\t\t}\n\n\t\tconst { as } = options as { as: ContextAppendType }\n\n\t\tif (typeof name !== 'string') return this\n\n\t\tswitch (typeof value) {\n\t\t\tcase 'object':\n\t\t\t\tif (name) {\n\t\t\t\t\tif (name in this.singleton.decorator)\n\t\t\t\t\t\tthis.singleton.decorator[name] = mergeDeep(\n\t\t\t\t\t\t\tthis.singleton.decorator[name] as any,\n\t\t\t\t\t\t\tvalue!,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toverride: as === 'override'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\telse this.singleton.decorator[name] = value\n\n\t\t\t\t\treturn this\n\t\t\t\t}\n\n\t\t\t\tif (value === null) return this\n\n\t\t\t\tthis.singleton.decorator = mergeDeep(\n\t\t\t\t\tthis.singleton.decorator,\n\t\t\t\t\tvalue,\n\t\t\t\t\t{\n\t\t\t\t\t\toverride: as === 'override'\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\t\treturn this as any\n\n\t\t\tcase 'function':\n\t\t\t\tif (name) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tas === 'override' ||\n\t\t\t\t\t\t!(name in this.singleton.decorator)\n\t\t\t\t\t)\n\t\t\t\t\t\tthis.singleton.decorator[name] = value\n\t\t\t\t} else\n\t\t\t\t\tthis.singleton.decorator = value(this.singleton.decorator)\n\n\t\t\t\treturn this as any\n\n\t\t\tdefault:\n\t\t\t\tif (as === 'override' || !(name in this.singleton.decorator))\n\t\t\t\t\tthis.singleton.decorator[name] = value\n\n\t\t\t\treturn this\n\t\t}\n\t}\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tderive<\n\t\tconst Derivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t\t\t| void\n\t>(\n\t\ttransform: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t\tSingleton & {\n\t\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Derivative>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Prettify<\n\t\t\t\tVolatile['derive'] & ExcludeElysiaResponse<Derivative>\n\t\t\t>\n\t\t\tresolve: Volatile['resolve']\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tderive<\n\t\tconst Derivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t\t\t| void,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\ttransform: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t\t'global' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\tSingleton &\n\t\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\tBasePath\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Derivative>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\tSingleton['derive'] & ExcludeElysiaResponse<Derivative>\n\t\t\t\t\t>\n\t\t\t\t\tresolve: Singleton['resolve']\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Derivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tresolve: Ephemeral['resolve']\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\t\tVolatile['derive'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Derivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tresolve: Ephemeral['resolve']\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\tderive(\n\t\toptionsOrTransform: { as?: LifeCycleType } | Function,\n\t\ttransform?: Function\n\t) {\n\t\tif (!transform) {\n\t\t\ttransform = optionsOrTransform as any\n\t\t\toptionsOrTransform = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'derive',\n\t\t\tfn: transform!\n\t\t}\n\n\t\treturn this.onTransform(optionsOrTransform as any, hook as any) as any\n\t}\n\n\tmodel<const Name extends string, const Model extends TSchema>(\n\t\tname: Name,\n\t\tmodel: Model\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox'] & {\n\t\t\t\t[name in Name]: Model\n\t\t\t}\n\t\t\terror: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmodel<const Recorder extends TProperties>(\n\t\trecord: Recorder\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox'] & Recorder\n\t\t\terror: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmodel<const NewType extends Record<string, TSchema>>(\n\t\tmapper: (\n\t\t\tdecorators: Definitions['typebox'] extends infer Models extends\n\t\t\t\tRecord<string, TSchema>\n\t\t\t\t? {\n\t\t\t\t\t\t[type in keyof Models]: TRef<// @ts-ignore\n\t\t\t\t\t\ttype>\n\t\t\t\t\t}\n\t\t\t\t: {}\n\t\t) => NewType\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: {\n\t\t\t\t[key in keyof NewType]: NewType[key] extends TRef<key & string>\n\t\t\t\t\t? // @ts-expect-error\n\t\t\t\t\t\tDefinitions['typebox'][key]\n\t\t\t\t\t: NewType[key]\n\t\t\t}\n\t\t\ttype: { [x in keyof NewType]: Static<NewType[x]> }\n\t\t\terror: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmodel(name: string | Record<string, TSchema> | Function, model?: TSchema) {\n\t\tswitch (typeof name) {\n\t\t\tcase 'object':\n\t\t\t\tconst parsedSchemas = {} as Record<string, TSchema>\n\n\t\t\t\tconst kvs = Object.entries(name)\n\n\t\t\t\tif (!kvs.length) return this\n\n\t\t\t\tfor (const [key, value] of kvs) {\n\t\t\t\t\tif (key in this.definitions.type) continue\n\n\t\t\t\t\tparsedSchemas[key] = this.definitions.type[key] = value\n\t\t\t\t\tparsedSchemas[key].$id ??= `#/components/schemas/${key}`\n\t\t\t\t}\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tthis.definitions.typebox = t.Module({\n\t\t\t\t\t...(this.definitions.typebox['$defs'] as TModule<{}>),\n\t\t\t\t\t...parsedSchemas\n\t\t\t\t} as any)\n\n\t\t\t\treturn this\n\n\t\t\tcase 'function':\n\t\t\t\tconst result = name(this.definitions.type)\n\t\t\t\tthis.definitions.type = result\n\t\t\t\tthis.definitions.typebox = t.Module(result as any)\n\n\t\t\t\treturn this as any\n\n\t\t\tcase 'string':\n\t\t\t\tif (!model) break\n\n\t\t\t\tconst newModel = {\n\t\t\t\t\t...model,\n\t\t\t\t\tid: model.$id ?? `#/components/schemas/${name}`\n\t\t\t\t}\n\n\t\t\t\tthis.definitions.type[name] = model\n\t\t\t\tthis.definitions.typebox = t.Module({\n\t\t\t\t\t...(this.definitions.typebox['$defs'] as TModule<{}>),\n\t\t\t\t\t...newModel\n\t\t\t\t} as any)\n\t\t\t\treturn this as any\n\t\t}\n\n\t\t;(this.definitions.type as Record<string, TSchema>)[name] = model!\n\t\tthis.definitions.typebox = t.Module({\n\t\t\t...this.definitions.typebox['$defs'],\n\t\t\t[name]: model!\n\t\t} as any)\n\n\t\treturn this as any\n\t}\n\n\tRef<K extends keyof Definitions['typebox'] & string>(key: K) {\n\t\treturn t.Ref(key)\n\t}\n\n\tmapDerive<\n\t\tconst NewDerivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t>(\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\t{},\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t},\n\t\t\t\tBasePath\n\t\t\t>\n\t\t) => MaybePromise<NewDerivative>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: ExcludeElysiaResponse<NewDerivative>\n\t\t\tresolve: Volatile['resolve']\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\tmapDerive<\n\t\tconst NewDerivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\t{},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t}),\n\t\t\t\tBasePath\n\t\t\t>\n\t\t) => MaybePromise<NewDerivative>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\t\t\tExcludeElysiaResponse<NewDerivative>\n\t\t\t\t\t>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewDerivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewDerivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\tmapDerive(\n\t\toptionsOrDerive: { as?: LifeCycleType } | Function,\n\t\tmapper?: Function\n\t) {\n\t\tif (!mapper) {\n\t\t\tmapper = optionsOrDerive as any\n\t\t\toptionsOrDerive = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'mapDerive',\n\t\t\tfn: mapper!\n\t\t}\n\n\t\treturn this.onTransform(optionsOrDerive as any, hook as any) as any\n\t}\n\n\taffix<\n\t\tconst Base extends 'prefix' | 'suffix',\n\t\tconst Type extends 'all' | 'decorator' | 'state' | 'model' | 'error',\n\t\tconst Word extends string\n\t>(\n\t\tbase: Base,\n\t\ttype: Type,\n\t\tword: Word\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Type extends 'decorator' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['decorator']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['decorator']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Singleton['decorator']>\n\t\t\t\t: Singleton['decorator']\n\t\t\tstore: Type extends 'state' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['store']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['store']>\n\t\t\t\t\t: AddSuffix<Word, Singleton['store']>\n\t\t\t\t: Singleton['store']\n\t\t\tderive: Type extends 'decorator' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['derive']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['derive']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Singleton['derive']>\n\t\t\t\t: Singleton['derive']\n\t\t\tresolve: Type extends 'decorator' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['resolve']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['resolve']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Singleton['resolve']>\n\t\t\t\t: Singleton['resolve']\n\t\t},\n\t\t{\n\t\t\ttypebox: Type extends 'model' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Definitions['typebox']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Definitions['typebox']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Definitions['typebox']>\n\t\t\t\t: Definitions['typebox']\n\t\t\terror: Type extends 'error' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Definitions['error']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Definitions['error']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Definitions['error']>\n\t\t\t\t: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tif (word === '') return this as any\n\n\t\tconst delimieter = ['_', '-', ' ']\n\t\tconst capitalize = (word: string) =>\n\t\t\tword[0].toUpperCase() + word.slice(1)\n\n\t\tconst joinKey =\n\t\t\tbase === 'prefix'\n\t\t\t\t? (prefix: string, word: string) =>\n\t\t\t\t\t\tdelimieter.includes(prefix.at(-1) ?? '')\n\t\t\t\t\t\t\t? prefix + word\n\t\t\t\t\t\t\t: prefix + capitalize(word)\n\t\t\t\t: delimieter.includes(word.at(-1) ?? '')\n\t\t\t\t\t? (suffix: string, word: string) => word + suffix\n\t\t\t\t\t: (suffix: string, word: string) =>\n\t\t\t\t\t\t\tword + capitalize(suffix)\n\n\t\tconst remap = (type: 'decorator' | 'state' | 'model' | 'error') => {\n\t\t\tconst store: Record<string, any> = {}\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'decorator':\n\t\t\t\t\tfor (const key in this.singleton.decorator) {\n\t\t\t\t\t\tstore[joinKey(word, key)] =\n\t\t\t\t\t\t\tthis.singleton.decorator[key]\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.singleton.decorator = store\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'state':\n\t\t\t\t\tfor (const key in this.singleton.store)\n\t\t\t\t\t\tstore[joinKey(word, key)] = this.singleton.store[key]\n\n\t\t\t\t\tthis.singleton.store = store\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'model':\n\t\t\t\t\tfor (const key in this.definitions.type)\n\t\t\t\t\t\tstore[joinKey(word, key)] = this.definitions.type[key]\n\n\t\t\t\t\tthis.definitions.type = store\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'error':\n\t\t\t\t\tfor (const key in this.definitions.error)\n\t\t\t\t\t\tstore[joinKey(word, key)] = this.definitions.error[key]\n\n\t\t\t\t\tthis.definitions.error = store\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst types = Array.isArray(type) ? type : [type]\n\n\t\tfor (const type of types.some((x) => x === 'all')\n\t\t\t? ['decorator', 'state', 'model', 'error']\n\t\t\t: types)\n\t\t\tremap(type as 'decorator')\n\n\t\treturn this as any\n\t}\n\n\tprefix<\n\t\tconst Type extends 'all' | 'decorator' | 'state' | 'model' | 'error',\n\t\tconst Word extends string\n\t>(type: Type, word: Word) {\n\t\treturn this.affix('prefix', type, word)\n\t}\n\n\tsuffix<\n\t\tconst Type extends 'all' | 'decorator' | 'state' | 'model' | 'error',\n\t\tconst Word extends string\n\t>(type: Type, word: Word) {\n\t\treturn this.affix('suffix', type, word)\n\t}\n\n\tcompile() {\n\t\tif (this['~adapter'].isWebStandard) {\n\t\t\tthis.fetch = this.config.aot\n\t\t\t\t? composeGeneralHandler(this)\n\t\t\t\t: createDynamicHandler(this)\n\n\t\t\tif (typeof this.server?.reload === 'function')\n\t\t\t\tthis.server.reload({\n\t\t\t\t\t...(this.server || {}),\n\t\t\t\t\tfetch: this.fetch\n\t\t\t\t})\n\n\t\t\treturn this\n\t\t}\n\n\t\tif (typeof this.server?.reload === 'function')\n\t\t\tthis.server.reload(this.server || {})\n\n\t\tthis._handle = composeGeneralHandler(this)\n\n\t\treturn this\n\t}\n\n\thandle = async (request: Request) => this.fetch(request)\n\n\t/**\n\t * Use handle can be either sync or async to save performance.\n\t *\n\t * Beside benchmark purpose, please use 'handle' instead.\n\t */\n\tfetch = (request: Request): MaybePromise<Response> => {\n\t\treturn (this.fetch = this.config.aot\n\t\t\t? composeGeneralHandler(this)\n\t\t\t: createDynamicHandler(this))(request)\n\t}\n\n\t/**\n\t * Custom handle written by adapter\n\t */\n\tprotected _handle?(...a: unknown[]): unknown\n\n\tprotected handleError = async (\n\t\tcontext: Partial<\n\t\t\tContext<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t},\n\t\t\t\tBasePath\n\t\t\t>\n\t\t> & {\n\t\t\trequest: Request\n\t\t},\n\t\terror:\n\t\t\t| Error\n\t\t\t| ValidationError\n\t\t\t| ParseError\n\t\t\t| NotFoundError\n\t\t\t| InternalServerError\n\t) => {\n\t\treturn (this.handleError = this.config.aot\n\t\t\t? composeErrorHandler(this)\n\t\t\t: createDynamicErrorHandler(this))(context, error)\n\t}\n\n\t/**\n\t * ### listen\n\t * Assign current instance to port and start serving\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .get(\"/\", () => 'hi')\n\t * .listen(3000)\n\t * ```\n\t */\n\tlisten = (\n\t\toptions: string | number | Partial<Serve>,\n\t\tcallback?: ListenCallback\n\t) => {\n\t\tthis['~adapter'].listen(this)(options, callback)\n\n\t\tif (this.promisedModules.size) clearSucroseCache(5000)\n\n\t\tthis.promisedModules.then(() => {\n\t\t\tclearSucroseCache(1000)\n\t\t})\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### stop\n\t * Stop server from serving\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * const app = new Elysia()\n\t * .get(\"/\", () => 'hi')\n\t * .listen(3000)\n\t *\n\t * // Sometime later\n\t * app.stop()\n\t * ```\n\t *\n\t * @example\n\t * ```typescript\n\t * const app = new Elysia()\n\t * .get(\"/\", () => 'hi')\n\t * .listen(3000)\n\t *\n\t * app.stop(true) // Abruptly any requests inflight\n\t * ```\n\t */\n\tstop = async (closeActiveConnections?: boolean) => {\n\t\tawait this['~adapter'].stop?.(this, closeActiveConnections)\n\n\t\treturn this\n\t};\n\n\t[Symbol.dispose] = () => {\n\t\tif (this.server) this.stop()\n\t}\n\n\t/**\n\t * Wait until all lazy loaded modules all load is fully\n\t */\n\tget modules() {\n\t\treturn this.promisedModules\n\t}\n}\n\nexport { Elysia }\n\nexport { t } from './type-system'\nexport { validationDetail } from './type-system/utils'\nexport type {\n\tElysiaTypeCustomError,\n\tElysiaTypeCustomErrorCallback\n} from './type-system/types'\n\nexport { serializeCookie, Cookie, type CookieOptions } from './cookies'\nexport type { Context, PreContext, ErrorContext } from './context'\nexport {\n\tELYSIA_TRACE,\n\ttype TraceEvent,\n\ttype TraceListener,\n\ttype TraceHandler,\n\ttype TraceProcess,\n\ttype TraceStream\n} from './trace'\n\nexport {\n\tgetSchemaValidator,\n\tgetResponseSchemaValidator,\n\treplaceSchemaType\n} from './schema'\n\nexport {\n\tmergeHook,\n\tmergeObjectArray,\n\tredirect,\n\tStatusMap,\n\tInvertedStatusMap,\n\tform,\n\treplaceUrlPath,\n\tchecksum,\n\tcloneInference,\n\tdeduplicateChecksum,\n\tELYSIA_FORM_DATA,\n\tELYSIA_REQUEST_ID,\n\tsse\n} from './utils'\n\nexport {\n\tstatus,\n\terror,\n\tmapValueError,\n\tParseError,\n\tNotFoundError,\n\tValidationError,\n\tInternalServerError,\n\tInvalidCookieSignature,\n\tERROR_CODE,\n\tElysiaCustomStatusResponse\n} from './error'\n\nexport type {\n\tEphemeralType,\n\tCreateEden,\n\tComposeElysiaResponse,\n\tElysiaConfig,\n\tSingletonBase,\n\tDefinitionBase,\n\tRouteBase,\n\tHandler,\n\tComposedHandler,\n\tInputSchema,\n\tLocalHook,\n\tMergeSchema,\n\tRouteSchema,\n\tUnwrapRoute,\n\tInternalRoute,\n\tHTTPMethod,\n\tSchemaValidator,\n\tVoidHandler,\n\tPreHandler,\n\tBodyHandler,\n\tOptionalHandler,\n\tAfterResponseHandler,\n\tErrorHandler,\n\tLifeCycleEvent,\n\tLifeCycleStore,\n\tLifeCycleType,\n\tMaybePromise,\n\tUnwrapSchema,\n\tChecksum,\n\tDocumentDecoration,\n\tInferContext,\n\tInferHandler,\n\tResolvePath,\n\tMapResponse,\n\tMacroQueue,\n\tBaseMacro,\n\tMacroManager,\n\tBaseMacroFn,\n\tMacroToProperty,\n\tResolveMacroContext,\n\tMergeElysiaInstances,\n\tMaybeArray,\n\tModelValidator,\n\tMetadataBase,\n\tUnwrapBodySchema,\n\tUnwrapGroupGuardRoute,\n\tModelValidatorError,\n\tExcludeElysiaResponse,\n\tSSEPayload,\n\tStandaloneInputSchema,\n\tMergeStandaloneSchema,\n\tMergeTypeModule,\n\tGracefulHandler,\n\tAfterHandler,\n\tInlineHandler,\n\tResolveHandler,\n\tTransformHandler,\n\tHTTPHeaders\n} from './types'\n\nexport { env } from './universal/env'\nexport { file, ElysiaFile } from './universal/file'\nexport type { ElysiaAdapter } from './adapter'\n\nexport { TypeSystemPolicy } from '@sinclair/typebox/system'\nexport type { Static, TSchema } from '@sinclair/typebox'\n",
|
|
8
|
+
"import { Memoirist } from 'memoirist'\nimport {\n\tKind,\n\ttype TObject,\n\ttype Static,\n\ttype TSchema,\n\ttype TModule,\n\ttype TRef,\n\ttype TProperties\n} from '@sinclair/typebox'\n\nimport fastDecodeURIComponent from 'fast-decode-uri-component'\nimport type { Context, PreContext } from './context'\n\nimport { t } from './type-system'\nimport {\n\tclearSucroseCache,\n\tmergeInference,\n\tsucrose,\n\ttype Sucrose\n} from './sucrose'\n\nimport type { WSLocalHook } from './ws/types'\n\nimport { BunAdapter } from './adapter/bun/index'\nimport { WebStandardAdapter } from './adapter/web-standard/index'\nimport type { ElysiaAdapter } from './adapter/types'\n\nimport { env } from './universal/env'\nimport type { ListenCallback, Serve, Server } from './universal/server'\n\nimport {\n\tcloneInference,\n\tdeduplicateChecksum,\n\tfnToContainer,\n\tgetLoosePath,\n\tlocalHookToLifeCycleStore,\n\tmergeDeep,\n\tmergeSchemaValidator,\n\tPromiseGroup,\n\tpromoteEvent,\n\tisNotEmpty,\n\tencodePath,\n\tlifeCycleToArray,\n\tsupportPerMethodInlineHandler,\n\tredirect\n} from './utils'\n\nimport {\n\tcoercePrimitiveRoot,\n\tstringToStructureCoercions,\n\tgetSchemaValidator,\n\tgetResponseSchemaValidator,\n\tgetCookieValidator,\n\tElysiaTypeCheck\n} from './schema'\nimport {\n\tcomposeHandler,\n\tcomposeGeneralHandler,\n\tcomposeErrorHandler\n} from './compose'\n\nimport { createTracer } from './trace'\n\nimport {\n\tmergeHook,\n\tchecksum,\n\tmergeLifeCycle,\n\tfilterGlobalHook,\n\tasHookType,\n\ttraceBackMacro,\n\treplaceUrlPath,\n\tcreateMacroManager\n} from './utils'\n\nimport {\n\tcreateDynamicErrorHandler,\n\tcreateDynamicHandler,\n\ttype DynamicHandler\n} from './dynamic-handle'\n\nimport {\n\tERROR_CODE,\n\tValidationError,\n\ttype ParseError,\n\ttype NotFoundError,\n\ttype InternalServerError,\n\tElysiaCustomStatusResponse,\n\tstatus\n} from './error'\n\nimport type { TraceHandler } from './trace'\n\nimport type {\n\tElysiaConfig,\n\tSingletonBase,\n\tDefinitionBase,\n\tHandler,\n\tComposedHandler,\n\tInputSchema,\n\tLocalHook,\n\tAnyLocalHook,\n\tMergeSchema,\n\tRouteSchema,\n\tUnwrapRoute,\n\tInternalRoute,\n\tHTTPMethod,\n\tSchemaValidator,\n\tPreHandler,\n\tBodyHandler,\n\tOptionalHandler,\n\tErrorHandler,\n\tLifeCycleStore,\n\tMaybePromise,\n\tPrettify,\n\tPrettify2,\n\tAddPrefix,\n\tAddSuffix,\n\tAddPrefixCapitalize,\n\tAddSuffixCapitalize,\n\tMaybeArray,\n\tGracefulHandler,\n\tMapResponse,\n\tChecksum,\n\tMacroManager,\n\tMacroToProperty,\n\tTransformHandler,\n\tMetadataBase,\n\tRouteBase,\n\tCreateEden,\n\tComposeElysiaResponse,\n\tInlineHandler,\n\tHookContainer,\n\tLifeCycleType,\n\tMacroQueue,\n\tEphemeralType,\n\tExcludeElysiaResponse,\n\tModelValidator,\n\tBaseMacroFn,\n\tContextAppendType,\n\tReconcile,\n\tAfterResponseHandler,\n\tHigherOrderFunction,\n\tResolvePath,\n\tJoinPath,\n\tValidatorLayer,\n\tMergeElysiaInstances,\n\tHookMacroFn,\n\tResolveHandler,\n\tResolveResolutions,\n\tUnwrapTypeModule,\n\tMacroToContext,\n\tStandaloneValidator,\n\tGuardSchemaType,\n\tOr,\n\tPrettifySchema,\n\tMergeStandaloneSchema,\n\tIsNever,\n\tDocumentDecoration,\n\tAfterHandler\n} from './types'\n\nexport type AnyElysia = Elysia<any, any, any, any, any, any, any>\n\n/**\n * ### Elysia Server\n * Main instance to create web server using Elysia\n *\n * ---\n * @example\n * ```typescript\n * import { Elysia } from 'elysia'\n *\n * new Elysia()\n * .get(\"/\", () => \"Hello\")\n * .listen(3000)\n * ```\n */\nexport default class Elysia<\n\tconst in out BasePath extends string = '',\n\tconst in out Singleton extends SingletonBase = {\n\t\tdecorator: {}\n\t\tstore: {}\n\t\tderive: {}\n\t\tresolve: {}\n\t},\n\tconst in out Definitions extends DefinitionBase = {\n\t\ttypebox: {}\n\t\terror: {}\n\t},\n\tconst in out Metadata extends MetadataBase = {\n\t\tschema: {}\n\t\tstandaloneSchema: {}\n\t\tmacro: {}\n\t\tmacroFn: {}\n\t\tparser: {}\n\t},\n\tconst out Routes extends RouteBase = {},\n\t// ? scoped\n\tconst in out Ephemeral extends EphemeralType = {\n\t\tderive: {}\n\t\tresolve: {}\n\t\tschema: {}\n\t\tstandaloneSchema: {}\n\t},\n\t// ? local\n\tconst in out Volatile extends EphemeralType = {\n\t\tderive: {}\n\t\tresolve: {}\n\t\tschema: {}\n\t\tstandaloneSchema: {}\n\t}\n> {\n\tconfig: ElysiaConfig<BasePath>\n\n\tserver: Server | null = null\n\tprivate dependencies: { [key in string]: Checksum[] } = {}\n\n\t'~Prefix' = '' as BasePath\n\t'~Singleton' = null as unknown as Singleton\n\t'~Definitions' = null as unknown as Definitions\n\t'~Metadata' = null as unknown as Metadata\n\t'~Ephemeral' = null as unknown as Ephemeral\n\t'~Volatile' = null as unknown as Volatile\n\t'~Routes' = null as unknown as Routes\n\n\tprotected singleton = {\n\t\tdecorator: {},\n\t\tstore: {},\n\t\tderive: {},\n\t\tresolve: {}\n\t} as SingletonBase\n\n\tget store(): Singleton['store'] {\n\t\treturn this.singleton.store\n\t}\n\n\tget decorator(): Singleton['decorator'] {\n\t\treturn this.singleton.decorator\n\t}\n\n\tprotected definitions = {\n\t\ttypebox: t.Module({}),\n\t\ttype: {} as Record<string, TSchema>,\n\t\terror: {} as Record<string, Error>\n\t}\n\n\tprotected extender = {\n\t\tmacros: <MacroQueue[]>[],\n\t\thigherOrderFunctions: <HookContainer<HigherOrderFunction>[]>[]\n\t}\n\n\tprotected validator: ValidatorLayer = {\n\t\tglobal: null,\n\t\tscoped: null,\n\t\tlocal: null,\n\t\tgetCandidate() {\n\t\t\tif (!this.global && !this.scoped && !this.local)\n\t\t\t\treturn {\n\t\t\t\t\tbody: undefined,\n\t\t\t\t\theaders: undefined,\n\t\t\t\t\tparams: undefined,\n\t\t\t\t\tquery: undefined,\n\t\t\t\t\tcookie: undefined,\n\t\t\t\t\tresponse: undefined\n\t\t\t\t}\n\n\t\t\treturn mergeSchemaValidator(\n\t\t\t\tmergeSchemaValidator(this.global, this.scoped),\n\t\t\t\tthis.local\n\t\t\t)\n\t\t}\n\t}\n\n\tprotected standaloneValidator: StandaloneValidator = {\n\t\tglobal: null,\n\t\tscoped: null,\n\t\tlocal: null\n\t}\n\n\tevent: Partial<LifeCycleStore> = {}\n\n\tprotected telemetry:\n\t\t| undefined\n\t\t| {\n\t\t\t\tstack: string | undefined\n\t\t }\n\n\trouter = {\n\t\t'~http': undefined as\n\t\t\t| Memoirist<{\n\t\t\t\t\tcompile: Function\n\t\t\t\t\thandler?: ComposedHandler\n\t\t\t }>\n\t\t\t| undefined,\n\t\tget http() {\n\t\t\tif (!this['~http'])\n\t\t\t\tthis['~http'] = new Memoirist({\n\t\t\t\t\tlazy: true,\n\t\t\t\t\tonParam: fastDecodeURIComponent\n\t\t\t\t})\n\n\t\t\treturn this['~http']\n\t\t},\n\t\t'~dynamic': undefined as Memoirist<DynamicHandler> | undefined,\n\t\t// Use in non-AOT mode\n\t\tget dynamic() {\n\t\t\tif (!this['~dynamic'])\n\t\t\t\tthis['~dynamic'] = new Memoirist({\n\t\t\t\t\tonParam: fastDecodeURIComponent\n\t\t\t\t})\n\n\t\t\treturn this['~dynamic']\n\t\t},\n\t\t// Static Router\n\t\tstatic: {} as { [path in string]: { [method in string]: number } },\n\t\t// Native Static Response\n\t\tresponse: {} as {\n\t\t\t[path: string]:\n\t\t\t\t| MaybePromise<Response | undefined>\n\t\t\t\t| { [method: string]: MaybePromise<Response | undefined> }\n\t\t},\n\t\thistory: [] as InternalRoute[]\n\t}\n\n\tprotected routeTree: Record<string, number> = {}\n\n\tget routes(): InternalRoute[] {\n\t\treturn this.router.history\n\t}\n\n\tprotected getGlobalRoutes(): InternalRoute[] {\n\t\treturn this.router.history\n\t}\n\n\tprotected getGlobalDefinitions() {\n\t\treturn this.definitions\n\t}\n\n\tprotected inference: Sucrose.Inference = {\n\t\tbody: false,\n\t\tcookie: false,\n\t\theaders: false,\n\t\tquery: false,\n\t\tset: false,\n\t\tserver: false,\n\t\tpath: false,\n\t\troute: false,\n\t\turl: false\n\t}\n\n\tprivate getServer() {\n\t\treturn this.server\n\t}\n\n\tprivate getParent(): Elysia | null {\n\t\treturn null\n\t}\n\n\t'~parser': { [K in string]: BodyHandler<any, any> } = {}\n\n\tprivate _promisedModules: PromiseGroup | undefined\n\tprivate get promisedModules() {\n\t\tif (!this._promisedModules)\n\t\t\tthis._promisedModules = new PromiseGroup(console.error, () => {\n\t\t\t\t// this.compile()\n\t\t\t})\n\n\t\treturn this._promisedModules\n\t}\n\n\tconstructor(config: ElysiaConfig<BasePath> = {}) {\n\t\tif (config.tags) {\n\t\t\tif (!config.detail)\n\t\t\t\tconfig.detail = {\n\t\t\t\t\ttags: config.tags\n\t\t\t\t}\n\t\t\telse config.detail.tags = config.tags\n\t\t}\n\n\t\tthis.config = {\n\t\t\taot: env.ELYSIA_AOT !== 'false',\n\t\t\tnativeStaticResponse: true,\n\t\t\tsystemRouter: true,\n\t\t\tencodeSchema: true,\n\t\t\tnormalize: true,\n\t\t\t...config,\n\t\t\tprefix: config.prefix\n\t\t\t\t? config.prefix.charCodeAt(0) === 47\n\t\t\t\t\t? config.prefix\n\t\t\t\t\t: `/${config.prefix}`\n\t\t\t\t: (undefined as any),\n\t\t\tcookie: {\n\t\t\t\tpath: '/',\n\t\t\t\t...config?.cookie\n\t\t\t},\n\t\t\texperimental: config?.experimental ?? {},\n\t\t\tseed: config?.seed === undefined ? '' : config?.seed\n\t\t}\n\n\t\tthis['~adapter'] =\n\t\t\tconfig.adapter ??\n\t\t\t(typeof Bun !== 'undefined' ? BunAdapter : WebStandardAdapter)\n\n\t\tif (config?.analytic && (config?.name || config?.seed !== undefined))\n\t\t\tthis.telemetry = {\n\t\t\t\tstack: new Error().stack\n\t\t\t}\n\t}\n\n\t'~adapter': ElysiaAdapter\n\n\tenv(model: TObject<any>, _env = env) {\n\t\tconst validator = getSchemaValidator(model, {\n\t\t\tmodules: this.definitions.typebox,\n\t\t\tdynamic: true,\n\t\t\tadditionalProperties: true,\n\t\t\tcoerce: true,\n\t\t\tsanitize: () => this.config.sanitize\n\t\t})\n\n\t\tif (validator.Check(_env) === false) {\n\t\t\tconst error = new ValidationError('env', model, _env)\n\n\t\t\tthrow new Error(error.all.map((x) => x.summary).join('\\n'))\n\t\t}\n\n\t\treturn this\n\t}\n\n\t/**\n\t * @private DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n\t * @version 1.1.0\n\t *\n\t * ! Do not use unless you know exactly what you are doing\n\t * ? Add Higher order function to Elysia.fetch\n\t */\n\twrap(fn: HigherOrderFunction) {\n\t\tthis.extender.higherOrderFunctions.push({\n\t\t\tchecksum: checksum(\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tname: this.config.name,\n\t\t\t\t\tseed: this.config.seed,\n\t\t\t\t\tcontent: fn.toString()\n\t\t\t\t})\n\t\t\t),\n\t\t\tfn\n\t\t})\n\n\t\treturn this\n\t}\n\n\tprivate applyMacro(localHook: AnyLocalHook) {\n\t\tif (this.extender.macros.length) {\n\t\t\tconst manage = createMacroManager({\n\t\t\t\tglobalHook: this.event,\n\t\t\t\tlocalHook\n\t\t\t})\n\n\t\t\tconst manager: MacroManager = {\n\t\t\t\tevents: {\n\t\t\t\t\tglobal: this.event,\n\t\t\t\t\tlocal: localHook\n\t\t\t\t},\n\t\t\t\tget onParse() {\n\t\t\t\t\treturn manage('parse') as any\n\t\t\t\t},\n\t\t\t\tget onTransform() {\n\t\t\t\t\treturn manage('transform') as any\n\t\t\t\t},\n\t\t\t\tget onBeforeHandle() {\n\t\t\t\t\treturn manage('beforeHandle') as any\n\t\t\t\t},\n\t\t\t\tget onAfterHandle() {\n\t\t\t\t\treturn manage('afterHandle') as any\n\t\t\t\t},\n\t\t\t\tget mapResponse() {\n\t\t\t\t\treturn manage('mapResponse') as any\n\t\t\t\t},\n\t\t\t\tget onAfterResponse() {\n\t\t\t\t\treturn manage('afterResponse') as any\n\t\t\t\t},\n\t\t\t\tget onError() {\n\t\t\t\t\treturn manage('error') as any\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const macro of this.extender.macros)\n\t\t\t\ttraceBackMacro(macro.fn(manager), localHook, manage)\n\t\t}\n\t}\n\n\tget models(): {\n\t\t[K in keyof Definitions['typebox']]: ModelValidator<\n\t\t\tDefinitions['typebox'][K]\n\t\t>\n\t} & {\n\t\tmodules: TModule<Definitions['typebox']>\n\t} {\n\t\tconst models: Record<string, ElysiaTypeCheck<TSchema>> = {}\n\n\t\tfor (const name of Object.keys(this.definitions.type))\n\t\t\tmodels[name] = getSchemaValidator(\n\t\t\t\tthis.definitions.typebox.Import(name as never)\n\t\t\t)\n\n\t\t// @ts-expect-error\n\t\tmodels.modules = this.definitions.typebox\n\n\t\treturn models as any\n\t}\n\n\tprivate add(\n\t\tmethod: HTTPMethod,\n\t\tpath: string,\n\t\thandle: Handler<any, any, any> | any,\n\t\tlocalHook?: AnyLocalHook,\n\t\toptions?: {\n\t\t\tallowMeta?: boolean\n\t\t\tskipPrefix?: boolean\n\t\t},\n\t\tstandaloneValidators?: InputSchema<string>[]\n\t) {\n\t\tconst skipPrefix = options?.skipPrefix ?? false\n\t\tconst allowMeta = options?.allowMeta ?? false\n\n\t\tlocalHook ??= {}\n\n\t\tif (standaloneValidators === undefined) {\n\t\t\tstandaloneValidators = []\n\n\t\t\tif (this.standaloneValidator.local)\n\t\t\t\tstandaloneValidators = standaloneValidators.concat(\n\t\t\t\t\tthis.standaloneValidator.local\n\t\t\t\t)\n\n\t\t\tif (this.standaloneValidator.scoped)\n\t\t\t\tstandaloneValidators = standaloneValidators.concat(\n\t\t\t\t\tthis.standaloneValidator.scoped\n\t\t\t\t)\n\n\t\t\tif (this.standaloneValidator.global)\n\t\t\t\tstandaloneValidators = standaloneValidators.concat(\n\t\t\t\t\tthis.standaloneValidator.global\n\t\t\t\t)\n\t\t}\n\n\t\tif (path !== '' && path.charCodeAt(0) !== 47) path = '/' + path\n\t\tif (this.config.prefix && !skipPrefix) path = this.config.prefix + path\n\n\t\tif (localHook?.type)\n\t\t\tswitch (localHook.type) {\n\t\t\t\tcase 'text':\n\t\t\t\t\tlocalHook.type = 'text/plain'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'json':\n\t\t\t\t\tlocalHook.type = 'application/json'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'formdata':\n\t\t\t\t\tlocalHook.type = 'multipart/form-data'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'urlencoded':\n\t\t\t\t\tlocalHook.type = 'application/x-www-form-urlencoded'\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'arrayBuffer':\n\t\t\t\t\tlocalHook.type = 'application/octet-stream'\n\t\t\t\t\tbreak\n\n\t\t\t\tdefault:\n\t\t\t\t\tbreak\n\t\t\t}\n\n\t\tconst instanceValidator = this.validator.getCandidate()\n\n\t\tconst cloned = {\n\t\t\tbody: localHook?.body ?? (instanceValidator?.body as any),\n\t\t\theaders: localHook?.headers ?? (instanceValidator?.headers as any),\n\t\t\tparams: localHook?.params ?? (instanceValidator?.params as any),\n\t\t\tquery: localHook?.query ?? (instanceValidator?.query as any),\n\t\t\tcookie: localHook?.cookie ?? (instanceValidator?.cookie as any),\n\t\t\tresponse:\n\t\t\t\tlocalHook?.response ?? (instanceValidator?.response as any)\n\t\t}\n\n\t\tconst shouldPrecompile =\n\t\t\tthis.config.precompile === true ||\n\t\t\t(typeof this.config.precompile === 'object' &&\n\t\t\t\tthis.config.precompile.compose === true)\n\n\t\tconst createValidator = () => {\n\t\t\tconst models = this.definitions.type\n\t\t\tconst dynamic = !this.config.aot\n\n\t\t\tconst normalize = this.config.normalize\n\t\t\tconst modules = this.definitions.typebox\n\n\t\t\tconst sanitize = () => this.config.sanitize\n\n\t\t\tconst cookieValidator = () => {\n\t\t\t\tif (cloned.cookie || standaloneValidators.find((x) => x.cookie))\n\t\t\t\t\treturn getCookieValidator({\n\t\t\t\t\t\tmodules,\n\t\t\t\t\t\tvalidator: cloned.cookie,\n\t\t\t\t\t\tdefaultConfig: this.config.cookie,\n\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\tconfig: cloned.cookie?.config ?? {},\n\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\tmodels,\n\t\t\t\t\t\tvalidators: standaloneValidators.map((x) => x.cookie),\n\t\t\t\t\t\tsanitize\n\t\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn shouldPrecompile\n\t\t\t\t? {\n\t\t\t\t\t\tbody: getSchemaValidator(cloned.body, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\tadditionalCoerce: coercePrimitiveRoot(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map((x) => x.body),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\theaders: getSchemaValidator(cloned.headers, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.headers\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tparams: getSchemaValidator(cloned.params, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.params\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tquery: getSchemaValidator(cloned.query, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.query\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tcookie: cookieValidator(),\n\t\t\t\t\t\tresponse: getResponseSchemaValidator(cloned.response, {\n\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t(x) => x.response\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t: ({\n\t\t\t\t\t\tcreateBody() {\n\t\t\t\t\t\t\tif (this.body) return this.body\n\n\t\t\t\t\t\t\treturn (this.body = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.body,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tadditionalCoerce: coercePrimitiveRoot(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.body\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateHeaders() {\n\t\t\t\t\t\t\tif (this.headers) return this.headers\n\n\t\t\t\t\t\t\treturn (this.headers = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.headers,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tadditionalProperties: !normalize,\n\t\t\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\t\t\tadditionalCoerce:\n\t\t\t\t\t\t\t\t\t\tstringToStructureCoercions(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.headers\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateParams() {\n\t\t\t\t\t\t\tif (this.params) return this.params\n\n\t\t\t\t\t\t\treturn (this.params = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.params,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\t\t\tadditionalCoerce:\n\t\t\t\t\t\t\t\t\t\tstringToStructureCoercions(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.params\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateQuery() {\n\t\t\t\t\t\t\tif (this.query) return this.query\n\n\t\t\t\t\t\t\treturn (this.query = getSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.query,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tcoerce: true,\n\t\t\t\t\t\t\t\t\tadditionalCoerce:\n\t\t\t\t\t\t\t\t\t\tstringToStructureCoercions(),\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.query\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateCookie() {\n\t\t\t\t\t\t\tif (this.cookie) return this.cookie\n\n\t\t\t\t\t\t\treturn (this.cookie = cookieValidator())\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcreateResponse() {\n\t\t\t\t\t\t\tif (this.response) return this.response\n\n\t\t\t\t\t\t\treturn (this.response = getResponseSchemaValidator(\n\t\t\t\t\t\t\t\tcloned.response,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\t\tvalidators: standaloneValidators.map(\n\t\t\t\t\t\t\t\t\t\t(x) => x.response\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t}\n\t\t\t\t\t} as any)\n\t\t}\n\n\t\tif (\n\t\t\tinstanceValidator.body ||\n\t\t\tinstanceValidator.cookie ||\n\t\t\tinstanceValidator.headers ||\n\t\t\tinstanceValidator.params ||\n\t\t\tinstanceValidator.query ||\n\t\t\tinstanceValidator.response\n\t\t)\n\t\t\tlocalHook = mergeHook(localHook, instanceValidator)\n\n\t\tif (localHook.tags) {\n\t\t\tif (!localHook.detail)\n\t\t\t\tlocalHook.detail = {\n\t\t\t\t\ttags: localHook.tags\n\t\t\t\t}\n\t\t\telse localHook.detail.tags = localHook.tags\n\t\t}\n\n\t\tif (isNotEmpty(this.config.detail))\n\t\t\tlocalHook.detail = mergeDeep(\n\t\t\t\tObject.assign({}, this.config.detail!),\n\t\t\t\tlocalHook.detail\n\t\t\t)\n\n\t\tthis.applyMacro(localHook)\n\n\t\tconst hooks = isNotEmpty(this.event)\n\t\t\t? mergeHook(this.event, localHookToLifeCycleStore(localHook))\n\t\t\t: lifeCycleToArray(localHookToLifeCycleStore(localHook))\n\n\t\tif (this.config.aot === false) {\n\t\t\tconst validator = createValidator()\n\n\t\t\tthis.router.dynamic.add(method, path, {\n\t\t\t\tvalidator,\n\t\t\t\thooks,\n\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\thandle,\n\t\t\t\troute: path\n\t\t\t})\n\n\t\t\tconst encoded = encodePath(path, { dynamic: true })\n\t\t\tif (path !== encoded) {\n\t\t\t\tthis.router.dynamic.add(method, encoded, {\n\t\t\t\t\tvalidator,\n\t\t\t\t\thooks,\n\t\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\t\thandle,\n\t\t\t\t\troute: path\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (this.config.strictPath === false) {\n\t\t\t\tconst loosePath = getLoosePath(path)\n\t\t\t\tthis.router.dynamic.add(method, loosePath, {\n\t\t\t\t\tvalidator,\n\t\t\t\t\thooks,\n\t\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\t\thandle,\n\t\t\t\t\troute: path\n\t\t\t\t})\n\n\t\t\t\tconst encoded = encodePath(loosePath)\n\t\t\t\tif (loosePath !== encoded)\n\t\t\t\t\tthis.router.dynamic.add(method, loosePath, {\n\t\t\t\t\t\tvalidator,\n\t\t\t\t\t\thooks,\n\t\t\t\t\t\tcontent: localHook?.type as string,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t\troute: path\n\t\t\t\t\t})\n\t\t\t}\n\n\t\t\tthis.router.history.push({\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tcomposed: null,\n\t\t\t\thandler: handle,\n\t\t\t\tcompile: undefined as any,\n\t\t\t\thooks,\n\t\t\t\tstandaloneValidators\n\t\t\t})\n\n\t\t\treturn\n\t\t}\n\n\t\tconst adapter = this['~adapter'].handler\n\n\t\tconst nativeStaticHandler =\n\t\t\ttypeof handle !== 'function'\n\t\t\t\t? () => {\n\t\t\t\t\t\tconst context: PreContext = {\n\t\t\t\t\t\t\tredirect,\n\t\t\t\t\t\t\trequest: this['~adapter'].isWebStandard\n\t\t\t\t\t\t\t\t? new Request(`http://e.ly${path}`, {\n\t\t\t\t\t\t\t\t\t\tmethod\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: (undefined as any as Request),\n\t\t\t\t\t\t\tserver: null,\n\t\t\t\t\t\t\tset: {\n\t\t\t\t\t\t\t\theaders: Object.assign({}, this.setHeaders)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\terror: status,\n\t\t\t\t\t\t\tstore: this.store\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tthis.event.request?.map((x) => {\n\t\t\t\t\t\t\t\tif (typeof x.fn === 'function')\n\t\t\t\t\t\t\t\t\treturn x.fn(context)\n\n\t\t\t\t\t\t\t\t// @ts-ignore just in case\n\t\t\t\t\t\t\t\tif (typeof x === 'function') return x(context)\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tlet res\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcontext.error = error\n\n\t\t\t\t\t\t\tthis.event.error?.some((x) => {\n\t\t\t\t\t\t\t\tif (typeof x.fn === 'function')\n\t\t\t\t\t\t\t\t\treturn (res = x.fn(context))\n\n\t\t\t\t\t\t\t\tif (typeof x === 'function')\n\t\t\t\t\t\t\t\t\t// @ts-ignore just in case\n\t\t\t\t\t\t\t\t\treturn (res = x(context))\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\tif (res !== undefined) handle = res\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst fn = adapter.createNativeStaticHandler?.(\n\t\t\t\t\t\t\thandle,\n\t\t\t\t\t\t\thooks,\n\t\t\t\t\t\t\tcontext.set as Context['set']\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn fn instanceof Promise\n\t\t\t\t\t\t\t? fn.then((fn) => {\n\t\t\t\t\t\t\t\t\tif (fn) return fn\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: fn?.()\n\t\t\t\t\t}\n\t\t\t\t: undefined\n\n\t\tconst useNativeStaticResponse =\n\t\t\tthis.config.nativeStaticResponse === true\n\n\t\tconst addResponsePath = (path: string) => {\n\t\t\tif (!useNativeStaticResponse || !nativeStaticHandler) return\n\n\t\t\tif (supportPerMethodInlineHandler) {\n\t\t\t\tif (this.router.response[path])\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tthis.router.response[path]![method] = nativeStaticHandler()\n\t\t\t\telse\n\t\t\t\t\tthis.router.response[path] = {\n\t\t\t\t\t\t[method]: nativeStaticHandler()\n\t\t\t\t\t}\n\t\t\t} else this.router.response[path] = nativeStaticHandler()\n\t\t}\n\n\t\taddResponsePath(path)\n\n\t\tlet _compiled: ComposedHandler\n\t\tconst compile = () => {\n\t\t\tif (_compiled) return _compiled\n\n\t\t\treturn (_compiled = composeHandler({\n\t\t\t\tapp: this,\n\t\t\t\tpath,\n\t\t\t\tmethod,\n\t\t\t\thooks,\n\t\t\t\tvalidator: createValidator(),\n\t\t\t\thandler:\n\t\t\t\t\ttypeof handle !== 'function' &&\n\t\t\t\t\ttypeof adapter.createStaticHandler !== 'function'\n\t\t\t\t\t\t? () => handle\n\t\t\t\t\t\t: handle,\n\t\t\t\tallowMeta,\n\t\t\t\tinference: this.inference\n\t\t\t}))\n\t\t}\n\n\t\tlet oldIndex: number | undefined\n\t\tif (`${method}_${path}` in this.routeTree)\n\t\t\tfor (let i = 0; i < this.router.history.length; i++) {\n\t\t\t\tconst route = this.router.history[i]\n\t\t\t\tif (route.path === path && route.method === method) {\n\t\t\t\t\toldIndex = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\telse this.routeTree[`${method}_${path}`] = this.router.history.length\n\n\t\tconst index = oldIndex ?? this.router.history.length\n\n\t\tconst mainHandler = shouldPrecompile\n\t\t\t? compile()\n\t\t\t: (ctx: Context) =>\n\t\t\t\t\t(\n\t\t\t\t\t\t(this.router.history[index].composed =\n\t\t\t\t\t\t\tcompile!()) as ComposedHandler\n\t\t\t\t\t)(ctx)\n\n\t\tif (oldIndex !== undefined)\n\t\t\tthis.router.history[oldIndex] = Object.assign(\n\t\t\t\t{\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath,\n\t\t\t\t\tcomposed: mainHandler,\n\t\t\t\t\tcompile: compile!,\n\t\t\t\t\thandler: handle,\n\t\t\t\t\thooks\n\t\t\t\t},\n\t\t\t\tstandaloneValidators.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tlocalHook.webSocket\n\t\t\t\t\t? { websocket: localHook.websocket as any }\n\t\t\t\t\t: undefined\n\t\t\t)\n\t\telse\n\t\t\tthis.router.history.push(\n\t\t\t\tObject.assign(\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tcomposed: mainHandler,\n\t\t\t\t\t\tcompile: compile!,\n\t\t\t\t\t\thandler: handle,\n\t\t\t\t\t\thooks\n\t\t\t\t\t},\n\t\t\t\t\tstandaloneValidators.length\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tlocalHook.webSocket\n\t\t\t\t\t\t? { websocket: localHook.websocket as any }\n\t\t\t\t\t\t: undefined\n\t\t\t\t)\n\t\t\t)\n\n\t\tconst handler = {\n\t\t\thandler: shouldPrecompile ? mainHandler : undefined,\n\t\t\tcompile() {\n\t\t\t\treturn (this.handler = compile!())\n\t\t\t}\n\t\t}\n\n\t\tconst staticRouter = this.router.static\n\t\tconst isStaticPath =\n\t\t\tpath.indexOf(':') === -1 && path.indexOf('*') === -1\n\n\t\tif (method === 'WS') {\n\t\t\tif (isStaticPath) {\n\t\t\t\tif (path in staticRouter) staticRouter[path][method] = index\n\t\t\t\telse\n\t\t\t\t\tstaticRouter[path] = {\n\t\t\t\t\t\t[method]: index\n\t\t\t\t\t}\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.router.http.add('WS', path, handler)\n\n\t\t\tif (!this.config.strictPath)\n\t\t\t\tthis.router.http.add('WS', getLoosePath(path), handler)\n\n\t\t\tconst encoded = encodePath(path, { dynamic: true })\n\t\t\tif (path !== encoded) this.router.http.add('WS', encoded, handler)\n\n\t\t\t// Static path doesn't need encode as it's done in compilation process\n\n\t\t\treturn\n\t\t}\n\n\t\tif (isStaticPath) {\n\t\t\tif (path in staticRouter) staticRouter[path][method] = index\n\t\t\telse\n\t\t\t\tstaticRouter[path] = {\n\t\t\t\t\t[method]: index\n\t\t\t\t} as const\n\n\t\t\tif (!this.config.strictPath) addResponsePath(getLoosePath(path))\n\n\t\t\t// Static path doesn't need encode as it's done in compilation process\n\t\t} else {\n\t\t\tthis.router.http.add(method, path, handler)\n\n\t\t\tif (!this.config.strictPath) {\n\t\t\t\tconst loosePath = getLoosePath(path)\n\n\t\t\t\taddResponsePath(loosePath)\n\t\t\t\tthis.router.http.add(method, loosePath, handler)\n\t\t\t}\n\n\t\t\tconst encoded = encodePath(path, { dynamic: true })\n\t\t\tif (path !== encoded) {\n\t\t\t\tthis.router.http.add(method, encoded, handler)\n\n\t\t\t\taddResponsePath(encoded)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setHeaders?: Context['set']['headers']\n\theaders(header: Context['set']['headers'] | undefined) {\n\t\tif (!header) return this\n\n\t\tif (!this.setHeaders) this.setHeaders = {}\n\n\t\tthis.setHeaders = mergeDeep(this.setHeaders, header)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### start | Life cycle event\n\t * Called after server is ready for serving\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onStart(({ server }) => {\n\t * console.log(\"Running at ${server?.url}:${server?.port}\")\n\t * })\n\t * .listen(3000)\n\t * ```\n\t */\n\tonStart(handler: MaybeArray<GracefulHandler<this>>) {\n\t\tthis.on('start', handler as any)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### request | Life cycle event\n\t * Called on every new request is accepted\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onRequest(({ method, url }) => {\n\t * saveToAnalytic({ method, url })\n\t * })\n\t * ```\n\t */\n\tonRequest<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tPreHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: {}\n\t\t\t\t\tresolve: {}\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t) {\n\t\tthis.on('request', handler as any)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### parse | Life cycle event\n\t * Callback function to handle body parsing\n\t *\n\t * If truthy value is returned, will be assigned to `context.body`\n\t * Otherwise will skip the callback and look for the next one.\n\t *\n\t * Equivalent to Express's body parser\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onParse((request, contentType) => {\n\t * if(contentType === \"application/json\")\n\t * return request.json()\n\t * })\n\t * ```\n\t */\n\tonParse<const Schema extends RouteSchema>(\n\t\tparser: MaybeArray<\n\t\t\tBodyHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\tresolve: {}\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### parse | Life cycle event\n\t * Callback function to handle body parsing\n\t *\n\t * If truthy value is returned, will be assigned to `context.body`\n\t * Otherwise will skip the callback and look for the next one.\n\t *\n\t * Equivalent to Express's body parser\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onParse((request, contentType) => {\n\t * if(contentType === \"application/json\")\n\t * return request.json()\n\t * })\n\t * ```\n\t */\n\tonParse<const Schema extends RouteSchema, const Type extends LifeCycleType>(\n\t\toptions: { as?: Type },\n\t\tparser: MaybeArray<\n\t\t\tBodyHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\t'global' extends Type\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\tPartial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t}\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\tonParse<const Parsers extends keyof Metadata['parser']>(\n\t\tparser: Parsers\n\t): this\n\n\tonParse(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function> | string,\n\t\thandler?: MaybeArray<Function>\n\t): unknown {\n\t\tif (!handler) {\n\t\t\tif (typeof options === 'string')\n\t\t\t\treturn this.on('parse', this['~parser'][options] as any)\n\n\t\t\treturn this.on('parse', options as any)\n\t\t}\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'parse',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### parse | Life cycle event\n\t * Callback function to handle body parsing\n\t *\n\t * If truthy value is returned, will be assigned to `context.body`\n\t * Otherwise will skip the callback and look for the next one.\n\t *\n\t * Equivalent to Express's body parser\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onParse((request, contentType) => {\n\t * if(contentType === \"application/json\")\n\t * return request.json()\n\t * })\n\t * ```\n\t */\n\tparser<\n\t\tconst Parser extends string,\n\t\tconst Schema extends RouteSchema,\n\t\tconst Handler extends BodyHandler<\n\t\t\tMergeSchema<\n\t\t\t\tSchema,\n\t\t\t\tMergeSchema<\n\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t>,\n\t\t\t\tBasePath\n\t\t\t> &\n\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t{\n\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\tstore: Singleton['store']\n\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\tVolatile['derive']\n\t\t\t\tresolve: {}\n\t\t\t}\n\t\t>\n\t>(\n\t\tname: Parser,\n\t\tparser: Handler\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: Metadata['schema']\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro']\n\t\t\tmacroFn: Metadata['macroFn']\n\t\t\tparser: Metadata['parser'] & { [K in Parser]: Handler }\n\t\t},\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis['~parser'][name] = parser as any\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### transform | Life cycle event\n\t * Assign or transform anything related to context before validation.\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onTransform(({ params }) => {\n\t * if(params.id)\n\t * params.id = +params.id\n\t * })\n\t * ```\n\t */\n\tonTransform<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tTransformHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\tresolve: {}\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### transform | Life cycle event\n\t * Assign or transform anything related to context before validation.\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onTransform(({ params }) => {\n\t * if(params.id)\n\t * params.id = +params.id\n\t * })\n\t * ```\n\t */\n\tonTransform<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tTransformHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\t'global' extends Type\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t}\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tPartial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: {}\n\t\t\t\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\tonTransform(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('transform', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'transform',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tresolve<\n\t\tconst Resolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\tresolver: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t\t'global' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\tSingleton &\n\t\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Resolver | void>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\tSingleton['resolve'] & ExcludeElysiaResponse<Resolver>\n\t\t\t\t\t>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Resolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Resolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tresolve<\n\t\tconst Resolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t\t\t| void\n\t>(\n\t\tresolver: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t\tSingleton & {\n\t\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t},\n\t\t\t\t\tBasePath\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Resolver | void>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: Prettify<\n\t\t\t\tVolatile['resolve'] & ExcludeElysiaResponse<Resolver>\n\t\t\t>\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\tresolve(\n\t\toptionsOrResolve: { as?: LifeCycleType } | Function,\n\t\tresolve?: Function\n\t) {\n\t\tif (!resolve) {\n\t\t\tresolve = optionsOrResolve as any\n\t\t\toptionsOrResolve = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'resolve',\n\t\t\tfn: resolve!\n\t\t}\n\n\t\treturn this.onBeforeHandle(optionsOrResolve as any, hook as any) as any\n\t}\n\n\tmapResolve<\n\t\tconst NewResolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t>(\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t},\n\t\t\t\tBasePath\n\t\t\t>\n\t\t) => MaybePromise<NewResolver | void>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: ExcludeElysiaResponse<NewResolver>\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\tmapResolve<\n\t\tconst NewResolver extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t) => MaybePromise<NewResolver | void>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: ExcludeElysiaResponse<NewResolver>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewResolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewResolver>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\tmapResolve(\n\t\toptionsOrResolve: Function | { as?: LifeCycleType },\n\t\tmapper?: Function\n\t) {\n\t\tif (!mapper) {\n\t\t\tmapper = optionsOrResolve as any\n\t\t\toptionsOrResolve = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'mapResolve',\n\t\t\tfn: mapper!\n\t\t}\n\n\t\treturn this.onBeforeHandle(optionsOrResolve as any, hook as any) as any\n\t}\n\n\t/**\n\t * ### Before Handle | Life cycle event\n\t * Execute after validation and before the main route handler.\n\t *\n\t * If truthy value is returned, will be assigned as `Response` and skip the main handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onBeforeHandle(({ params: { id }, status }) => {\n\t * if(id && !isExisted(id)) {\n\t * \t status(401)\n\t *\n\t * return \"Unauthorized\"\n\t * \t }\n\t * })\n\t * ```\n\t */\n\tonBeforeHandle<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tOptionalHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### Before Handle | Life cycle event\n\t * Execute after validation and before the main route handler.\n\t *\n\t * If truthy value is returned, will be assigned as `Response` and skip the main handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onBeforeHandle(({ params: { id }, status }) => {\n\t * if(id && !isExisted(id)) {\n\t * \t status(401)\n\t *\n\t * return \"Unauthorized\"\n\t * \t }\n\t * })\n\t * ```\n\t */\n\tonBeforeHandle<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tOptionalHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t}),\n\t\t\t\tBasePath\n\t\t\t>\n\t\t>\n\t): this\n\n\tonBeforeHandle(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('beforeHandle', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'beforeHandle',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tonAfterHandle<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tAfterHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tonAfterHandle<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: LifeCycleType },\n\t\thandler: MaybeArray<\n\t\t\tAfterHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t>\n\t): this\n\n\tonAfterHandle(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('afterHandle', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'afterHandle',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .mapResponse((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tmapResponse<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tMapResponse<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .mapResponse((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\tmapResponse<const Schema extends RouteSchema, Type extends LifeCycleType>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tMapResponse<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t>\n\t): this\n\n\tmapResponse(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('mapResponse', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'mapResponse',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### response | Life cycle event\n\t * Call AFTER main handler is executed\n\t * Good for analytic metrics\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterResponse(() => {\n\t * cleanup()\n\t * })\n\t * ```\n\t */\n\tonAfterResponse<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tAfterResponseHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### response | Life cycle event\n\t * Call AFTER main handler is executed\n\t * Good for analytic metrics\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterResponse(() => {\n\t * cleanup()\n\t * \t })\n\t * ```\n\t */\n\n\tonAfterResponse<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\thandler: MaybeArray<\n\t\t\tAfterResponseHandler<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>,\n\t\t\t\t\tBasePath\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t'global' extends Type\n\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: {},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t})\n\t\t\t>\n\t\t>\n\t): this\n\n\tonAfterResponse(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('afterResponse', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'afterResponse',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\ttrace<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<TraceHandler<Schema, Singleton>>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\ttrace<const Schema extends RouteSchema>(\n\t\toptions: { as?: LifeCycleType },\n\t\thandler: MaybeArray<TraceHandler<Schema, Singleton>>\n\t): this\n\n\t/**\n\t * ### After Handle | Life cycle event\n\t * Intercept request **after** main handler is called.\n\t *\n\t * If truthy value is returned, will be assigned as `Response`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onAfterHandle((context, response) => {\n\t * if(typeof response === \"object\")\n\t * return JSON.stringify(response)\n\t * })\n\t * ```\n\t */\n\ttrace(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) {\n\t\t\thandler = options as MaybeArray<Function>\n\t\t\toptions = { as: 'local' }\n\t\t}\n\n\t\tif (!Array.isArray(handler)) handler = [handler] as Function[]\n\n\t\tfor (const fn of handler)\n\t\t\tthis.on(\n\t\t\t\toptions as { as?: LifeCycleType },\n\t\t\t\t'trace',\n\t\t\t\tcreateTracer(fn as any) as any\n\t\t\t)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * Register errors\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * class CustomError extends Error {\n\t * constructor() {\n\t * super()\n\t * }\n\t * }\n\t *\n\t * new Elysia()\n\t * .error('CUSTOM_ERROR', CustomError)\n\t * ```\n\t */\n\terror<\n\t\tconst Errors extends Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tprototype: Error\n\t\t\t}\n\t\t>\n\t>(\n\t\terrors: Errors\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox']\n\t\t\terror: Definitions['error'] & {\n\t\t\t\t[K in keyof Errors]: Errors[K] extends {\n\t\t\t\t\tprototype: infer LiteralError extends Error\n\t\t\t\t}\n\t\t\t\t\t? LiteralError\n\t\t\t\t\t: Errors[K]\n\t\t\t}\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * Register errors\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * class CustomError extends Error {\n\t * constructor() {\n\t * super()\n\t * }\n\t * }\n\t *\n\t * new Elysia()\n\t * .error({\n\t * CUSTOM_ERROR: CustomError\n\t * })\n\t * ```\n\t */\n\terror<\n\t\tName extends string,\n\t\tconst CustomError extends {\n\t\t\tprototype: Error\n\t\t}\n\t>(\n\t\tname: Name,\n\t\terrors: CustomError\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox']\n\t\t\terror: Definitions['error'] & {\n\t\t\t\t[name in Name]: CustomError extends {\n\t\t\t\t\tprototype: infer LiteralError extends Error\n\t\t\t\t}\n\t\t\t\t\t? LiteralError\n\t\t\t\t\t: CustomError\n\t\t\t}\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * Register errors\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * class CustomError extends Error {\n\t * constructor() {\n\t * super()\n\t * }\n\t * }\n\t *\n\t * new Elysia()\n\t * .error('CUSTOM_ERROR', CustomError)\n\t * ```\n\t */\n\terror<const NewErrors extends Record<string, Error>>(\n\t\tmapper: (decorators: Definitions['error']) => NewErrors\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox']\n\t\t\terror: {\n\t\t\t\t[K in keyof NewErrors]: NewErrors[K] extends {\n\t\t\t\t\tprototype: infer LiteralError extends Error\n\t\t\t\t}\n\t\t\t\t\t? LiteralError\n\t\t\t\t\t: never\n\t\t\t}\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\terror(\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tname:\n\t\t\t| string\n\t\t\t| Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t{\n\t\t\t\t\t\tprototype: Error\n\t\t\t\t\t}\n\t\t\t >\n\t\t\t| Function,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\terror?: {\n\t\t\tprototype: Error\n\t\t}\n\t): AnyElysia {\n\t\tswitch (typeof name) {\n\t\t\tcase 'string':\n\t\t\t\t// @ts-ignore\n\t\t\t\terror.prototype[ERROR_CODE] = name\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.definitions.error[name] = error\n\n\t\t\t\treturn this\n\n\t\t\tcase 'function':\n\t\t\t\tthis.definitions.error = name(this.definitions.error)\n\n\t\t\t\treturn this as any\n\t\t}\n\n\t\tfor (const [code, error] of Object.entries(name)) {\n\t\t\t// @ts-ignore\n\t\t\terror.prototype[ERROR_CODE] = code as any\n\n\t\t\tthis.definitions.error[code] = error as any\n\t\t}\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### Error | Life cycle event\n\t * Called when error is thrown during processing request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onError(({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\tonError<const Schema extends RouteSchema>(\n\t\thandler: MaybeArray<\n\t\t\tErrorHandler<\n\t\t\t\tDefinitions['error'],\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### Error | Life cycle event\n\t * Called when error is thrown during processing request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onError(({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\tonError<\n\t\tconst Schema extends RouteSchema,\n\t\tconst Scope extends LifeCycleType\n\t>(\n\t\toptions: { as?: Scope },\n\t\thandler: MaybeArray<\n\t\t\tErrorHandler<\n\t\t\t\tDefinitions['error'],\n\t\t\t\tMergeSchema<\n\t\t\t\t\tSchema,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tScope extends 'global'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\tresolve: Singleton['resolve'] &\n\t\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t}\n\t\t\t\t\t: Scope extends 'scoped'\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\t\tderive: Singleton['derive'] &\n\t\t\t\t\t\t\t\t\tEphemeral['derive']\n\t\t\t\t\t\t\t\tresolve: Singleton['resolve'] &\n\t\t\t\t\t\t\t\t\tEphemeral['resolve']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: Singleton,\n\t\t\t\tScope extends 'global'\n\t\t\t\t\t? Ephemeral\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tderive: Partial<Ephemeral['derive']>\n\t\t\t\t\t\t\tresolve: Partial<Ephemeral['resolve']>\n\t\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t\t},\n\t\t\t\tScope extends 'global'\n\t\t\t\t\t? Ephemeral\n\t\t\t\t\t: Scope extends 'scoped'\n\t\t\t\t\t\t? Ephemeral\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tderive: Partial<Ephemeral['derive']>\n\t\t\t\t\t\t\t\tresolve: Partial<Ephemeral['resolve']>\n\t\t\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t\t\t}\n\t\t\t>\n\t\t>\n\t): this\n\n\t/**\n\t * ### Error | Life cycle event\n\t * Called when error is thrown during processing request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onError(({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\tonError(\n\t\toptions: { as?: LifeCycleType } | MaybeArray<Function>,\n\t\thandler?: MaybeArray<Function>\n\t) {\n\t\tif (!handler) return this.on('error', options as any)\n\n\t\treturn this.on(\n\t\t\toptions as { as?: LifeCycleType },\n\t\t\t'error',\n\t\t\thandler as any\n\t\t)\n\t}\n\n\t/**\n\t * ### stop | Life cycle event\n\t * Called after server stop serving request\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .onStop((app) => {\n\t * cleanup()\n\t * })\n\t * ```\n\t */\n\tonStop(handler: MaybeArray<GracefulHandler<this>>) {\n\t\tthis.on('stop', handler as any)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### on\n\t * Syntax sugar for attaching life cycle event by name\n\t *\n\t * Does the exact same thing as `.on[Event]()`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .on('error', ({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\ton<Event extends keyof LifeCycleStore>(\n\t\ttype: Event,\n\t\thandlers: MaybeArray<\n\t\t\tExtract<LifeCycleStore[Event], HookContainer[]>[0]['fn']\n\t\t>\n\t): this\n\n\t/**\n\t * ### on\n\t * Syntax sugar for attaching life cycle event by name\n\t *\n\t * Does the exact same thing as `.on[Event]()`\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .on('error', ({ code }) => {\n\t * if(code === \"NOT_FOUND\")\n\t * return \"Path not found :(\"\n\t * })\n\t * ```\n\t */\n\ton<const Event extends keyof LifeCycleStore>(\n\t\toptions: { as?: LifeCycleType },\n\t\ttype: Event,\n\t\thandlers: MaybeArray<Extract<LifeCycleStore[Event], Function[]>[0]>\n\t): this\n\n\ton(\n\t\toptionsOrType: { as?: LifeCycleType } | string,\n\t\ttypeOrHandlers: MaybeArray<Function | HookContainer> | string,\n\t\thandlers?: MaybeArray<Function | HookContainer>\n\t) {\n\t\tlet type: keyof LifeCycleStore\n\n\t\tswitch (typeof optionsOrType) {\n\t\t\tcase 'string':\n\t\t\t\ttype = optionsOrType as any\n\t\t\t\thandlers = typeOrHandlers as any\n\n\t\t\t\tbreak\n\n\t\t\tcase 'object':\n\t\t\t\ttype = typeOrHandlers as any\n\n\t\t\t\tif (\n\t\t\t\t\t!Array.isArray(typeOrHandlers) &&\n\t\t\t\t\ttypeof typeOrHandlers === 'object'\n\t\t\t\t)\n\t\t\t\t\thandlers = typeOrHandlers\n\n\t\t\t\tbreak\n\t\t}\n\n\t\tif (Array.isArray(handlers)) handlers = fnToContainer(handlers)\n\t\telse {\n\t\t\tif (typeof handlers === 'function')\n\t\t\t\thandlers = [\n\t\t\t\t\t{\n\t\t\t\t\t\tfn: handlers\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\telse handlers = [handlers!]\n\t\t}\n\n\t\tconst handles = handlers as HookContainer[]\n\n\t\tfor (const handle of handles) {\n\t\t\thandle.scope =\n\t\t\t\ttypeof optionsOrType === 'string'\n\t\t\t\t\t? 'local'\n\t\t\t\t\t: (optionsOrType?.as ?? 'local')\n\n\t\t\t// @ts-expect-error\n\t\t\tif (type === 'resolve' || type === 'derive') handle.subType = type\n\t\t}\n\n\t\tif (type !== 'trace')\n\t\t\tthis.inference = sucrose(\n\t\t\t\t{\n\t\t\t\t\t[type]: handles.map((x) => x.fn)\n\t\t\t\t},\n\t\t\t\tthis.inference\n\t\t\t)\n\n\t\tfor (const handle of handles) {\n\t\t\tconst fn = asHookType(handle, 'global', { skipIfHasType: true })\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'start':\n\t\t\t\t\tthis.event.start ??= []\n\t\t\t\t\tthis.event.start.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'request':\n\t\t\t\t\tthis.event.request ??= []\n\t\t\t\t\tthis.event.request.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'parse':\n\t\t\t\t\tthis.event.parse ??= []\n\t\t\t\t\tthis.event.parse.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'transform':\n\t\t\t\t\tthis.event.transform ??= []\n\t\t\t\t\tthis.event.transform.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tcase 'derive':\n\t\t\t\t\tthis.event.transform ??= []\n\t\t\t\t\tthis.event.transform.push(\n\t\t\t\t\t\tfnToContainer(fn as any, 'derive') as any\n\t\t\t\t\t)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'beforeHandle':\n\t\t\t\t\tthis.event.beforeHandle ??= []\n\t\t\t\t\tthis.event.beforeHandle.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\t// eslint-disable-next-line sonarjs/no-duplicated-branches\n\t\t\t\tcase 'resolve':\n\t\t\t\t\tthis.event.beforeHandle ??= []\n\t\t\t\t\tthis.event.beforeHandle.push(\n\t\t\t\t\t\tfnToContainer(fn as any, 'resolve') as any\n\t\t\t\t\t)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'afterHandle':\n\t\t\t\t\tthis.event.afterHandle ??= []\n\t\t\t\t\tthis.event.afterHandle.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'mapResponse':\n\t\t\t\t\tthis.event.mapResponse ??= []\n\t\t\t\t\tthis.event.mapResponse.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'afterResponse':\n\t\t\t\t\tthis.event.afterResponse ??= []\n\t\t\t\t\tthis.event.afterResponse.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'trace':\n\t\t\t\t\tthis.event.trace ??= []\n\t\t\t\t\tthis.event.trace.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'error':\n\t\t\t\t\tthis.event.error ??= []\n\t\t\t\t\tthis.event.error.push(fn as any)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'stop':\n\t\t\t\t\tthis.event.stop ??= []\n\t\t\t\t\tthis.event.stop.push(fn as any)\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\treturn this\n\t}\n\n\tas(type: 'global'): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Prettify<\n\t\t\t\tSingleton['derive'] & Ephemeral['derive'] & Volatile['derive']\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\tVolatile['resolve']\n\t\t\t>\n\t\t},\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: MergeSchema<\n\t\t\t\tMergeSchema<Volatile['schema'], Ephemeral['schema']>,\n\t\t\t\tMetadata['schema']\n\t\t\t>\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro']\n\t\t\tmacroFn: Metadata['macroFn']\n\t\t\tparser: Metadata['parser']\n\t\t},\n\t\tRoutes,\n\t\t{\n\t\t\tderive: {}\n\t\t\tresolve: {}\n\t\t\tschema: {}\n\t\t\tstandaloneSchema: {}\n\t\t},\n\t\t{\n\t\t\tderive: {}\n\t\t\tresolve: {}\n\t\t\tschema: {}\n\t\t\tstandaloneSchema: {}\n\t\t}\n\t>\n\n\tas(type: 'scoped'): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\t{\n\t\t\tderive: Prettify<Ephemeral['derive'] & Volatile['derive']>\n\t\t\tresolve: Prettify<Ephemeral['resolve'] & Volatile['resolve']>\n\t\t\tschema: MergeSchema<Volatile['schema'], Ephemeral['schema']>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tVolatile['standaloneSchema'] & Ephemeral['standaloneSchema']\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\tderive: {}\n\t\t\tresolve: {}\n\t\t\tschema: {}\n\t\t\tstandaloneSchema: {}\n\t\t}\n\t>\n\n\tas(type: 'global' | 'scoped') {\n\t\tpromoteEvent(this.event.parse, type)\n\t\tpromoteEvent(this.event.transform, type)\n\t\tpromoteEvent(this.event.beforeHandle, type)\n\t\tpromoteEvent(this.event.afterHandle, type)\n\t\tpromoteEvent(this.event.mapResponse, type)\n\t\tpromoteEvent(this.event.afterResponse, type)\n\t\tpromoteEvent(this.event.trace, type)\n\t\tpromoteEvent(this.event.error, type)\n\n\t\tif (type === 'scoped') {\n\t\t\tthis.validator.scoped = mergeSchemaValidator(\n\t\t\t\tthis.validator.scoped,\n\t\t\t\tthis.validator.local\n\t\t\t)\n\t\t\tthis.validator.local = null\n\n\t\t\tif (this.standaloneValidator.local !== null) {\n\t\t\t\tthis.standaloneValidator.scoped ||= []\n\t\t\t\tthis.standaloneValidator.scoped.push(\n\t\t\t\t\t...this.standaloneValidator.local\n\t\t\t\t)\n\t\t\t\tthis.standaloneValidator.local = null\n\t\t\t}\n\t\t} else if (type === 'global') {\n\t\t\tthis.validator.global = mergeSchemaValidator(\n\t\t\t\tthis.validator.global,\n\t\t\t\tmergeSchemaValidator(\n\t\t\t\t\tthis.validator.scoped,\n\t\t\t\t\tthis.validator.local\n\t\t\t\t) as SchemaValidator\n\t\t\t) as SchemaValidator\n\n\t\t\tthis.validator.scoped = null\n\t\t\tthis.validator.local = null\n\n\t\t\tif (this.standaloneValidator.local !== null) {\n\t\t\t\tthis.standaloneValidator.scoped ||= []\n\t\t\t\tthis.standaloneValidator.scoped.push(\n\t\t\t\t\t...this.standaloneValidator.local\n\t\t\t\t)\n\t\t\t\tthis.standaloneValidator.local = null\n\t\t\t}\n\t\t\tif (this.standaloneValidator.scoped !== null) {\n\t\t\t\tthis.standaloneValidator.global ||= []\n\t\t\t\tthis.standaloneValidator.global.push(\n\t\t\t\t\t...this.standaloneValidator.scoped\n\t\t\t\t)\n\t\t\t\tthis.standaloneValidator.scoped = null\n\t\t\t}\n\t\t}\n\n\t\treturn this as any\n\t}\n\n\tgroup<const Prefix extends string, const NewElysia extends AnyElysia>(\n\t\tprefix: Prefix,\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tJoinPath<BasePath, Prefix>,\n\t\t\t\tSingleton,\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: MergeSchema<\n\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\tJoinPath<BasePath, Prefix>\n\t\t\t\t\t\t>,\n\t\t\t\t\t\tMetadata['schema']\n\t\t\t\t\t>\n\t\t\t\t\tstandaloneSchema: Prettify<\n\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\tJoinPath<BasePath, Prefix>\n\t\t\t\t\t\t> &\n\t\t\t\t\t\t\tMetadata['standaloneSchema']\n\t\t\t\t\t>\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tPrettify<Routes & NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tgroup<\n\t\tconst Prefix extends string,\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Input extends InputSchema<keyof Definitions['typebox'] & string>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tInput,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Prefix>\n\t\t\t>,\n\t\t\tMetadata['schema']\n\t\t> &\n\t\t\tMetadata['standaloneSchema'],\n\t\tconst Resolutions extends MaybeArray<\n\t\t\tResolveHandler<\n\t\t\t\tSchema,\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t>(\n\t\tprefix: Prefix,\n\t\tschema: LocalHook<\n\t\t\tInput,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMetadata['macro'],\n\t\t\tkeyof Metadata['parser']\n\t\t>,\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tJoinPath<BasePath, Prefix>,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\tSingleton['derive'] &\n\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t>\n\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\tResolveResolutions<Resolutions>\n\t\t\t\t\t>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: Prettify<Schema>\n\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes & NewElysia['~Routes'],\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### group\n\t * Encapsulate and group path with prefix\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .group('/v1', app => app\n\t * .get('/', () => 'Hi')\n\t * .get('/name', () => 'Elysia')\n\t * })\n\t * ```\n\t */\n\tgroup(\n\t\tprefix: string,\n\t\tschemaOrRun: AnyLocalHook | ((group: AnyElysia) => AnyElysia),\n\t\trun?: (group: AnyElysia) => AnyElysia\n\t): AnyElysia {\n\t\tconst instance = new Elysia({\n\t\t\t...this.config,\n\t\t\tprefix: ''\n\t\t})\n\n\t\tinstance.singleton = { ...this.singleton }\n\t\tinstance.definitions = { ...this.definitions }\n\t\tinstance.getServer = () => this.getServer()\n\t\tinstance.inference = cloneInference(this.inference)\n\t\tinstance.extender = { ...this.extender }\n\t\tinstance['~parser'] = this['~parser']\n\t\tinstance.standaloneValidator = {\n\t\t\tlocal: [...(this.standaloneValidator.local ?? [])],\n\t\t\tscoped: [...(this.standaloneValidator.scoped ?? [])],\n\t\t\tglobal: [...(this.standaloneValidator.global ?? [])]\n\t\t}\n\n\t\tconst isSchema = typeof schemaOrRun === 'object'\n\t\tconst sandbox = (isSchema ? run! : schemaOrRun)(instance)\n\t\tthis.singleton = mergeDeep(this.singleton, instance.singleton) as any\n\t\tthis.definitions = mergeDeep(this.definitions, instance.definitions)\n\n\t\tif (sandbox.event.request?.length)\n\t\t\tthis.event.request = [\n\t\t\t\t...(this.event.request || []),\n\t\t\t\t...((sandbox.event.request || []) as any)\n\t\t\t]\n\n\t\tif (sandbox.event.mapResponse?.length)\n\t\t\tthis.event.mapResponse = [\n\t\t\t\t...(this.event.mapResponse || []),\n\t\t\t\t...((sandbox.event.mapResponse || []) as any)\n\t\t\t]\n\n\t\tthis.model(sandbox.definitions.type)\n\n\t\tObject.values(instance.router.history).forEach(\n\t\t\t({ method, path, handler, hooks, standaloneValidators }) => {\n\t\t\t\tpath =\n\t\t\t\t\t(isSchema ? '' : (this.config.prefix ?? '')) + prefix + path\n\n\t\t\t\tif (isSchema) {\n\t\t\t\t\tconst hook = schemaOrRun\n\t\t\t\t\tconst localHook = hooks as AnyLocalHook\n\n\t\t\t\t\tthis.add(\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\thandler,\n\t\t\t\t\t\tmergeHook(hook, {\n\t\t\t\t\t\t\t...(localHook || {}),\n\t\t\t\t\t\t\terror: !localHook.error\n\t\t\t\t\t\t\t\t? sandbox.event.error\n\t\t\t\t\t\t\t\t: Array.isArray(localHook.error)\n\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t...(localHook.error ?? []),\n\t\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\tlocalHook.error,\n\t\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tthis.add(\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\thandler,\n\t\t\t\t\t\tmergeHook(hooks as AnyLocalHook, {\n\t\t\t\t\t\t\terror: sandbox.event.error\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tskipPrefix: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\n\t\treturn this as any\n\t}\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>,\n\t\tconst GuardType extends GuardSchemaType,\n\t\tconst AsType extends LifeCycleType\n\t>(\n\t\thook: {\n\t\t\t/**\n\t\t\t * @default 'override'\n\t\t\t */\n\t\t\tas?: AsType\n\t\t\t/**\n\t\t\t * @default 'standalone'\n\t\t\t * @since 1.3.0\n\t\t\t */\n\t\t\tschema?: GuardType\n\t\t} & LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Or<\n\t\tGuardSchemaType extends GuardType ? true : false,\n\t\tGuardType extends 'override' ? true : false\n\t> extends true\n\t\t? Or<\n\t\t\t\tLifeCycleType extends AsType ? true : false,\n\t\t\t\tAsType extends 'local' ? true : false\n\t\t\t> extends true\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\t\t\t\tschema: Prettify<\n\t\t\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\t\tDefinitions['typebox']\n\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\tMetadata['schema']\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t: AsType extends 'global'\n\t\t\t\t? Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tSingleton['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t},\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tschema: Prettify<\n\t\t\t\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\t\t\t\tBasePath\n\t\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\t\tMetadata['schema']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\tEphemeral,\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\t\t\t\t: Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\tSingleton,\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\tMetadata,\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tEphemeral['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tschema: Prettify<\n\t\t\t\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\t\t\t\tUnwrapRoute<\n\t\t\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\t\t\tDefinitions['typebox']\n\t\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\t\tMetadata['schema'] & Ephemeral['schema']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\t\t: Or<\n\t\t\t\t\tLifeCycleType extends AsType ? true : false,\n\t\t\t\t\tAsType extends 'local' ? true : false\n\t\t\t > extends true\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema'] &\n\t\t\t\t\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox']>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t: AsType extends 'global'\n\t\t\t\t? Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tSingleton['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t},\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tschema: Metadata['schema']\n\t\t\t\t\t\t\tstandaloneSchema: UnwrapRoute<\n\t\t\t\t\t\t\t\tLocalSchema,\n\t\t\t\t\t\t\t\tDefinitions['typebox'],\n\t\t\t\t\t\t\t\tBasePath\n\t\t\t\t\t\t\t> &\n\t\t\t\t\t\t\t\tMetadata['standaloneSchema']\n\t\t\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\tEphemeral,\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\t\t\t\t: Elysia<\n\t\t\t\t\t\tBasePath,\n\t\t\t\t\t\tSingleton,\n\t\t\t\t\t\tDefinitions,\n\t\t\t\t\t\tMetadata,\n\t\t\t\t\t\tRoutes,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\t\tEphemeral['resolve'] & MacroContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema'] &\n\t\t\t\t\t\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox']>\n\t\t\t\t\t\t},\n\t\t\t\t\t\tVolatile\n\t\t\t\t\t>\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>\n\t>(\n\t\thook: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\tMacroContext\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\tschema: Prettify<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t>\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t}\n\t>\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>\n\t>(\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Singleton['resolve'] & MacroContext\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: Prettify<Schema>\n\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tPrettify<Routes & NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tguard<\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<LocalSchema, Definitions['typebox'], BasePath>,\n\t\t\tMetadata['schema']\n\t\t>,\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst MacroContext extends MacroToContext<\n\t\t\tMetadata['macroFn'],\n\t\t\tNoInfer<Macro>\n\t\t>\n\t>(\n\t\tschema: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t},\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>,\n\t\trun: (\n\t\t\tgroup: Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Prettify<Singleton['resolve'] & MacroContext>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\t{\n\t\t\t\t\tschema: Prettify<Schema>\n\t\t\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\t\t\tmacro: Metadata['macro']\n\t\t\t\t\tmacroFn: Metadata['macroFn']\n\t\t\t\t\tparser: Metadata['parser']\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tPrettify<Routes & NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Volatile['derive']\n\t\t\tresolve: Prettify<Volatile['resolve'] & MacroContext>\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\t/**\n\t * ### guard\n\t * Encapsulate and pass hook into all child handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .guard({\n\t * schema: {\n\t * body: t.Object({\n\t * username: t.String(),\n\t * password: t.String()\n\t * })\n\t * }\n\t * }, app => app\n\t * .get(\"/\", () => 'Hi')\n\t * .get(\"/name\", () => 'Elysia')\n\t * })\n\t * ```\n\t */\n\tguard(\n\t\thook:\n\t\t\t| (AnyLocalHook & {\n\t\t\t\t\tas: LifeCycleType\n\t\t\t })\n\t\t\t| ((group: AnyElysia) => AnyElysia),\n\t\trun?: (group: AnyElysia) => AnyElysia\n\t): AnyElysia {\n\t\tif (!run) {\n\t\t\tif (typeof hook === 'object') {\n\t\t\t\tthis.applyMacro(hook)\n\n\t\t\t\tif (hook.detail) {\n\t\t\t\t\tif (this.config.detail)\n\t\t\t\t\t\tthis.config.detail = mergeDeep(\n\t\t\t\t\t\t\tObject.assign({}, this.config.detail),\n\t\t\t\t\t\t\thook.detail\n\t\t\t\t\t\t)\n\t\t\t\t\telse this.config.detail = hook.detail\n\t\t\t\t}\n\n\t\t\t\tif (hook.tags) {\n\t\t\t\t\tif (!this.config.detail)\n\t\t\t\t\t\tthis.config.detail = {\n\t\t\t\t\t\t\ttags: hook.tags\n\t\t\t\t\t\t}\n\t\t\t\t\telse this.config.detail.tags = hook.tags\n\t\t\t\t}\n\n\t\t\t\tconst type: LifeCycleType = hook.as ?? 'local'\n\n\t\t\t\tif (hook.schema === 'standalone') {\n\t\t\t\t\tif (!this.standaloneValidator[type])\n\t\t\t\t\t\tthis.standaloneValidator[type] = []\n\n\t\t\t\t\tconst response =\n\t\t\t\t\t\thook?.response ||\n\t\t\t\t\t\ttypeof hook?.response === 'string' ||\n\t\t\t\t\t\t(hook?.response && Kind in hook.response)\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t200: hook.response\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: hook?.response\n\n\t\t\t\t\tthis.standaloneValidator[type].push({\n\t\t\t\t\t\tbody: hook.body,\n\t\t\t\t\t\theaders: hook.headers,\n\t\t\t\t\t\tparams: hook.params,\n\t\t\t\t\t\tquery: hook.query,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tcookie: hook.cookie\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tthis.validator[type] = {\n\t\t\t\t\t\tbody: hook.body ?? this.validator[type]?.body,\n\t\t\t\t\t\theaders: hook.headers ?? this.validator[type]?.headers,\n\t\t\t\t\t\tparams: hook.params ?? this.validator[type]?.params,\n\t\t\t\t\t\tquery: hook.query ?? this.validator[type]?.query,\n\t\t\t\t\t\tresponse:\n\t\t\t\t\t\t\thook.response ?? this.validator[type]?.response,\n\t\t\t\t\t\tcookie: hook.cookie ?? this.validator[type]?.cookie\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (hook.parse) this.on({ as: type }, 'parse', hook.parse)\n\t\t\t\tif (hook.transform)\n\t\t\t\t\tthis.on({ as: type }, 'transform', hook.transform)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (hook.derive) this.on({ as: type }, 'derive', hook.derive)\n\t\t\t\tif (hook.beforeHandle)\n\t\t\t\t\tthis.on({ as: type }, 'beforeHandle', hook.beforeHandle)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (hook.resolve) this.on({ as: type }, 'resolve', hook.resolve)\n\t\t\t\tif (hook.afterHandle)\n\t\t\t\t\tthis.on({ as: type }, 'afterHandle', hook.afterHandle)\n\t\t\t\tif (hook.mapResponse)\n\t\t\t\t\tthis.on({ as: type }, 'mapResponse', hook.mapResponse)\n\t\t\t\tif (hook.afterResponse)\n\t\t\t\t\tthis.on({ as: type }, 'afterResponse', hook.afterResponse)\n\t\t\t\tif (hook.error) this.on({ as: type }, 'error', hook.error)\n\n\t\t\t\treturn this\n\t\t\t}\n\n\t\t\treturn this.guard({} as any, hook)\n\t\t}\n\n\t\tconst instance = new Elysia({\n\t\t\t...this.config,\n\t\t\tprefix: ''\n\t\t})\n\t\tinstance.singleton = { ...this.singleton }\n\t\tinstance.definitions = { ...this.definitions }\n\t\tinstance.inference = cloneInference(this.inference)\n\t\tinstance.extender = { ...this.extender }\n\t\tinstance.getServer = () => this.getServer()\n\n\t\tconst sandbox = run(instance)\n\t\tthis.singleton = mergeDeep(this.singleton, instance.singleton) as any\n\t\tthis.definitions = mergeDeep(this.definitions, instance.definitions)\n\n\t\t// ? Inject getServer for websocket and trace (important, do not remove)\n\t\tsandbox.getServer = () => this.server\n\n\t\tif (sandbox.event.request?.length)\n\t\t\tthis.event.request = [\n\t\t\t\t...(this.event.request || []),\n\t\t\t\t...(sandbox.event.request || [])\n\t\t\t]\n\n\t\tif (sandbox.event.mapResponse?.length)\n\t\t\tthis.event.mapResponse = [\n\t\t\t\t...(this.event.mapResponse || []),\n\t\t\t\t...(sandbox.event.mapResponse || [])\n\t\t\t]\n\n\t\tthis.model(sandbox.definitions.type)\n\n\t\tObject.values(instance.router.history).forEach(\n\t\t\t({ method, path, handler, hooks: localHook }) => {\n\t\t\t\tthis.add(\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath,\n\t\t\t\t\thandler,\n\t\t\t\t\tmergeHook(hook as AnyLocalHook, {\n\t\t\t\t\t\t...((localHook || {}) as AnyLocalHook),\n\t\t\t\t\t\terror: !localHook.error\n\t\t\t\t\t\t\t? sandbox.event.error\n\t\t\t\t\t\t\t: Array.isArray(localHook.error)\n\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t...(localHook.error ?? []),\n\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\tlocalHook.error,\n\t\t\t\t\t\t\t\t\t\t...(sandbox.event.error ?? [])\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t}\n\t\t)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * Inline fn\n\t */\n\tuse<\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Param extends AnyElysia = this\n\t>(\n\t\tplugin: (app: Param) => NewElysia\n\t): Elysia<\n\t\tBasePath,\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Singleton & NewElysia['~Singleton']>,\n\t\tPrettify<Definitions & NewElysia['~Definitions']>,\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\tPrettify2<Ephemeral & NewElysia['~Ephemeral']>,\n\t\tPrettify2<Volatile & NewElysia['~Volatile']>\n\t>\n\n\t/**\n\t * Inline async fn\n\t */\n\tuse<\n\t\tconst NewElysia extends AnyElysia,\n\t\tconst Param extends AnyElysia = this\n\t>(\n\t\tplugin:\n\t\t\t| ((app: Param) => Promise<NewElysia>)\n\t\t\t| Promise<(app: Param) => NewElysia>\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<\n\t\t\t\tSingleton['decorator'] &\n\t\t\t\t\tPartial<NewElysia['~Singleton']['decorator']>\n\t\t\t>\n\t\t\tstore: Prettify<\n\t\t\t\tSingleton['store'] & Partial<NewElysia['~Singleton']['store']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tSingleton['derive'] & Partial<NewElysia['~Singleton']['derive']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\tPartial<NewElysia['~Singleton']['resolve']>\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\terror: Prettify<\n\t\t\t\tDefinitions['error'] & NewElysia['~Definitions']['error']\n\t\t\t>\n\t\t\ttypebox: Prettify<\n\t\t\t\tDefinitions['typebox'] & NewElysia['~Definitions']['typebox']\n\t\t\t>\n\t\t},\n\t\t// @ts-expect-error this is truly ideal\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\t{\n\t\t\tschema: Prettify<\n\t\t\t\tEphemeral['schema'] & Partial<NewElysia['~Ephemeral']['schema']>\n\t\t\t>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tPartial<NewElysia['~Ephemeral']['standaloneSchema']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\tPartial<NewElysia['~Ephemeral']['resolve']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tEphemeral['derive'] & Partial<NewElysia['~Ephemeral']['derive']>\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\tschema: Prettify<\n\t\t\t\tVolatile['schema'] & Partial<NewElysia['~Volatile']['schema']>\n\t\t\t>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\tPartial<NewElysia['~Volatile']['standaloneSchema']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tVolatile['resolve'] & Partial<NewElysia['~Volatile']['resolve']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tVolatile['derive'] & Partial<NewElysia['~Volatile']['derive']>\n\t\t\t>\n\t\t}\n\t>\n\n\t/**\n\t * Entire Instance\n\t **/\n\tuse<const NewElysia extends AnyElysia>(\n\t\tinstance: MaybePromise<NewElysia>\n\t): Elysia<\n\t\tBasePath,\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Singleton & NewElysia['~Singleton']>,\n\t\tPrettify2<Definitions & NewElysia['~Definitions']>,\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\tEphemeral,\n\t\tPrettify2<Volatile & NewElysia['~Ephemeral']>\n\t>\n\n\t/**\n\t * Entire multiple Instance\n\t **/\n\tuse<const Instances extends AnyElysia[]>(\n\t\tinstance: MaybePromise<Instances>\n\t): MergeElysiaInstances<Instances, BasePath>\n\n\t/**\n\t * Import fn\n\t */\n\tuse<const NewElysia extends AnyElysia>(\n\t\tplugin: Promise<{\n\t\t\tdefault: (elysia: AnyElysia) => MaybePromise<NewElysia>\n\t\t}>\n\t): Elysia<\n\t\tBasePath,\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Singleton & NewElysia['~Singleton']>,\n\t\t{\n\t\t\terror: Prettify<\n\t\t\t\tDefinitions['error'] & NewElysia['~Definitions']['error']\n\t\t\t>\n\t\t\ttypebox: Prettify<\n\t\t\t\tDefinitions['typebox'] & NewElysia['~Definitions']['typebox']\n\t\t\t>\n\t\t},\n\t\tPrettify2<Metadata & NewElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & NewElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, NewElysia['~Routes']>,\n\t\tPrettify2<Ephemeral & NewElysia['~Ephemeral']>,\n\t\tPrettify2<Volatile & NewElysia['~Volatile']>\n\t>\n\n\t/**\n\t * Import entire instance\n\t */\n\tuse<const LazyLoadElysia extends AnyElysia>(\n\t\tplugin: Promise<{\n\t\t\tdefault: LazyLoadElysia\n\t\t}>\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<\n\t\t\t\tSingleton['decorator'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['decorator']>\n\t\t\t>\n\t\t\tstore: Prettify<\n\t\t\t\tSingleton['store'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['store']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tSingleton['derive'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['derive']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Singleton']['resolve']>\n\t\t\t>\n\t\t},\n\t\t{\n\t\t\terror: Prettify<\n\t\t\t\tDefinitions['error'] & LazyLoadElysia['~Definitions']['error']\n\t\t\t>\n\t\t\ttypebox: Prettify<\n\t\t\t\tDefinitions['typebox'] &\n\t\t\t\t\tLazyLoadElysia['~Definitions']['typebox']\n\t\t\t>\n\t\t},\n\t\t// @ts-expect-error - This is truly ideal\n\t\tPrettify2<Metadata & LazyLoadElysia['~Metadata']>,\n\t\tBasePath extends ``\n\t\t\t? Routes & LazyLoadElysia['~Routes']\n\t\t\t: Routes & CreateEden<BasePath, LazyLoadElysia['~Routes']>,\n\t\tEphemeral,\n\t\tPrettify2<{\n\t\t\tschema: Prettify<\n\t\t\t\tVolatile['schema'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['schema']>\n\t\t\t>\n\t\t\tstandaloneSchema: PrettifySchema<\n\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['standaloneSchema']>\n\t\t\t>\n\t\t\tresolve: Prettify<\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['resolve']>\n\t\t\t>\n\t\t\tderive: Prettify<\n\t\t\t\tVolatile['derive'] &\n\t\t\t\t\tPartial<LazyLoadElysia['~Ephemeral']['derive']>\n\t\t\t>\n\t\t}>\n\t>\n\n\t/**\n\t * conditional undefined ignore type\n\t */\n\tuse(\n\t\tinstance:\n\t\t\t| MaybeArray<MaybePromise<AnyElysia>>\n\t\t\t| MaybePromise<\n\t\t\t\t\tAnyElysia | ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t >\n\t\t\t| Promise<{\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t| AnyElysia\n\t\t\t\t\t\t| ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t }>\n\t\t\t| undefined\n\t\t\t| false\n\t): this\n\n\t/**\n\t * ### use\n\t * Merge separate logic of Elysia with current\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * const plugin = (app: Elysia) => app\n\t * .get('/plugin', () => 'hi')\n\t *\n\t * new Elysia()\n\t * .use(plugin)\n\t * ```\n\t */\n\tuse(\n\t\tplugin:\n\t\t\t| MaybeArray<MaybePromise<AnyElysia>>\n\t\t\t| MaybePromise<\n\t\t\t\t\tAnyElysia | ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t >\n\t\t\t| Promise<{\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t| AnyElysia\n\t\t\t\t\t\t| ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t\t\t }>\n\t\t\t| undefined\n\t\t\t| false\n\t): AnyElysia {\n\t\tif (!plugin) return this\n\n\t\tif (Array.isArray(plugin)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\n\t\t\tlet app = this\n\t\t\tfor (const p of plugin) app = app.use(p) as any\n\t\t\treturn app\n\t\t}\n\n\t\tif (plugin instanceof Promise) {\n\t\t\tthis.promisedModules.add(\n\t\t\t\tplugin\n\t\t\t\t\t.then((plugin) => {\n\t\t\t\t\t\tif (typeof plugin === 'function') return plugin(this)\n\n\t\t\t\t\t\tif (plugin instanceof Elysia)\n\t\t\t\t\t\t\treturn this._use(plugin).compile()\n\n\t\t\t\t\t\tif (plugin.constructor?.name === 'Elysia')\n\t\t\t\t\t\t\treturn this._use(\n\t\t\t\t\t\t\t\tplugin as unknown as Elysia\n\t\t\t\t\t\t\t).compile()\n\n\t\t\t\t\t\tif (typeof plugin.default === 'function')\n\t\t\t\t\t\t\treturn plugin.default(this)\n\n\t\t\t\t\t\tif (plugin.default instanceof Elysia)\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\n\t\t\t\t\t\tif (plugin.constructor?.name === 'Elysia')\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\n\t\t\t\t\t\tif (plugin.constructor?.name === '_Elysia')\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn this._use(plugin.default)\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t'Invalid plugin type. Expected Elysia instance, function, or module with \"default\" as Elysia instance or function that returns Elysia instance.'\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tthrow error\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.then((v) => {\n\t\t\t\t\t\tif (v && typeof v.compile === 'function') v.compile()\n\n\t\t\t\t\t\treturn v\n\t\t\t\t\t})\n\t\t\t)\n\n\t\t\treturn this\n\t\t}\n\n\t\treturn this._use(plugin)\n\t}\n\n\tprivate propagatePromiseModules(plugin: Elysia) {\n\t\tif (plugin.promisedModules.size <= 0) return this\n\n\t\tfor (const promise of plugin.promisedModules.promises)\n\t\t\tthis.promisedModules.add(\n\t\t\t\tpromise.then((v) => {\n\t\t\t\t\tif (!v) return\n\n\t\t\t\t\tconst t = this._use(v)\n\t\t\t\t\tif (t instanceof Promise)\n\t\t\t\t\t\treturn t.then((v2) => {\n\t\t\t\t\t\t\tif (v2) v2.compile()\n\t\t\t\t\t\t\telse v.compile()\n\t\t\t\t\t\t})\n\n\t\t\t\t\treturn v.compile()\n\t\t\t\t})\n\t\t\t)\n\n\t\treturn this\n\t}\n\n\tprivate _use(\n\t\tplugin: AnyElysia | ((app: AnyElysia) => MaybePromise<AnyElysia>)\n\t) {\n\t\tif (typeof plugin === 'function') {\n\t\t\tconst instance = plugin(this as unknown as any) as unknown as any\n\n\t\t\tif (instance instanceof Promise) {\n\t\t\t\tthis.promisedModules.add(\n\t\t\t\t\tinstance\n\t\t\t\t\t\t.then((plugin) => {\n\t\t\t\t\t\t\tif (plugin instanceof Elysia) {\n\t\t\t\t\t\t\t\tplugin.getServer = () => this.getServer()\n\t\t\t\t\t\t\t\tplugin.getGlobalRoutes = () =>\n\t\t\t\t\t\t\t\t\tthis.getGlobalRoutes()\n\t\t\t\t\t\t\t\tplugin.getGlobalDefinitions = () =>\n\t\t\t\t\t\t\t\t\tthis.getGlobalDefinitions()\n\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Model and error is required for Swagger generation\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tplugin.model(this.definitions.type as any)\n\t\t\t\t\t\t\t\tplugin.error(this.definitions.error as any)\n\n\t\t\t\t\t\t\t\t// Recompile async plugin routes\n\t\t\t\t\t\t\t\tfor (const {\n\t\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\thandler,\n\t\t\t\t\t\t\t\t\thooks,\n\t\t\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t\t\t} of Object.values(plugin.router.history))\n\t\t\t\t\t\t\t\t\tthis.add(\n\t\t\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\t\thandler,\n\t\t\t\t\t\t\t\t\t\thooks,\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\tstandaloneValidators\n\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\tif (plugin === this) return\n\n\t\t\t\t\t\t\t\tthis.propagatePromiseModules(plugin)\n\n\t\t\t\t\t\t\t\treturn plugin\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (typeof plugin === 'function')\n\t\t\t\t\t\t\t\treturn plugin(\n\t\t\t\t\t\t\t\t\tthis as unknown as any\n\t\t\t\t\t\t\t\t) as unknown as Elysia\n\n\t\t\t\t\t\t\tif (typeof plugin.default === 'function')\n\t\t\t\t\t\t\t\treturn plugin.default(\n\t\t\t\t\t\t\t\t\tthis as unknown as any\n\t\t\t\t\t\t\t\t) as unknown as Elysia\n\n\t\t\t\t\t\t\treturn this._use(plugin)\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then((v) => {\n\t\t\t\t\t\t\tif (v && typeof v.compile === 'function')\n\t\t\t\t\t\t\t\tv.compile()\n\n\t\t\t\t\t\t\treturn v\n\t\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\treturn this as unknown as any\n\t\t\t}\n\n\t\t\treturn instance\n\t\t}\n\n\t\tthis.propagatePromiseModules(plugin)\n\n\t\tconst name = plugin.config.name\n\t\tconst seed = plugin.config.seed\n\n\t\tplugin.getParent = () => this as any\n\t\tplugin.getServer = () => this.getServer()\n\t\tplugin.getGlobalRoutes = () => this.getGlobalRoutes()\n\t\tplugin.getGlobalDefinitions = () => this.getGlobalDefinitions()\n\n\t\tif (plugin.standaloneValidator?.scoped) {\n\t\t\tif (this.standaloneValidator.local)\n\t\t\t\tthis.standaloneValidator.local =\n\t\t\t\t\tthis.standaloneValidator.local.concat(\n\t\t\t\t\t\tplugin.standaloneValidator.scoped\n\t\t\t\t\t)\n\t\t\telse\n\t\t\t\tthis.standaloneValidator.local =\n\t\t\t\t\tplugin.standaloneValidator.scoped\n\t\t}\n\n\t\tif (plugin.standaloneValidator?.global) {\n\t\t\tif (this.standaloneValidator.global)\n\t\t\t\tthis.standaloneValidator.global =\n\t\t\t\t\tthis.standaloneValidator.global.concat(\n\t\t\t\t\t\tplugin.standaloneValidator.global\n\t\t\t\t\t)\n\t\t\telse\n\t\t\t\tthis.standaloneValidator.global =\n\t\t\t\t\tplugin.standaloneValidator.global\n\t\t}\n\n\t\t/**\n\t\t * Model and error is required for Swagger generation\n\t\t */\n\t\t// plugin.model(this.definitions.type as any)\n\t\t// plugin.error(this.definitions.error as any)\n\n\t\tif (isNotEmpty(plugin['~parser']))\n\t\t\tthis['~parser'] = {\n\t\t\t\t...plugin['~parser'],\n\t\t\t\t...this['~parser']\n\t\t\t}\n\n\t\tif (plugin.setHeaders) this.headers(plugin.setHeaders)\n\n\t\tif (name) {\n\t\t\tif (!(name in this.dependencies)) this.dependencies[name] = []\n\n\t\t\tconst current =\n\t\t\t\tseed !== undefined ? checksum(name + JSON.stringify(seed)) : 0\n\n\t\t\tif (\n\t\t\t\t!this.dependencies[name].some(\n\t\t\t\t\t({ checksum }) => current === checksum\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthis.extender.macros = this.extender.macros.concat(\n\t\t\t\t\tplugin.extender.macros\n\t\t\t\t)\n\n\t\t\t\tthis.extender.higherOrderFunctions =\n\t\t\t\t\tthis.extender.higherOrderFunctions.concat(\n\t\t\t\t\t\tplugin.extender.higherOrderFunctions\n\t\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\tif (plugin.extender.macros.length)\n\t\t\t\tthis.extender.macros = this.extender.macros.concat(\n\t\t\t\t\tplugin.extender.macros\n\t\t\t\t)\n\n\t\t\tif (plugin.extender.higherOrderFunctions.length)\n\t\t\t\tthis.extender.higherOrderFunctions =\n\t\t\t\t\tthis.extender.higherOrderFunctions.concat(\n\t\t\t\t\t\tplugin.extender.higherOrderFunctions\n\t\t\t\t\t)\n\t\t}\n\n\t\t// ! Deduplicate current instance\n\t\tdeduplicateChecksum(this.extender.macros)\n\n\t\tif (plugin.extender.higherOrderFunctions.length) {\n\t\t\tdeduplicateChecksum(this.extender.higherOrderFunctions)\n\n\t\t\t// ! Deduplicate current instance\n\t\t\tconst hofHashes: number[] = []\n\t\t\tfor (\n\t\t\t\tlet i = 0;\n\t\t\t\ti < this.extender.higherOrderFunctions.length;\n\t\t\t\ti++\n\t\t\t) {\n\t\t\t\tconst hof = this.extender.higherOrderFunctions[i]\n\n\t\t\t\tif (hof.checksum) {\n\t\t\t\t\tif (hofHashes.includes(hof.checksum)) {\n\t\t\t\t\t\tthis.extender.higherOrderFunctions.splice(i, 1)\n\t\t\t\t\t\ti--\n\t\t\t\t\t}\n\n\t\t\t\t\thofHashes.push(hof.checksum)\n\t\t\t\t}\n\t\t\t}\n\t\t\thofHashes.length = 0\n\t\t}\n\n\t\tthis.inference = mergeInference(this.inference, plugin.inference)\n\n\t\tif (isNotEmpty(plugin.singleton.decorator))\n\t\t\tthis.decorate(plugin.singleton.decorator)\n\n\t\tif (isNotEmpty(plugin.singleton.store))\n\t\t\tthis.state(plugin.singleton.store)\n\n\t\tif (isNotEmpty(plugin.definitions.type))\n\t\t\tthis.model(plugin.definitions.type)\n\n\t\tif (isNotEmpty(plugin.definitions.error))\n\t\t\tthis.error(plugin.definitions.error as any)\n\n\t\tif (isNotEmpty(plugin.definitions.error))\n\t\t\tplugin.extender.macros = this.extender.macros.concat(\n\t\t\t\tplugin.extender.macros\n\t\t\t)\n\n\t\tfor (const {\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\thandler,\n\t\t\thooks,\n\t\t\tstandaloneValidators\n\t\t} of Object.values(plugin.router.history)) {\n\t\t\tthis.add(\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\thandler,\n\t\t\t\thooks,\n\t\t\t\tundefined,\n\t\t\t\tstandaloneValidators\n\t\t\t)\n\t\t}\n\n\t\tif (name) {\n\t\t\tif (!(name in this.dependencies)) this.dependencies[name] = []\n\n\t\t\tconst current =\n\t\t\t\tseed !== undefined ? checksum(name + JSON.stringify(seed)) : 0\n\n\t\t\tif (\n\t\t\t\tthis.dependencies[name].some(\n\t\t\t\t\t({ checksum }) => current === checksum\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn this\n\n\t\t\tthis.dependencies[name].push(\n\t\t\t\tthis.config?.analytic\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\tname: plugin.config.name,\n\t\t\t\t\t\t\tseed: plugin.config.seed,\n\t\t\t\t\t\t\tchecksum: current,\n\t\t\t\t\t\t\tdependencies: plugin.dependencies,\n\t\t\t\t\t\t\tstack: plugin.telemetry?.stack,\n\t\t\t\t\t\t\troutes: plugin.router.history,\n\t\t\t\t\t\t\tdecorators: plugin.singleton,\n\t\t\t\t\t\t\tstore: plugin.singleton.store,\n\t\t\t\t\t\t\terror: plugin.definitions.error,\n\t\t\t\t\t\t\tderive: plugin.event.transform\n\t\t\t\t\t\t\t\t?.filter((x) => x?.subType === 'derive')\n\t\t\t\t\t\t\t\t.map((x) => ({\n\t\t\t\t\t\t\t\t\tfn: x.toString(),\n\t\t\t\t\t\t\t\t\tstack: new Error().stack ?? ''\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tresolve: plugin.event.transform\n\t\t\t\t\t\t\t\t?.filter((x) => x?.subType === 'resolve')\n\t\t\t\t\t\t\t\t.map((x) => ({\n\t\t\t\t\t\t\t\t\tfn: x.toString(),\n\t\t\t\t\t\t\t\t\tstack: new Error().stack ?? ''\n\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t} as any)\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tname: plugin.config.name,\n\t\t\t\t\t\t\tseed: plugin.config.seed,\n\t\t\t\t\t\t\tchecksum: current,\n\t\t\t\t\t\t\tdependencies: plugin.dependencies\n\t\t\t\t\t\t}\n\t\t\t)\n\n\t\t\tif (isNotEmpty(plugin.event))\n\t\t\t\tthis.event = mergeLifeCycle(\n\t\t\t\t\tthis.event,\n\t\t\t\t\tfilterGlobalHook(plugin.event),\n\t\t\t\t\tcurrent\n\t\t\t\t)\n\t\t} else {\n\t\t\tif (isNotEmpty(plugin.event))\n\t\t\t\tthis.event = mergeLifeCycle(\n\t\t\t\t\tthis.event,\n\t\t\t\t\tfilterGlobalHook(plugin.event)\n\t\t\t\t)\n\t\t}\n\n\t\tif (plugin.validator.global)\n\t\t\t// @ts-ignore\n\t\t\tthis.validator.global = mergeHook(this.validator.global, {\n\t\t\t\t...plugin.validator.global\n\t\t\t}) as any\n\n\t\tif (plugin.validator.scoped)\n\t\t\t// @ts-ignore\n\t\t\tthis.validator.local = mergeHook(this.validator.local, {\n\t\t\t\t...plugin.validator.scoped\n\t\t\t})\n\n\t\treturn this\n\t}\n\n\tmacro<const NewMacro extends BaseMacroFn>(\n\t\tmacro: (\n\t\t\troute: MacroManager<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Partial<Ephemeral['derive'] & Volatile['derive']>\n\t\t\t\t\tresolve: Partial<Ephemeral['resolve'] & Volatile['resolve']>\n\t\t\t\t},\n\t\t\t\tDefinitions['error']\n\t\t\t>\n\t\t) => NewMacro\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: Metadata['schema']\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro'] & Partial<MacroToProperty<NewMacro>>\n\t\t\tmacroFn: Metadata['macroFn'] & NewMacro\n\t\t\tparser: Metadata['parser']\n\t\t},\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmacro<\n\t\tconst NewMacro extends HookMacroFn<\n\t\t\tMetadata['schema'],\n\t\t\tSingleton & {\n\t\t\t\tderive: Partial<Ephemeral['derive'] & Volatile['derive']>\n\t\t\t\tresolve: Partial<Ephemeral['resolve'] & Volatile['resolve']>\n\t\t\t},\n\t\t\tDefinitions['error']\n\t\t>\n\t>(\n\t\tmacro: NewMacro\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\t{\n\t\t\tschema: Metadata['schema']\n\t\t\tstandaloneSchema: Metadata['standaloneSchema']\n\t\t\tmacro: Metadata['macro'] & Partial<MacroToProperty<NewMacro>>\n\t\t\tmacroFn: Metadata['macroFn'] & NewMacro\n\t\t\tparser: Metadata['parser']\n\t\t},\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmacro(macro: Function | Record<keyof any, Function>) {\n\t\tif (typeof macro === 'function') {\n\t\t\tconst hook: MacroQueue = {\n\t\t\t\tchecksum: checksum(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tname: this.config.name,\n\t\t\t\t\t\tseed: this.config.seed,\n\t\t\t\t\t\tcontent: macro.toString()\n\t\t\t\t\t})\n\t\t\t\t),\n\t\t\t\tfn: macro as any\n\t\t\t}\n\n\t\t\tthis.extender.macros.push(hook)\n\t\t} else if (typeof macro === 'object') {\n\t\t\tfor (const name of Object.keys(macro))\n\t\t\t\tif (typeof macro[name] === 'object') {\n\t\t\t\t\tconst actualValue = { ...(macro[name] as Object) }\n\n\t\t\t\t\tmacro[name] = (v: boolean) => {\n\t\t\t\t\t\tif (v === true) return actualValue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tconst hook: MacroQueue = {\n\t\t\t\tchecksum: checksum(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tname: this.config.name,\n\t\t\t\t\t\tseed: this.config.seed,\n\t\t\t\t\t\tcontent: Object.entries(macro)\n\t\t\t\t\t\t\t.map(([k, v]) => `${k}+${v}`)\n\t\t\t\t\t\t\t.join(',')\n\t\t\t\t\t})\n\t\t\t\t),\n\t\t\t\tfn: () => macro\n\t\t\t}\n\n\t\t\tthis.extender.macros.push(hook)\n\t\t}\n\n\t\treturn this as any\n\t}\n\n\tmount(\n\t\thandle: ((request: Request) => MaybePromise<Response>) | AnyElysia,\n\t\tdetail?: { detail?: DocumentDecoration }\n\t): this\n\tmount(\n\t\tpath: string,\n\t\thandle: ((request: Request) => MaybePromise<Response>) | AnyElysia,\n\t\tdetail?: { detail?: DocumentDecoration }\n\t): this\n\n\tmount(\n\t\tpath:\n\t\t\t| string\n\t\t\t| ((request: Request) => MaybePromise<Response>)\n\t\t\t| AnyElysia,\n\t\thandleOrConfig?:\n\t\t\t| ((request: Request) => MaybePromise<Response>)\n\t\t\t| AnyElysia\n\t\t\t| { detail?: DocumentDecoration },\n\t\tconfig?: { detail?: DocumentDecoration }\n\t) {\n\t\tif (\n\t\t\tpath instanceof Elysia ||\n\t\t\ttypeof path === 'function' ||\n\t\t\tpath.length === 0 ||\n\t\t\tpath === '/'\n\t\t) {\n\t\t\tconst run =\n\t\t\t\ttypeof path === 'function'\n\t\t\t\t\t? path\n\t\t\t\t\t: path instanceof Elysia\n\t\t\t\t\t\t? path.compile().fetch\n\t\t\t\t\t\t: handleOrConfig instanceof Elysia\n\t\t\t\t\t\t\t? handleOrConfig.compile().fetch\n\t\t\t\t\t\t\t: typeof handleOrConfig === 'function'\n\t\t\t\t\t\t\t\t? handleOrConfig\n\t\t\t\t\t\t\t\t: (() => {\n\t\t\t\t\t\t\t\t\t\tthrow new Error('Invalid handler')\n\t\t\t\t\t\t\t\t\t})()\n\n\t\t\tconst handler: Handler = ({ request, path }) =>\n\t\t\t\trun(\n\t\t\t\t\tnew Request(replaceUrlPath(request.url, path), {\n\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\tcredentials: request.credentials,\n\t\t\t\t\t\treferrerPolicy: request.referrerPolicy as any,\n\t\t\t\t\t\tduplex: request.duplex,\n\t\t\t\t\t\tredirect: request.redirect,\n\t\t\t\t\t\tmode: request.mode,\n\t\t\t\t\t\tkeepalive: request.keepalive,\n\t\t\t\t\t\tintegrity: request.integrity,\n\t\t\t\t\t\tbody: request.body\n\t\t\t\t\t})\n\t\t\t\t)\n\n\t\t\tthis.route('ALL', '/*', handler as any, {\n\t\t\t\tparse: 'none',\n\t\t\t\t...config,\n\t\t\t\tdetail: {\n\t\t\t\t\t...config?.detail,\n\t\t\t\t\thide: true\n\t\t\t\t},\n\t\t\t\tconfig: {\n\t\t\t\t\tmount: run\n\t\t\t\t}\n\t\t\t})\n\n\t\t\treturn this\n\t\t}\n\n\t\tconst handle =\n\t\t\thandleOrConfig instanceof Elysia\n\t\t\t\t? handleOrConfig.compile().fetch\n\t\t\t\t: typeof handleOrConfig === 'function'\n\t\t\t\t\t? handleOrConfig\n\t\t\t\t\t: (() => {\n\t\t\t\t\t\t\tthrow new Error('Invalid handler')\n\t\t\t\t\t\t})()\n\n\t\tconst length = path.length - (path.endsWith('*') ? 1 : 0)\n\n\t\tconst handler: Handler = ({ request, path }) =>\n\t\t\thandle(\n\t\t\t\tnew Request(\n\t\t\t\t\treplaceUrlPath(request.url, path.slice(length) || '/'),\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\tcredentials: request.credentials,\n\t\t\t\t\t\treferrerPolicy: request.referrerPolicy as any,\n\t\t\t\t\t\tduplex: request.duplex,\n\t\t\t\t\t\tredirect: request.redirect,\n\t\t\t\t\t\tmode: request.mode,\n\t\t\t\t\t\tkeepalive: request.keepalive,\n\t\t\t\t\t\tintegrity: request.integrity,\n\t\t\t\t\t\tbody: request.body\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t)\n\n\t\tthis.route('ALL', path, handler as any, {\n\t\t\tparse: 'none',\n\t\t\t...config,\n\t\t\tdetail: {\n\t\t\t\t...config?.detail,\n\t\t\t\thide: true\n\t\t\t},\n\t\t\tconfig: {\n\t\t\t\tmount: handle\n\t\t\t}\n\t\t})\n\n\t\tthis.route(\n\t\t\t'ALL',\n\t\t\tpath + (path.endsWith('/') ? '*' : '/*'),\n\t\t\thandler as any,\n\t\t\t{\n\t\t\t\tparse: 'none',\n\t\t\t\t...config,\n\t\t\t\tdetail: {\n\t\t\t\t\t...config?.detail,\n\t\t\t\t\thide: true\n\t\t\t\t},\n\t\t\t\tconfig: {\n\t\t\t\t\tmount: handle\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### get\n\t * Register handler for path with method [GET]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .get('/', () => 'hi')\n\t * .get('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tget<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tget: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('GET', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### post\n\t * Register handler for path with method [POST]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .post('/', () => 'hi')\n\t * .post('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tpost<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tpost: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('POST', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### put\n\t * Register handler for path with method [PUT]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .put('/', () => 'hi')\n\t * .put('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tput<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tput: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('PUT', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### patch\n\t * Register handler for path with method [PATCH]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .patch('/', () => 'hi')\n\t * .patch('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tpatch<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tpatch: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('PATCH', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### delete\n\t * Register handler for path with method [DELETE]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .delete('/', () => 'hi')\n\t * .delete('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tdelete<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tdelete: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('DELETE', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### options\n\t * Register handler for path with method [POST]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .options('/', () => 'hi')\n\t * .options('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\toptions<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('OPTIONS', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### all\n\t * Register handler for path with method [ALL]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .all('/', () => 'hi')\n\t * .all('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tall<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\t[method in string]: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('ALL', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### head\n\t * Register handler for path with method [HEAD]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .head('/', () => 'hi')\n\t * .head('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\thead<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\thead: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('HEAD', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### connect\n\t * Register handler for path with method [CONNECT]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .connect('/', () => 'hi')\n\t * .connect('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\tconnect<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tconnect: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add('CONNECT', path, handler as any, hook)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### route\n\t * Register handler for path with method [ROUTE]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .route('/', () => 'hi')\n\t * .route('/with-hook', () => 'hi', {\n\t * response: t.String()\n\t * })\n\t * ```\n\t */\n\troute<\n\t\tconst Method extends HTTPMethod,\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t> &\n\t\t\tMetadata['standaloneSchema'] &\n\t\t\tEphemeral['standaloneSchema'] &\n\t\t\tVolatile['standaloneSchema'],\n\t\tconst Macro extends Metadata['macro'],\n\t\tconst Decorator extends Singleton & {\n\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\tVolatile['resolve'] &\n\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t},\n\t\tconst Handle extends InlineHandler<\n\t\t\tNoInfer<Schema>,\n\t\t\tDecorator,\n\t\t\tJoinPath<BasePath, Path>\n\t\t>\n\t>(\n\t\tmethod: Method,\n\t\tpath: Path,\n\t\thandler: Handle,\n\t\thook?: LocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tDecorator,\n\t\t\tDefinitions['error'],\n\t\t\tMacro,\n\t\t\tkeyof Metadata['parser']\n\t\t> & {\n\t\t\tconfig?: {\n\t\t\t\tallowMeta?: boolean\n\t\t\t\tmount?: Function\n\t\t\t}\n\t\t}\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\t[method in Method]: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: ComposeElysiaResponse<Schema, Handle>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tthis.add(method.toUpperCase(), path, handler as any, hook, hook?.config)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### ws\n\t * Register handler for path with method [ws]\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * import { Elysia, t } from 'elysia'\n\t *\n\t * new Elysia()\n\t * .ws('/', {\n\t * message(ws, message) {\n\t * ws.send(message)\n\t * }\n\t * })\n\t * ```\n\t */\n\tws<\n\t\tconst Path extends string,\n\t\tconst LocalSchema extends InputSchema<\n\t\t\tkeyof Definitions['typebox'] & string\n\t\t>,\n\t\tconst Schema extends MergeSchema<\n\t\t\tUnwrapRoute<\n\t\t\t\tLocalSchema,\n\t\t\t\tDefinitions['typebox'],\n\t\t\t\tJoinPath<BasePath, Path>\n\t\t\t>,\n\t\t\tMergeSchema<\n\t\t\t\tVolatile['schema'],\n\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>\n\t\t\t>\n\t\t>,\n\t\tconst Macro extends Metadata['macro']\n\t>(\n\t\tpath: Path,\n\t\toptions: WSLocalHook<\n\t\t\tLocalSchema,\n\t\t\tSchema,\n\t\t\tSingleton & {\n\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\tMacroToContext<Metadata['macroFn'], Macro>\n\t\t\t},\n\t\t\tMacro\n\t\t>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes &\n\t\t\tCreateEden<\n\t\t\t\tJoinPath<BasePath, Path>,\n\t\t\t\t{\n\t\t\t\t\tsubscribe: {\n\t\t\t\t\t\tbody: Schema['body']\n\t\t\t\t\t\tparams: IsNever<keyof Schema['params']> extends true\n\t\t\t\t\t\t\t? ResolvePath<Path>\n\t\t\t\t\t\t\t: Schema['params']\n\t\t\t\t\t\tquery: Schema['query']\n\t\t\t\t\t\theaders: Schema['headers']\n\t\t\t\t\t\tresponse: {} extends Schema['response']\n\t\t\t\t\t\t\t? unknown\n\t\t\t\t\t\t\t: Schema['response'] extends { [200]: any }\n\t\t\t\t\t\t\t\t? Schema['response'][200]\n\t\t\t\t\t\t\t\t: unknown\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t>,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tif (this['~adapter'].ws) this['~adapter'].ws(this, path, options as any)\n\t\telse console.warn(`Current adapter doesn't support WebSocket`)\n\n\t\treturn this as any\n\t}\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state('counter', 0)\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<const Name extends string | number | symbol, Value>(\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Prettify<\n\t\t\t\tSingleton['store'] & {\n\t\t\t\t\t[name in Name]: Value\n\t\t\t\t}\n\t\t\t>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state({ counter: 0 })\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<Store extends Record<string, unknown>>(\n\t\tstore: Store\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Prettify<Singleton['store'] & Store>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state('counter', 0)\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<\n\t\tconst Type extends ContextAppendType,\n\t\tconst Name extends string | number | symbol,\n\t\tValue\n\t>(\n\t\toptions: { as: Type },\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Type extends 'override'\n\t\t\t\t? Reconcile<\n\t\t\t\t\t\tSingleton['store'],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue\n\t\t\t\t\t>\n\t\t\t\t: Prettify<\n\t\t\t\t\t\tSingleton['store'] & {\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state({ counter: 0 })\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate<\n\t\tconst Type extends ContextAppendType,\n\t\tStore extends Record<string, unknown>\n\t>(\n\t\toptions: { as: Type },\n\t\tstore: Store\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: Type extends 'override'\n\t\t\t\t? Reconcile<Singleton['store'], Store>\n\t\t\t\t: Prettify<Singleton['store'] & Store>\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tstate<NewStore extends Record<string, unknown>>(\n\t\tmapper: (decorators: Singleton['store']) => NewStore\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Singleton['decorator']\n\t\t\tstore: NewStore\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### state\n\t * Assign global mutatable state accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .state('counter', 0)\n\t * .get('/', (({ counter }) => ++counter)\n\t * ```\n\t */\n\tstate(\n\t\toptions:\n\t\t\t| { as: ContextAppendType }\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function,\n\t\tname?:\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function\n\t\t\t| { as: ContextAppendType },\n\t\tvalue?: unknown\n\t) {\n\t\tif (name === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ name: value })\n\t\t\t */\n\t\t\tvalue = options\n\t\t\toptions = { as: 'append' }\n\t\t\tname = ''\n\t\t} else if (value === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ as: 'override' }, { name: value })\n\t\t\t * - decorate('name', value)\n\t\t\t */\n\n\t\t\t// decorate('name', value)\n\t\t\tif (typeof options === 'string') {\n\t\t\t\tvalue = name\n\t\t\t\tname = options\n\t\t\t\toptions = { as: 'append' }\n\t\t\t} else if (typeof options === 'object') {\n\t\t\t\t// decorate({ as: 'override' }, { name: value })\n\t\t\t\tvalue = name\n\t\t\t\tname = ''\n\t\t\t}\n\t\t}\n\n\t\tconst { as } = options as { as: ContextAppendType }\n\n\t\tif (typeof name !== 'string') return this\n\n\t\tswitch (typeof value) {\n\t\t\tcase 'object':\n\t\t\t\tif (!value || !isNotEmpty(value)) return this\n\n\t\t\t\tif (name) {\n\t\t\t\t\tif (name in this.singleton.store)\n\t\t\t\t\t\tthis.singleton.store[name] = mergeDeep(\n\t\t\t\t\t\t\tthis.singleton.store[name] as any,\n\t\t\t\t\t\t\tvalue!,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toverride: as === 'override'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\telse this.singleton.store[name] = value\n\n\t\t\t\t\treturn this\n\t\t\t\t}\n\n\t\t\t\tif (value === null) return this\n\n\t\t\t\tthis.singleton.store = mergeDeep(this.singleton.store, value, {\n\t\t\t\t\toverride: as === 'override'\n\t\t\t\t})\n\n\t\t\t\treturn this as any\n\n\t\t\tcase 'function':\n\t\t\t\tif (name) {\n\t\t\t\t\tif (as === 'override' || !(name in this.singleton.store))\n\t\t\t\t\t\tthis.singleton.store[name] = value\n\t\t\t\t} else this.singleton.store = value(this.singleton.store)\n\n\t\t\t\treturn this as any\n\n\t\t\tdefault:\n\t\t\t\tif (as === 'override' || !(name in this.singleton.store))\n\t\t\t\t\tthis.singleton.store[name] = value\n\n\t\t\t\treturn this\n\t\t}\n\t}\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<const Name extends string, Value>(\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<\n\t\t\t\tSingleton['decorator'] & {\n\t\t\t\t\t[name in Name]: Value\n\t\t\t\t}\n\t\t\t>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<NewDecorators extends Record<string, unknown>>(\n\t\tdecorators: NewDecorators\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Prettify<Singleton['decorator'] & NewDecorators>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tdecorate<NewDecorators extends Record<string, unknown>>(\n\t\tmapper: (decorators: Singleton['decorator']) => NewDecorators\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: NewDecorators\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate({ as: 'override' }, 'getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<\n\t\tconst Type extends ContextAppendType,\n\t\tconst Name extends string,\n\t\tValue\n\t>(\n\t\toptions: { as: Type },\n\t\tname: Name,\n\t\tvalue: Value\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Type extends 'override'\n\t\t\t\t? Reconcile<\n\t\t\t\t\t\tSingleton['decorator'],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue\n\t\t\t\t\t>\n\t\t\t\t: Prettify<\n\t\t\t\t\t\tSingleton['decorator'] & {\n\t\t\t\t\t\t\t[name in Name]: Value\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate<\n\t\tconst Type extends ContextAppendType,\n\t\tNewDecorators extends Record<string, unknown>\n\t>(\n\t\toptions: { as: Type },\n\t\tdecorators: NewDecorators\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Type extends 'override'\n\t\t\t\t? Reconcile<Singleton['decorator'], NewDecorators, true>\n\t\t\t\t: Prettify<Singleton['decorator'] & NewDecorators>\n\t\t\tstore: Singleton['store']\n\t\t\tderive: Singleton['derive']\n\t\t\tresolve: Singleton['resolve']\n\t\t},\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\t/**\n\t * ### decorate\n\t * Define custom method to `Context` accessible for all handler\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .decorate('getDate', () => Date.now())\n\t * .get('/', (({ getDate }) => getDate())\n\t * ```\n\t */\n\tdecorate(\n\t\toptions:\n\t\t\t| { as: ContextAppendType }\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function,\n\t\tname?:\n\t\t\t| string\n\t\t\t| Record<string, unknown>\n\t\t\t| Function\n\t\t\t| { as: ContextAppendType },\n\t\tvalue?: unknown\n\t) {\n\t\tif (name === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ name: value })\n\t\t\t */\n\t\t\tvalue = options\n\t\t\toptions = { as: 'append' }\n\t\t\tname = ''\n\t\t} else if (value === undefined) {\n\t\t\t/**\n\t\t\t * Using either\n\t\t\t * - decorate({ as: 'override' }, { name: value })\n\t\t\t * - decorate('name', value)\n\t\t\t */\n\n\t\t\t// decorate('name', value)\n\t\t\tif (typeof options === 'string') {\n\t\t\t\tvalue = name\n\t\t\t\tname = options\n\t\t\t\toptions = { as: 'append' }\n\t\t\t} else if (typeof options === 'object') {\n\t\t\t\t// decorate({ as: 'override' }, { name: value })\n\t\t\t\tvalue = name\n\t\t\t\tname = ''\n\t\t\t}\n\t\t}\n\n\t\tconst { as } = options as { as: ContextAppendType }\n\n\t\tif (typeof name !== 'string') return this\n\n\t\tswitch (typeof value) {\n\t\t\tcase 'object':\n\t\t\t\tif (name) {\n\t\t\t\t\tif (name in this.singleton.decorator)\n\t\t\t\t\t\tthis.singleton.decorator[name] = mergeDeep(\n\t\t\t\t\t\t\tthis.singleton.decorator[name] as any,\n\t\t\t\t\t\t\tvalue!,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toverride: as === 'override'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\telse this.singleton.decorator[name] = value\n\n\t\t\t\t\treturn this\n\t\t\t\t}\n\n\t\t\t\tif (value === null) return this\n\n\t\t\t\tthis.singleton.decorator = mergeDeep(\n\t\t\t\t\tthis.singleton.decorator,\n\t\t\t\t\tvalue,\n\t\t\t\t\t{\n\t\t\t\t\t\toverride: as === 'override'\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\t\treturn this as any\n\n\t\t\tcase 'function':\n\t\t\t\tif (name) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tas === 'override' ||\n\t\t\t\t\t\t!(name in this.singleton.decorator)\n\t\t\t\t\t)\n\t\t\t\t\t\tthis.singleton.decorator[name] = value\n\t\t\t\t} else\n\t\t\t\t\tthis.singleton.decorator = value(this.singleton.decorator)\n\n\t\t\t\treturn this as any\n\n\t\t\tdefault:\n\t\t\t\tif (as === 'override' || !(name in this.singleton.decorator))\n\t\t\t\t\tthis.singleton.decorator[name] = value\n\n\t\t\t\treturn this\n\t\t}\n\t}\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tderive<\n\t\tconst Derivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t\t\t| void\n\t>(\n\t\ttransform: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\t\tSingleton & {\n\t\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Derivative>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: Prettify<\n\t\t\t\tVolatile['derive'] & ExcludeElysiaResponse<Derivative>\n\t\t\t>\n\t\t\tresolve: Volatile['resolve']\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\t/**\n\t * Derive new property for each request with access to `Context`.\n\t *\n\t * If error is thrown, the scope will skip to handling error instead.\n\t *\n\t * ---\n\t * @example\n\t * new Elysia()\n\t * .state('counter', 1)\n\t * .derive(({ store }) => ({\n\t * increase() {\n\t * store.counter++\n\t * }\n\t * }))\n\t */\n\tderive<\n\t\tconst Derivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t\t\t| void,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\ttransform: (\n\t\t\tcontext: Prettify<\n\t\t\t\tContext<\n\t\t\t\t\tMergeSchema<\n\t\t\t\t\t\tVolatile['schema'],\n\t\t\t\t\t\tMergeSchema<Ephemeral['schema'], Metadata['schema']>,\n\t\t\t\t\t\tBasePath\n\t\t\t\t\t> &\n\t\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\t\tVolatile['standaloneSchema'] &\n\t\t\t\t\t\t'global' extends Type\n\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? { params: Record<string, string> }\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\tSingleton &\n\t\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\tBasePath\n\t\t\t\t>\n\t\t\t>\n\t\t) => MaybePromise<Derivative>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\tSingleton['derive'] & ExcludeElysiaResponse<Derivative>\n\t\t\t\t\t>\n\t\t\t\t\tresolve: Singleton['resolve']\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\t\tEphemeral['derive'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Derivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tresolve: Ephemeral['resolve']\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Prettify<\n\t\t\t\t\t\t\tVolatile['derive'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<Derivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tresolve: Ephemeral['resolve']\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\tderive(\n\t\toptionsOrTransform: { as?: LifeCycleType } | Function,\n\t\ttransform?: Function\n\t) {\n\t\tif (!transform) {\n\t\t\ttransform = optionsOrTransform as any\n\t\t\toptionsOrTransform = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'derive',\n\t\t\tfn: transform!\n\t\t}\n\n\t\treturn this.onTransform(optionsOrTransform as any, hook as any) as any\n\t}\n\n\tmodel<const Name extends string, const Model extends TSchema>(\n\t\tname: Name,\n\t\tmodel: Model\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox'] & {\n\t\t\t\t[name in Name]: Model\n\t\t\t}\n\t\t\terror: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmodel<const Recorder extends TProperties>(\n\t\trecord: Recorder\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: Definitions['typebox'] & Recorder\n\t\t\terror: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmodel<const NewType extends Record<string, TSchema>>(\n\t\tmapper: (\n\t\t\tdecorators: Definitions['typebox'] extends infer Models extends\n\t\t\t\tRecord<string, TSchema>\n\t\t\t\t? {\n\t\t\t\t\t\t[type in keyof Models]: TRef<// @ts-ignore\n\t\t\t\t\t\ttype>\n\t\t\t\t\t}\n\t\t\t\t: {}\n\t\t) => NewType\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\t{\n\t\t\ttypebox: {\n\t\t\t\t[key in keyof NewType]: NewType[key] extends TRef<key & string>\n\t\t\t\t\t? // @ts-expect-error\n\t\t\t\t\t\tDefinitions['typebox'][key]\n\t\t\t\t\t: NewType[key]\n\t\t\t}\n\t\t\ttype: { [x in keyof NewType]: Static<NewType[x]> }\n\t\t\terror: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t>\n\n\tmodel(name: string | Record<string, TSchema> | Function, model?: TSchema) {\n\t\tswitch (typeof name) {\n\t\t\tcase 'object':\n\t\t\t\tconst parsedSchemas = {} as Record<string, TSchema>\n\n\t\t\t\tconst kvs = Object.entries(name)\n\n\t\t\t\tif (!kvs.length) return this\n\n\t\t\t\tfor (const [key, value] of kvs) {\n\t\t\t\t\tif (key in this.definitions.type) continue\n\n\t\t\t\t\tparsedSchemas[key] = this.definitions.type[key] = value\n\t\t\t\t\tparsedSchemas[key].$id ??= `#/components/schemas/${key}`\n\t\t\t\t}\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tthis.definitions.typebox = t.Module({\n\t\t\t\t\t...(this.definitions.typebox['$defs'] as TModule<{}>),\n\t\t\t\t\t...parsedSchemas\n\t\t\t\t} as any)\n\n\t\t\t\treturn this\n\n\t\t\tcase 'function':\n\t\t\t\tconst result = name(this.definitions.type)\n\t\t\t\tthis.definitions.type = result\n\t\t\t\tthis.definitions.typebox = t.Module(result as any)\n\n\t\t\t\treturn this as any\n\n\t\t\tcase 'string':\n\t\t\t\tif (!model) break\n\n\t\t\t\tconst newModel = {\n\t\t\t\t\t...model,\n\t\t\t\t\tid: model.$id ?? `#/components/schemas/${name}`\n\t\t\t\t}\n\n\t\t\t\tthis.definitions.type[name] = model\n\t\t\t\tthis.definitions.typebox = t.Module({\n\t\t\t\t\t...(this.definitions.typebox['$defs'] as TModule<{}>),\n\t\t\t\t\t...newModel\n\t\t\t\t} as any)\n\t\t\t\treturn this as any\n\t\t}\n\n\t\t;(this.definitions.type as Record<string, TSchema>)[name] = model!\n\t\tthis.definitions.typebox = t.Module({\n\t\t\t...this.definitions.typebox['$defs'],\n\t\t\t[name]: model!\n\t\t} as any)\n\n\t\treturn this as any\n\t}\n\n\tRef<K extends keyof Definitions['typebox'] & string>(key: K) {\n\t\treturn t.Ref(key)\n\t}\n\n\tmapDerive<\n\t\tconst NewDerivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>\n\t>(\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\t{},\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t},\n\t\t\t\tBasePath\n\t\t\t>\n\t\t) => MaybePromise<NewDerivative>\n\t): Elysia<\n\t\tBasePath,\n\t\tSingleton,\n\t\tDefinitions,\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\t{\n\t\t\tderive: ExcludeElysiaResponse<NewDerivative>\n\t\t\tresolve: Volatile['resolve']\n\t\t\tschema: Volatile['schema']\n\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t}\n\t>\n\n\tmapDerive<\n\t\tconst NewDerivative extends\n\t\t\t| Record<string, unknown>\n\t\t\t| ElysiaCustomStatusResponse<any, any, any>,\n\t\tconst Type extends LifeCycleType\n\t>(\n\t\toptions: { as?: Type },\n\t\tmapper: (\n\t\t\tcontext: Context<\n\t\t\t\t{},\n\t\t\t\tSingleton &\n\t\t\t\t\t('global' extends Type\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tderive: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['derive'] & Volatile['derive']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tresolve: Partial<\n\t\t\t\t\t\t\t\t\tEphemeral['resolve'] & Volatile['resolve']\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: 'scoped' extends Type\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['derive']>\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tPartial<Volatile['resolve']>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tderive: Ephemeral['derive'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['derive']\n\t\t\t\t\t\t\t\t\tresolve: Ephemeral['resolve'] &\n\t\t\t\t\t\t\t\t\t\tVolatile['resolve']\n\t\t\t\t\t\t\t\t}),\n\t\t\t\tBasePath\n\t\t\t>\n\t\t) => MaybePromise<NewDerivative>\n\t): Type extends 'global'\n\t\t? Elysia<\n\t\t\t\tBasePath,\n\t\t\t\t{\n\t\t\t\t\tdecorator: Singleton['decorator']\n\t\t\t\t\tstore: Singleton['store']\n\t\t\t\t\tderive: Singleton['derive']\n\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\tSingleton['resolve'] &\n\t\t\t\t\t\t\tExcludeElysiaResponse<NewDerivative>\n\t\t\t\t\t>\n\t\t\t\t},\n\t\t\t\tDefinitions,\n\t\t\t\tMetadata,\n\t\t\t\tRoutes,\n\t\t\t\tEphemeral,\n\t\t\t\tVolatile\n\t\t\t>\n\t\t: Type extends 'scoped'\n\t\t\t? Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Ephemeral['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tEphemeral['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewDerivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Ephemeral['schema']\n\t\t\t\t\t\tstandaloneSchema: Ephemeral['standaloneSchema']\n\t\t\t\t\t},\n\t\t\t\t\tVolatile\n\t\t\t\t>\n\t\t\t: Elysia<\n\t\t\t\t\tBasePath,\n\t\t\t\t\tSingleton,\n\t\t\t\t\tDefinitions,\n\t\t\t\t\tMetadata,\n\t\t\t\t\tRoutes,\n\t\t\t\t\tEphemeral,\n\t\t\t\t\t{\n\t\t\t\t\t\tderive: Volatile['derive']\n\t\t\t\t\t\tresolve: Prettify<\n\t\t\t\t\t\t\tVolatile['resolve'] &\n\t\t\t\t\t\t\t\tExcludeElysiaResponse<NewDerivative>\n\t\t\t\t\t\t>\n\t\t\t\t\t\tschema: Volatile['schema']\n\t\t\t\t\t\tstandaloneSchema: Volatile['standaloneSchema']\n\t\t\t\t\t}\n\t\t\t\t>\n\n\tmapDerive(\n\t\toptionsOrDerive: { as?: LifeCycleType } | Function,\n\t\tmapper?: Function\n\t) {\n\t\tif (!mapper) {\n\t\t\tmapper = optionsOrDerive as any\n\t\t\toptionsOrDerive = { as: 'local' }\n\t\t}\n\n\t\tconst hook: HookContainer = {\n\t\t\tsubType: 'mapDerive',\n\t\t\tfn: mapper!\n\t\t}\n\n\t\treturn this.onTransform(optionsOrDerive as any, hook as any) as any\n\t}\n\n\taffix<\n\t\tconst Base extends 'prefix' | 'suffix',\n\t\tconst Type extends 'all' | 'decorator' | 'state' | 'model' | 'error',\n\t\tconst Word extends string\n\t>(\n\t\tbase: Base,\n\t\ttype: Type,\n\t\tword: Word\n\t): Elysia<\n\t\tBasePath,\n\t\t{\n\t\t\tdecorator: Type extends 'decorator' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['decorator']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['decorator']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Singleton['decorator']>\n\t\t\t\t: Singleton['decorator']\n\t\t\tstore: Type extends 'state' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['store']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['store']>\n\t\t\t\t\t: AddSuffix<Word, Singleton['store']>\n\t\t\t\t: Singleton['store']\n\t\t\tderive: Type extends 'decorator' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['derive']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['derive']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Singleton['derive']>\n\t\t\t\t: Singleton['derive']\n\t\t\tresolve: Type extends 'decorator' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Singleton['resolve']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Singleton['resolve']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Singleton['resolve']>\n\t\t\t\t: Singleton['resolve']\n\t\t},\n\t\t{\n\t\t\ttypebox: Type extends 'model' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Definitions['typebox']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Definitions['typebox']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Definitions['typebox']>\n\t\t\t\t: Definitions['typebox']\n\t\t\terror: Type extends 'error' | 'all'\n\t\t\t\t? 'prefix' extends Base\n\t\t\t\t\t? Word extends `${string}${'_' | '-' | ' '}`\n\t\t\t\t\t\t? AddPrefix<Word, Definitions['error']>\n\t\t\t\t\t\t: AddPrefixCapitalize<Word, Definitions['error']>\n\t\t\t\t\t: AddSuffixCapitalize<Word, Definitions['error']>\n\t\t\t\t: Definitions['error']\n\t\t},\n\t\tMetadata,\n\t\tRoutes,\n\t\tEphemeral,\n\t\tVolatile\n\t> {\n\t\tif (word === '') return this as any\n\n\t\tconst delimieter = ['_', '-', ' ']\n\t\tconst capitalize = (word: string) =>\n\t\t\tword[0].toUpperCase() + word.slice(1)\n\n\t\tconst joinKey =\n\t\t\tbase === 'prefix'\n\t\t\t\t? (prefix: string, word: string) =>\n\t\t\t\t\t\tdelimieter.includes(prefix.at(-1) ?? '')\n\t\t\t\t\t\t\t? prefix + word\n\t\t\t\t\t\t\t: prefix + capitalize(word)\n\t\t\t\t: delimieter.includes(word.at(-1) ?? '')\n\t\t\t\t\t? (suffix: string, word: string) => word + suffix\n\t\t\t\t\t: (suffix: string, word: string) =>\n\t\t\t\t\t\t\tword + capitalize(suffix)\n\n\t\tconst remap = (type: 'decorator' | 'state' | 'model' | 'error') => {\n\t\t\tconst store: Record<string, any> = {}\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'decorator':\n\t\t\t\t\tfor (const key in this.singleton.decorator) {\n\t\t\t\t\t\tstore[joinKey(word, key)] =\n\t\t\t\t\t\t\tthis.singleton.decorator[key]\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.singleton.decorator = store\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'state':\n\t\t\t\t\tfor (const key in this.singleton.store)\n\t\t\t\t\t\tstore[joinKey(word, key)] = this.singleton.store[key]\n\n\t\t\t\t\tthis.singleton.store = store\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'model':\n\t\t\t\t\tfor (const key in this.definitions.type)\n\t\t\t\t\t\tstore[joinKey(word, key)] = this.definitions.type[key]\n\n\t\t\t\t\tthis.definitions.type = store\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'error':\n\t\t\t\t\tfor (const key in this.definitions.error)\n\t\t\t\t\t\tstore[joinKey(word, key)] = this.definitions.error[key]\n\n\t\t\t\t\tthis.definitions.error = store\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst types = Array.isArray(type) ? type : [type]\n\n\t\tfor (const type of types.some((x) => x === 'all')\n\t\t\t? ['decorator', 'state', 'model', 'error']\n\t\t\t: types)\n\t\t\tremap(type as 'decorator')\n\n\t\treturn this as any\n\t}\n\n\tprefix<\n\t\tconst Type extends 'all' | 'decorator' | 'state' | 'model' | 'error',\n\t\tconst Word extends string\n\t>(type: Type, word: Word) {\n\t\treturn this.affix('prefix', type, word)\n\t}\n\n\tsuffix<\n\t\tconst Type extends 'all' | 'decorator' | 'state' | 'model' | 'error',\n\t\tconst Word extends string\n\t>(type: Type, word: Word) {\n\t\treturn this.affix('suffix', type, word)\n\t}\n\n\tcompile() {\n\t\tif (this['~adapter'].isWebStandard) {\n\t\t\tthis.fetch = this.config.aot\n\t\t\t\t? composeGeneralHandler(this)\n\t\t\t\t: createDynamicHandler(this)\n\n\t\t\tif (typeof this.server?.reload === 'function')\n\t\t\t\tthis.server.reload({\n\t\t\t\t\t...(this.server || {}),\n\t\t\t\t\tfetch: this.fetch\n\t\t\t\t})\n\n\t\t\treturn this\n\t\t}\n\n\t\tif (typeof this.server?.reload === 'function')\n\t\t\tthis.server.reload(this.server || {})\n\n\t\tthis._handle = composeGeneralHandler(this)\n\n\t\treturn this\n\t}\n\n\thandle = async (request: Request) => this.fetch(request)\n\n\t/**\n\t * Use handle can be either sync or async to save performance.\n\t *\n\t * Beside benchmark purpose, please use 'handle' instead.\n\t */\n\tfetch = (request: Request): MaybePromise<Response> => {\n\t\treturn (this.fetch = this.config.aot\n\t\t\t? composeGeneralHandler(this)\n\t\t\t: createDynamicHandler(this))(request)\n\t}\n\n\t/**\n\t * Custom handle written by adapter\n\t */\n\tprotected _handle?(...a: unknown[]): unknown\n\n\tprotected handleError = async (\n\t\tcontext: Partial<\n\t\t\tContext<\n\t\t\t\tMergeSchema<\n\t\t\t\t\tMetadata['schema'],\n\t\t\t\t\tMergeSchema<Ephemeral['schema'], Volatile['schema']>\n\t\t\t\t> &\n\t\t\t\t\tMetadata['standaloneSchema'] &\n\t\t\t\t\tEphemeral['standaloneSchema'] &\n\t\t\t\t\tVolatile['standaloneSchema'],\n\t\t\t\tSingleton & {\n\t\t\t\t\tderive: Ephemeral['derive'] & Volatile['derive']\n\t\t\t\t\tresolve: Ephemeral['resolve'] & Volatile['resolve']\n\t\t\t\t},\n\t\t\t\tBasePath\n\t\t\t>\n\t\t> & {\n\t\t\trequest: Request\n\t\t},\n\t\terror:\n\t\t\t| Error\n\t\t\t| ValidationError\n\t\t\t| ParseError\n\t\t\t| NotFoundError\n\t\t\t| InternalServerError\n\t) => {\n\t\treturn (this.handleError = this.config.aot\n\t\t\t? composeErrorHandler(this)\n\t\t\t: createDynamicErrorHandler(this))(context, error)\n\t}\n\n\t/**\n\t * ### listen\n\t * Assign current instance to port and start serving\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * new Elysia()\n\t * .get(\"/\", () => 'hi')\n\t * .listen(3000)\n\t * ```\n\t */\n\tlisten = (\n\t\toptions: string | number | Partial<Serve>,\n\t\tcallback?: ListenCallback\n\t) => {\n\t\tthis['~adapter'].listen(this)(options, callback)\n\n\t\tif (this.promisedModules.size) clearSucroseCache(5000)\n\n\t\tthis.promisedModules.then(() => {\n\t\t\tclearSucroseCache(1000)\n\t\t})\n\n\t\treturn this\n\t}\n\n\t/**\n\t * ### stop\n\t * Stop server from serving\n\t *\n\t * ---\n\t * @example\n\t * ```typescript\n\t * const app = new Elysia()\n\t * .get(\"/\", () => 'hi')\n\t * .listen(3000)\n\t *\n\t * // Sometime later\n\t * app.stop()\n\t * ```\n\t *\n\t * @example\n\t * ```typescript\n\t * const app = new Elysia()\n\t * .get(\"/\", () => 'hi')\n\t * .listen(3000)\n\t *\n\t * app.stop(true) // Abruptly any requests inflight\n\t * ```\n\t */\n\tstop = async (closeActiveConnections?: boolean) => {\n\t\tawait this['~adapter'].stop?.(this, closeActiveConnections)\n\n\t\treturn this\n\t};\n\n\t[Symbol.dispose] = () => {\n\t\tif (this.server) this.stop()\n\t}\n\n\t/**\n\t * Wait until all lazy loaded modules all load is fully\n\t */\n\tget modules() {\n\t\treturn this.promisedModules\n\t}\n}\n\nexport { Elysia }\n\nexport { t } from './type-system'\nexport { validationDetail } from './type-system/utils'\nexport type {\n\tElysiaTypeCustomError,\n\tElysiaTypeCustomErrorCallback\n} from './type-system/types'\n\nexport { serializeCookie, Cookie, type CookieOptions } from './cookies'\nexport type { Context, PreContext, ErrorContext } from './context'\nexport {\n\tELYSIA_TRACE,\n\ttype TraceEvent,\n\ttype TraceListener,\n\ttype TraceHandler,\n\ttype TraceProcess,\n\ttype TraceStream\n} from './trace'\n\nexport {\n\tgetSchemaValidator,\n\tgetResponseSchemaValidator,\n\treplaceSchemaType\n} from './schema'\n\nexport {\n\tmergeHook,\n\tmergeObjectArray,\n\tredirect,\n\tStatusMap,\n\tInvertedStatusMap,\n\tform,\n\treplaceUrlPath,\n\tchecksum,\n\tcloneInference,\n\tdeduplicateChecksum,\n\tELYSIA_FORM_DATA,\n\tELYSIA_REQUEST_ID,\n\tsse\n} from './utils'\n\nexport {\n\tstatus,\n\terror,\n\tmapValueError,\n\tParseError,\n\tNotFoundError,\n\tValidationError,\n\tInternalServerError,\n\tInvalidCookieSignature,\n\tERROR_CODE,\n\tElysiaCustomStatusResponse\n} from './error'\n\nexport type {\n\tEphemeralType,\n\tCreateEden,\n\tComposeElysiaResponse,\n\tElysiaConfig,\n\tSingletonBase,\n\tDefinitionBase,\n\tRouteBase,\n\tHandler,\n\tComposedHandler,\n\tInputSchema,\n\tLocalHook,\n\tMergeSchema,\n\tRouteSchema,\n\tUnwrapRoute,\n\tInternalRoute,\n\tHTTPMethod,\n\tSchemaValidator,\n\tVoidHandler,\n\tPreHandler,\n\tBodyHandler,\n\tOptionalHandler,\n\tAfterResponseHandler,\n\tErrorHandler,\n\tLifeCycleEvent,\n\tLifeCycleStore,\n\tLifeCycleType,\n\tMaybePromise,\n\tUnwrapSchema,\n\tChecksum,\n\tDocumentDecoration,\n\tInferContext,\n\tInferHandler,\n\tResolvePath,\n\tMapResponse,\n\tMacroQueue,\n\tBaseMacro,\n\tMacroManager,\n\tBaseMacroFn,\n\tMacroToProperty,\n\tResolveMacroContext,\n\tMergeElysiaInstances,\n\tMaybeArray,\n\tModelValidator,\n\tMetadataBase,\n\tUnwrapBodySchema,\n\tUnwrapGroupGuardRoute,\n\tModelValidatorError,\n\tExcludeElysiaResponse,\n\tSSEPayload,\n\tStandaloneInputSchema,\n\tMergeStandaloneSchema,\n\tMergeTypeModule,\n\tGracefulHandler,\n\tAfterHandler,\n\tInlineHandler,\n\tResolveHandler,\n\tTransformHandler,\n\tHTTPHeaders\n} from './types'\n\nexport { env } from './universal/env'\nexport { file, ElysiaFile } from './universal/file'\nexport type { ElysiaAdapter } from './adapter'\n\nexport { TypeSystemPolicy } from '@sinclair/typebox/system'\nexport type { Static, TSchema } from '@sinclair/typebox'\n",
|
|
9
9
|
"import { Type, Kind } from '@sinclair/typebox'\nimport type {\n\tArrayOptions,\n\tDateOptions,\n\tIntegerOptions,\n\tObjectOptions,\n\tSchemaOptions,\n\tTAnySchema,\n\tTArray,\n\tTBoolean,\n\tTDate,\n\tTEnumValue,\n\tTInteger,\n\tTNumber,\n\tTObject,\n\tTProperties,\n\tTSchema,\n\tTString,\n\tNumberOptions,\n\tJavaScriptTypeBuilder,\n\tStringOptions,\n\tTUnsafe,\n\tUint8ArrayOptions\n} from '@sinclair/typebox'\n\nimport './format'\nimport {\n\tcompile,\n\tcreateType,\n\tloadFileType,\n\ttryParse,\n\tvalidateFile\n} from './utils'\nimport {\n\tCookieValidatorOptions,\n\tTFile,\n\tTFiles,\n\tFileOptions,\n\tFilesOptions,\n\tNonEmptyArray,\n\tTForm,\n\tTUnionEnum,\n\tElysiaTransformDecodeBuilder,\n\tTArrayBuffer\n} from './types'\n\nimport { ELYSIA_FORM_DATA, form } from '../utils'\nimport { ValidationError } from '../error'\nimport { parseDateTimeEmptySpace } from './format'\nimport { replaceSchemaType } from '../schema'\nimport { isJSDocDeprecatedTag } from 'typescript'\n\nconst t = Object.assign({}, Type) as unknown as Omit<\n\tJavaScriptTypeBuilder,\n\t'String' | 'Transform'\n> &\n\ttypeof ElysiaType & {\n\t\tTransform<Type extends TSchema>(\n\t\t\ttype: Type\n\t\t): ElysiaTransformDecodeBuilder<Type>\n\t}\n\ncreateType<TUnionEnum>(\n\t'UnionEnum',\n\t(schema, value) =>\n\t\t(typeof value === 'number' ||\n\t\t\ttypeof value === 'string' ||\n\t\t\tvalue === null) &&\n\t\tschema.enum.includes(value as never)\n)\n\ncreateType<TArrayBuffer>(\n\t'ArrayBuffer',\n\t(schema, value) => value instanceof ArrayBuffer\n)\n\nconst internalFiles = createType<FilesOptions, File[]>(\n\t'Files',\n\t(options, value) => {\n\t\tif (options.minItems && options.minItems > 1 && !Array.isArray(value))\n\t\t\treturn false\n\n\t\tif (!Array.isArray(value)) return validateFile(options, value)\n\n\t\tif (options.minItems && value.length < options.minItems) return false\n\t\tif (options.maxItems && value.length > options.maxItems) return false\n\n\t\tfor (let i = 0; i < value.length; i++)\n\t\t\tif (!validateFile(options, value[i])) return false\n\n\t\treturn true\n\t}\n) as unknown as TFiles\n\nconst internalFormData = createType<TForm, FormData>(\n\t'ElysiaForm',\n\t({ compiler, ...schema }, value) => {\n\t\tif (!(value instanceof FormData)) return false\n\n\t\tif (compiler) {\n\t\t\tif (!(ELYSIA_FORM_DATA in value))\n\t\t\t\tthrow new ValidationError('property', schema, value)\n\n\t\t\tif (!compiler.Check(value[ELYSIA_FORM_DATA]))\n\t\t\t\tthrow compiler.Error(value[ELYSIA_FORM_DATA])\n\t\t}\n\n\t\treturn true\n\t}\n) as unknown as TForm\n\ninterface ElysiaStringOptions extends StringOptions {\n\t/**\n\t * Whether the value include JSON escape sequences or not\n\t *\n\t * When using JSON Accelerator, this will bypass the JSON escape sequence validation\n\t *\n\t * Set to `true` if the value doesn't include JSON escape sequences\n\t *\n\t * @default false\n\t */\n\ttrusted?: boolean\n}\n\nexport const ElysiaType = {\n\t// @ts-ignore\n\tString: (property?: ElysiaStringOptions) => Type.String(property),\n\tNumeric: (property?: NumberOptions) => {\n\t\tconst schema = Type.Number(property)\n\t\tconst compiler = compile(schema)\n\n\t\treturn t\n\t\t\t.Transform(\n\t\t\t\tt.Union(\n\t\t\t\t\t[\n\t\t\t\t\t\tt.String({\n\t\t\t\t\t\t\tformat: 'numeric',\n\t\t\t\t\t\t\tdefault: 0\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tt.Number(property)\n\t\t\t\t\t],\n\t\t\t\t\tproperty\n\t\t\t\t)\n\t\t\t)\n\t\t\t.Decode((value) => {\n\t\t\t\tconst number = +value\n\t\t\t\tif (isNaN(number)) return value\n\n\t\t\t\tif (property && !compiler.Check(number))\n\t\t\t\t\tthrow compiler.Error(number)\n\n\t\t\t\treturn number\n\t\t\t})\n\t\t\t.Encode((value) => value) as any as TNumber\n\t},\n\n\tInteger: (property?: IntegerOptions): TInteger => {\n\t\tconst schema = Type.Integer(property)\n\t\tconst compiler = compile(schema)\n\n\t\treturn t\n\t\t\t.Transform(\n\t\t\t\tt.Union(\n\t\t\t\t\t[\n\t\t\t\t\t\tt.String({\n\t\t\t\t\t\t\tformat: 'integer',\n\t\t\t\t\t\t\tdefault: 0\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tType.Integer(property)\n\t\t\t\t\t],\n\t\t\t\t\tproperty\n\t\t\t\t)\n\t\t\t)\n\t\t\t.Decode((value) => {\n\t\t\t\tconst number = +value\n\n\t\t\t\tif (!compiler.Check(number)) throw compiler.Error(number)\n\n\t\t\t\treturn number\n\t\t\t})\n\t\t\t.Encode((value) => value) as any as TInteger\n\t},\n\n\tDate: (property?: DateOptions) => {\n\t\tconst schema = Type.Date(property)\n\t\tconst compiler = compile(schema)\n\n\t\tconst _default = property?.default\n\t\t\t? new Date(property.default) // in case the default is an ISO string or milliseconds from epoch\n\t\t\t: undefined\n\n\t\treturn t\n\t\t\t.Transform(\n\t\t\t\tt.Union(\n\t\t\t\t\t[\n\t\t\t\t\t\tType.Date(property),\n\t\t\t\t\t\tt.String({\n\t\t\t\t\t\t\tformat: 'date-time',\n\t\t\t\t\t\t\tdefault: _default?.toISOString()\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tt.String({\n\t\t\t\t\t\t\tformat: 'date',\n\t\t\t\t\t\t\tdefault: _default?.toISOString()\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tt.Number({ default: _default?.getTime() })\n\t\t\t\t\t],\n\t\t\t\t\tproperty\n\t\t\t\t)\n\t\t\t)\n\t\t\t.Decode((value) => {\n\t\t\t\tif (typeof value === 'number') {\n\t\t\t\t\tconst date = new Date(value)\n\n\t\t\t\t\tif (!compiler.Check(date)) throw compiler.Error(date)\n\n\t\t\t\t\treturn date\n\t\t\t\t}\n\n\t\t\t\tif (value instanceof Date) return value\n\n\t\t\t\tconst date = new Date(parseDateTimeEmptySpace(value))\n\n\t\t\t\tif (!date || isNaN(date.getTime()))\n\t\t\t\t\tthrow new ValidationError('property', schema, date)\n\n\t\t\t\tif (!compiler.Check(date)) throw compiler.Error(date)\n\n\t\t\t\treturn date\n\t\t\t})\n\t\t\t.Encode((value) => {\n\t\t\t\tif (value instanceof Date) return value.toISOString()\n\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisNaN(\n\t\t\t\t\t\t\tnew Date(parseDateTimeEmptySpace(value)).getTime()\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new ValidationError('property', schema, value)\n\n\t\t\t\t\treturn value\n\t\t\t\t}\n\n\t\t\t\tif (!compiler.Check(value)) throw compiler.Error(value)\n\n\t\t\t\treturn value\n\t\t\t}) as any as TDate\n\t},\n\n\tBooleanString: (property?: SchemaOptions) => {\n\t\tconst schema = Type.Boolean(property)\n\t\tconst compiler = compile(schema)\n\n\t\treturn t\n\t\t\t.Transform(\n\t\t\t\tt.Union(\n\t\t\t\t\t[\n\t\t\t\t\t\tt.Boolean(property),\n\t\t\t\t\t\tt.String({\n\t\t\t\t\t\t\tformat: 'boolean',\n\t\t\t\t\t\t\tdefault: false\n\t\t\t\t\t\t})\n\t\t\t\t\t],\n\t\t\t\t\tproperty\n\t\t\t\t)\n\t\t\t)\n\t\t\t.Decode((value) => {\n\t\t\t\tif (typeof value === 'string') return value === 'true'\n\n\t\t\t\tif (value !== undefined && !compiler.Check(value))\n\t\t\t\t\tthrow compiler.Error(value)\n\n\t\t\t\treturn value\n\t\t\t})\n\t\t\t.Encode((value) => value) as any as TBoolean\n\t},\n\n\tObjectString: <T extends TProperties>(\n\t\tproperties: T,\n\t\toptions?: ObjectOptions\n\t) => {\n\t\tconst schema = t.Object(properties, options)\n\t\tconst compiler = compile(schema)\n\n\t\tconst defaultValue = JSON.stringify(compiler.Create())\n\n\t\treturn t\n\t\t\t.Transform(\n\t\t\t\tt.Union([\n\t\t\t\t\tt.String({\n\t\t\t\t\t\tformat: 'ObjectString',\n\t\t\t\t\t\tdefault: defaultValue\n\t\t\t\t\t}),\n\t\t\t\t\tschema\n\t\t\t\t])\n\t\t\t)\n\t\t\t.Decode((value) => {\n\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\tif (value.charCodeAt(0) !== 123)\n\t\t\t\t\t\tthrow new ValidationError('property', schema, value)\n\n\t\t\t\t\tif (!compiler.Check((value = tryParse(value, schema))))\n\t\t\t\t\t\tthrow compiler.Error(value)\n\n\t\t\t\t\treturn compiler.Decode(value)\n\t\t\t\t}\n\n\t\t\t\treturn value\n\t\t\t})\n\t\t\t.Encode((value) => {\n\t\t\t\tlet original\n\t\t\t\tif (typeof value === 'string')\n\t\t\t\t\tvalue = tryParse((original = value), schema)\n\n\t\t\t\tif (!compiler.Check(value)) throw compiler.Error(value)\n\n\t\t\t\treturn original ?? JSON.stringify(value)\n\t\t\t}) as any as TObject<T>\n\t},\n\n\tArrayString: <T extends TSchema = TString>(\n\t\tchildren: T = t.String() as any,\n\t\toptions?: ArrayOptions\n\t) => {\n\t\tconst schema = t.Array(children, options)\n\t\tconst compiler = compile(schema)\n\n\t\tconst decode = (value: string, isProperty = false) => {\n\t\t\tif (value.charCodeAt(0) === 91) {\n\t\t\t\tif (!compiler.Check((value = tryParse(value, schema))))\n\t\t\t\t\tthrow compiler.Error(value)\n\n\t\t\t\treturn compiler.Decode(value)\n\t\t\t}\n\n\t\t\t// has , (as used in nuqs)\n\t\t\tif (value.indexOf(',') !== -1) {\n\t\t\t\t// const newValue = value.split(',').map((v) => v.trim())\n\n\t\t\t\tif (!compiler.Check(value)) throw compiler.Error(value)\n\n\t\t\t\treturn compiler.Decode(value)\n\t\t\t}\n\n\t\t\tif (isProperty) return value\n\n\t\t\tthrow new ValidationError('property', schema, value)\n\t\t}\n\n\t\treturn t\n\t\t\t.Transform(\n\t\t\t\tt.Union([\n\t\t\t\t\tt.String({\n\t\t\t\t\t\tformat: 'ArrayString',\n\t\t\t\t\t\tdefault: options?.default\n\t\t\t\t\t}),\n\t\t\t\t\tschema\n\t\t\t\t])\n\t\t\t)\n\t\t\t.Decode((value) => {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\tlet values = <unknown[]>[]\n\n\t\t\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\t\t\tconst v = value[i]\n\t\t\t\t\t\tif (typeof v === 'string') {\n\t\t\t\t\t\t\tconst t = decode(v, true)\n\t\t\t\t\t\t\tif (Array.isArray(t)) values = values.concat(t)\n\t\t\t\t\t\t\telse values.push(t)\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvalues.push(v)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn values\n\t\t\t\t}\n\n\t\t\t\tif (typeof value === 'string') return decode(value)\n\n\t\t\t\t// Is probably transformed, unable to check schema\n\t\t\t\treturn value\n\t\t\t})\n\t\t\t.Encode((value) => {\n\t\t\t\tlet original\n\t\t\t\tif (typeof value === 'string')\n\t\t\t\t\tvalue = tryParse((original = value), schema)\n\n\t\t\t\tif (!compiler.Check(value))\n\t\t\t\t\tthrow new ValidationError('property', schema, value)\n\n\t\t\t\treturn original ?? JSON.stringify(value)\n\t\t\t}) as any as TArray<T>\n\t},\n\n\tFile: createType<FileOptions, File>(\n\t\t'File',\n\t\tvalidateFile\n\t) as unknown as TFile,\n\n\tFiles: (options: FilesOptions = {}): TUnsafe<File[]> =>\n\t\tt\n\t\t\t.Transform(internalFiles(options))\n\t\t\t.Decode((value) => {\n\t\t\t\tif (Array.isArray(value)) return value\n\t\t\t\treturn [value]\n\t\t\t})\n\t\t\t.Encode((value) => value) as unknown as TUnsafe<File[]>,\n\n\tNullable: <T extends TSchema>(schema: T, options?: SchemaOptions) =>\n\t\tt.Union([schema, t.Null()], {\n\t\t\t...options,\n\t\t\tnullable: true\n\t\t}),\n\n\t/**\n\t * Allow Optional, Nullable and Undefined\n\t */\n\tMaybeEmpty: <T extends TSchema>(schema: T, options?: SchemaOptions) =>\n\t\tt.Union([schema, t.Null(), t.Undefined()], options),\n\n\tCookie: <T extends TProperties>(\n\t\tproperties: T,\n\t\t{\n\t\t\tdomain,\n\t\t\texpires,\n\t\t\thttpOnly,\n\t\t\tmaxAge,\n\t\t\tpath,\n\t\t\tpriority,\n\t\t\tsameSite,\n\t\t\tsecure,\n\t\t\tsecrets,\n\t\t\tsign,\n\t\t\t...options\n\t\t}: CookieValidatorOptions<T> = {}\n\t) => {\n\t\tconst v = t.Object(properties, options)\n\n\t\tv.config = {\n\t\t\tdomain,\n\t\t\texpires,\n\t\t\thttpOnly,\n\t\t\tmaxAge,\n\t\t\tpath,\n\t\t\tpriority,\n\t\t\tsameSite,\n\t\t\tsecure,\n\t\t\tsecrets,\n\t\t\tsign\n\t\t}\n\n\t\treturn v\n\t},\n\n\tUnionEnum: <\n\t\tconst T extends\n\t\t\t| NonEmptyArray<TEnumValue>\n\t\t\t| Readonly<NonEmptyArray<TEnumValue>>\n\t>(\n\t\tvalues: T,\n\t\toptions: SchemaOptions = {}\n\t) => {\n\t\tconst type = values.every((value) => typeof value === 'string')\n\t\t\t? { type: 'string' }\n\t\t\t: values.every((value) => typeof value === 'number')\n\t\t\t\t? { type: 'number' }\n\t\t\t\t: values.every((value) => value === null)\n\t\t\t\t\t? { type: 'null' }\n\t\t\t\t\t: {}\n\n\t\tif (values.some((x) => typeof x === 'object' && x !== null))\n\t\t\tthrow new Error('This type does not support objects or arrays')\n\n\t\treturn {\n\t\t\t// default is need for generating error message\n\t\t\tdefault: values[0],\n\t\t\t...options,\n\t\t\t[Kind]: 'UnionEnum',\n\t\t\t...type,\n\t\t\tenum: values\n\t\t} as any as TUnionEnum<T>\n\t},\n\n\tNoValidate: <T extends TAnySchema>(v: T, enabled = true) => {\n\t\tv.noValidate = enabled\n\n\t\treturn v\n\t},\n\n\tForm: <T extends TProperties>(\n\t\tv: T,\n\t\toptions: ObjectOptions = {}\n\t): TForm<T> => {\n\t\tconst schema = t.Object(v, {\n\t\t\tdefault: form({}),\n\t\t\t...options\n\t\t})\n\t\tconst compiler = compile(schema)\n\n\t\treturn t.Union([\n\t\t\tschema,\n\t\t\t// @ts-expect-error\n\t\t\tinternalFormData({\n\t\t\t\tcompiler\n\t\t\t})\n\t\t])\n\t},\n\n\tArrayBuffer(options: TArrayBuffer = {}) {\n\t\treturn {\n\t\t\t// default is need for generating error message\n\t\t\tdefault: [1, 2, 3],\n\t\t\t...options,\n\t\t\t[Kind]: 'ArrayBuffer'\n\t\t} as any as TUnsafe<ArrayBuffer>\n\t},\n\n\tUint8Array: (options: Uint8ArrayOptions) => {\n\t\tconst schema = Type.Uint8Array(options)\n\t\tconst compiler = compile(schema)\n\n\t\treturn t\n\t\t\t.Transform(t.Union([t.ArrayBuffer(), Type.Uint8Array(options)]))\n\t\t\t.Decode((value) => {\n\t\t\t\tif (value instanceof ArrayBuffer) {\n\t\t\t\t\tif (!compiler.Check((value = new Uint8Array(value))))\n\t\t\t\t\t\tthrow compiler.Error(value)\n\n\t\t\t\t\treturn value\n\t\t\t\t}\n\n\t\t\t\treturn value\n\t\t\t})\n\t\t\t.Encode((value) => value) as any as TUnsafe<Uint8Array>\n\t}\n}\n\nt.BooleanString = ElysiaType.BooleanString\nt.ObjectString = ElysiaType.ObjectString\nt.ArrayString = ElysiaType.ArrayString\nt.Numeric = ElysiaType.Numeric\nt.Integer = ElysiaType.Integer\n\nt.File = (arg) => {\n\tif (arg?.type) loadFileType()\n\n\treturn ElysiaType.File({\n\t\tdefault: 'File',\n\t\t...arg,\n\t\textension: arg?.type,\n\t\ttype: 'string',\n\t\tformat: 'binary'\n\t})\n}\n\nt.Files = (arg) => {\n\tif (arg?.type) loadFileType()\n\n\treturn ElysiaType.Files({\n\t\t...arg,\n\t\telysiaMeta: 'Files',\n\t\tdefault: 'Files',\n\t\textension: arg?.type,\n\t\ttype: 'array',\n\t\titems: {\n\t\t\t...arg,\n\t\t\tdefault: 'Files',\n\t\t\ttype: 'string',\n\t\t\tformat: 'binary'\n\t\t}\n\t})\n}\n\nt.Nullable = ElysiaType.Nullable\nt.MaybeEmpty = ElysiaType.MaybeEmpty\nt.Cookie = ElysiaType.Cookie\nt.Date = ElysiaType.Date\nt.UnionEnum = ElysiaType.UnionEnum\nt.NoValidate = ElysiaType.NoValidate\nt.Form = ElysiaType.Form\n\nt.ArrayBuffer = ElysiaType.ArrayBuffer\nt.Uint8Array = ElysiaType.Uint8Array as any\n\nexport { t }\n\nexport {\n\tTypeSystemPolicy,\n\tTypeSystem,\n\tTypeSystemDuplicateFormat,\n\tTypeSystemDuplicateTypeKind\n} from '@sinclair/typebox/system'\nexport { TypeRegistry, FormatRegistry } from '@sinclair/typebox'\nexport { TypeCompiler, TypeCheck } from '@sinclair/typebox/compiler'\n",
|
|
10
10
|
"import { FormatRegistry } from '@sinclair/typebox'\n\n/**\n * ? Fork of ajv-formats without ajv as dependencies\n *\n * @see https://github.com/ajv-validator/ajv-formats/blob/master/src/formats.ts\n **/\n\n/* eslint-disable no-control-regex */\nexport type FormatName =\n\t| 'date'\n\t| 'time'\n\t| 'date-time'\n\t| 'iso-time'\n\t| 'iso-date-time'\n\t| 'duration'\n\t| 'uri'\n\t| 'uri-reference'\n\t| 'uri-template'\n\t| 'url'\n\t| 'email'\n\t| 'hostname'\n\t| 'ipv4'\n\t| 'ipv6'\n\t| 'regex'\n\t| 'uuid'\n\t| 'json-pointer'\n\t| 'json-pointer-uri-fragment'\n\t| 'relative-json-pointer'\n\t| 'byte'\n\t| 'int32'\n\t| 'int64'\n\t| 'float'\n\t| 'double'\n\t| 'password'\n\t| 'binary'\n\nexport const fullFormats = {\n\t// date: http://tools.ietf.org/html/rfc3339#section-5.6\n\tdate,\n\t// date-time: http://tools.ietf.org/html/rfc3339#section-5.6\n\ttime: getTime(true),\n\t'date-time': getDateTime(true),\n\t'iso-time': getTime(false),\n\t'iso-date-time': getDateTime(false),\n\t// duration: https://tools.ietf.org/html/rfc3339#appendix-A\n\tduration:\n\t\t/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/,\n\turi,\n\t'uri-reference':\n\t\t/^(?:[a-z][a-z0-9+\\-.]*:)?(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'\"()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\\?(?:[a-z0-9\\-._~!$&'\"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'\"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,\n\t// uri-template: https://tools.ietf.org/html/rfc6570\n\t'uri-template':\n\t\t/^(?:(?:[^\\x00-\\x20\"'<>%\\\\^`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i,\n\t// For the source: https://gist.github.com/dperini/729294\n\t// For test cases: https://mathiasbynens.be/demo/url-regex\n\turl: /^(?:https?|ftp):\\/\\/(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)(?:\\.(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu,\n\temail: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,\n\thostname:\n\t\t/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i,\n\t// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html\n\tipv4: /^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/,\n\tipv6: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))$/i,\n\tregex,\n\t// uuid: http://tools.ietf.org/html/rfc4122\n\tuuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,\n\t// JSON-pointer: https://tools.ietf.org/html/rfc6901\n\t// uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A\n\t'json-pointer': /^(?:\\/(?:[^~/]|~0|~1)*)*$/,\n\t'json-pointer-uri-fragment':\n\t\t/^#(?:\\/(?:[a-z0-9_\\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,\n\t// relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00\n\t'relative-json-pointer': /^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/,\n\t// the following formats are used by the openapi specification: https://spec.openapis.org/oas/v3.0.0#data-types\n\t// byte: https://github.com/miguelmota/is-base64\n\tbyte,\n\t// signed 32 bit integer\n\tint32: { type: 'number', validate: validateInt32 },\n\t// signed 64 bit integer\n\tint64: { type: 'number', validate: validateInt64 },\n\t// C-type float\n\tfloat: { type: 'number', validate: validateNumber },\n\t// C-type double\n\tdouble: { type: 'number', validate: validateNumber },\n\t// hint to the UI to hide input strings\n\tpassword: true,\n\t// unchecked string payload\n\tbinary: true\n} as const\n\nfunction isLeapYear(year: number): boolean {\n\t// https://tools.ietf.org/html/rfc3339#appendix-C\n\treturn year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n}\n\nconst DATE = /^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/\nconst DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nfunction date(str: string): boolean {\n\t// full-date from http://tools.ietf.org/html/rfc3339#section-5.6\n\tconst matches: string[] | null = DATE.exec(str)\n\tif (!matches) return false\n\tconst year: number = +matches[1]\n\tconst month: number = +matches[2]\n\tconst day: number = +matches[3]\n\treturn (\n\t\tmonth >= 1 &&\n\t\tmonth <= 12 &&\n\t\tday >= 1 &&\n\t\tday <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month])\n\t)\n}\n\nconst TIME = /^(\\d\\d):(\\d\\d):(\\d\\d(?:\\.\\d+)?)(z|([+-])(\\d\\d)(?::?(\\d\\d))?)?$/i\n\nfunction getTime(strictTimeZone?: boolean): (str: string) => boolean {\n\treturn function time(str: string): boolean {\n\t\tconst matches: string[] | null = TIME.exec(str)\n\t\tif (!matches) return false\n\t\tconst hr: number = +matches[1]\n\t\tconst min: number = +matches[2]\n\t\tconst sec: number = +matches[3]\n\t\tconst tz: string | undefined = matches[4]\n\t\tconst tzSign: number = matches[5] === '-' ? -1 : 1\n\t\tconst tzH: number = +(matches[6] || 0)\n\t\tconst tzM: number = +(matches[7] || 0)\n\t\tif (tzH > 23 || tzM > 59 || (strictTimeZone && !tz)) return false\n\t\tif (hr <= 23 && min <= 59 && sec < 60) return true\n\t\t// leap second\n\t\tconst utcMin = min - tzM * tzSign\n\t\tconst utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0)\n\t\treturn (\n\t\t\t(utcHr === 23 || utcHr === -1) &&\n\t\t\t(utcMin === 59 || utcMin === -1) &&\n\t\t\tsec < 61\n\t\t)\n\t}\n}\n\nexport const parseDateTimeEmptySpace = (str: string) => {\n\tif (str.charCodeAt(str.length - 6) === 32)\n\t\treturn str.slice(0, -6) + '+' + str.slice(-5)\n\n\treturn str\n}\n\nconst DATE_TIME_SEPARATOR = /t|\\s/i\nfunction getDateTime(strictTimeZone?: boolean): (str: string) => boolean {\n\tconst time = getTime(strictTimeZone)\n\n\treturn function date_time(str: string): boolean {\n\t\t// http://tools.ietf.org/html/rfc3339#section-5.6\n\t\tconst dateTime: string[] = str.split(DATE_TIME_SEPARATOR)\n\n\t\treturn dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1])\n\t}\n}\n\nconst NOT_URI_FRAGMENT = /\\/|:/\nconst URI =\n\t/^(?:[a-z][a-z0-9+\\-.]*:)(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\\?(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i\n\nfunction uri(str: string): boolean {\n\t// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required \".\"\n\treturn NOT_URI_FRAGMENT.test(str) && URI.test(str)\n}\n\nconst BYTE =\n\t/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm\n\nfunction byte(str: string): boolean {\n\tBYTE.lastIndex = 0\n\treturn BYTE.test(str)\n}\n\nconst MIN_INT32 = -(2 ** 31)\nconst MAX_INT32 = 2 ** 31 - 1\n\nfunction validateInt32(value: number): boolean {\n\treturn Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32\n}\n\nfunction validateInt64(value: number): boolean {\n\t// JSON and javascript max Int is 2**53, so any int that passes isInteger is valid for Int64\n\treturn Number.isInteger(value)\n}\n\nfunction validateNumber(): boolean {\n\treturn true\n}\n\nconst Z_ANCHOR = /[^\\\\]\\\\Z/\nfunction regex(str: string): boolean {\n\tif (Z_ANCHOR.test(str)) return false\n\ttry {\n\t\tnew RegExp(str)\n\t\treturn true\n\t} catch (e) {\n\t\treturn false\n\t}\n}\n\n/**\n * @license\n *\n * MIT License\n *\n * Copyright (c) 2020 Evgeny Poberezkin\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nconst isISO8601 =\n\t/(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+([+-][0-2]\\d:[0-5]\\d|Z))|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z))|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z))/\n\nconst isFormalDate =\n\t/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s\\d{2}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\sGMT(?:\\+|-)\\d{4}\\s\\([^)]+\\)/\n\nconst isShortenDate =\n\t/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\\s-](?:0?[1-9]|1[0-2])[/\\s-](?:19|20)\\d{2})|(?:(?:19|20)\\d{2}[/\\s-](?:0?[1-9]|1[0-2])[/\\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\\s[AP]M)?)?$/\n\nconst _validateDate = fullFormats.date\nconst _validateDateTime = fullFormats['date-time']\n\nif (!FormatRegistry.Has('date'))\n\tFormatRegistry.Set('date', (value: string) => {\n\t\t// Remove quote from stringified date\n\t\tconst temp = parseDateTimeEmptySpace(value).replace(/\"/g, '')\n\n\t\tif (\n\t\t\tisISO8601.test(temp) ||\n\t\t\tisFormalDate.test(temp) ||\n\t\t\tisShortenDate.test(temp) ||\n\t\t\t_validateDate(temp)\n\t\t) {\n\t\t\tconst date = new Date(temp)\n\t\t\tif (!Number.isNaN(date.getTime())) return true\n\t\t}\n\n\t\treturn false\n\t})\n\nif (!FormatRegistry.Has('date-time'))\n\tFormatRegistry.Set('date-time', (value: string) => {\n\t\t// Remove quote from stringified date\n\t\tconst temp = value.replace(/\"/g, '')\n\n\t\tif (\n\t\t\tisISO8601.test(temp) ||\n\t\t\tisFormalDate.test(temp) ||\n\t\t\tisShortenDate.test(temp) ||\n\t\t\t_validateDateTime(temp)\n\t\t) {\n\t\t\tconst date = new Date(temp)\n\t\t\tif (!Number.isNaN(date.getTime())) return true\n\t\t}\n\n\t\treturn false\n\t})\n\nObject.entries(fullFormats).forEach((formatEntry) => {\n\tconst [formatName, formatValue] = formatEntry\n\n\tif (!FormatRegistry.Has(formatName)) {\n\t\tif (formatValue instanceof RegExp)\n\t\t\tFormatRegistry.Set(formatName, (value) => formatValue.test(value))\n\t\telse if (typeof formatValue === 'function')\n\t\t\tFormatRegistry.Set(formatName, formatValue)\n\t}\n})\n\nif (!FormatRegistry.Has('numeric'))\n\tFormatRegistry.Set('numeric', (value) => !!value && !isNaN(+value))\n\nif (!FormatRegistry.Has('integer'))\n\tFormatRegistry.Set(\n\t\t'integer',\n\t\t(value) => !!value && Number.isInteger(+value)\n\t)\n\nif (!FormatRegistry.Has('boolean'))\n\tFormatRegistry.Set(\n\t\t'boolean',\n\t\t(value) => value === 'true' || value === 'false'\n\t)\n\nif (!FormatRegistry.Has('ObjectString'))\n\tFormatRegistry.Set('ObjectString', (value) => {\n\t\tlet start = value.charCodeAt(0)\n\n\t\t// If starts with ' ', '\\t', '\\n', then trim first\n\t\tif (start === 9 || start === 10 || start === 32)\n\t\t\tstart = value.trimStart().charCodeAt(0)\n\n\t\tif (start !== 123 && start !== 91) return false\n\n\t\ttry {\n\t\t\tJSON.parse(value)\n\n\t\t\treturn true\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t})\n\nif (!FormatRegistry.Has('ArrayString'))\n\tFormatRegistry.Set('ArrayString', (value) => {\n\t\tlet start = value.charCodeAt(0)\n\n\t\t// If starts with ' ', '\\t', '\\n', then trim first\n\t\tif (start === 9 || start === 10 || start === 32)\n\t\t\tstart = value.trimStart().charCodeAt(0)\n\n\t\tif (start !== 123 && start !== 91) return false\n\n\t\ttry {\n\t\t\tJSON.parse(value)\n\n\t\t\treturn true\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t})\n",
|
|
11
11
|
"import {\n\tKind,\n\tTUnsafe,\n\tTypeRegistry,\n\tUnsafe,\n\ttype TAnySchema\n} from '@sinclair/typebox'\nimport { Value } from '@sinclair/typebox/value'\nimport { TypeCheck, TypeCompiler } from '@sinclair/typebox/compiler'\n\nimport { ElysiaFile } from '../universal/file'\nimport { InvalidFileType, ValidationError } from '../error'\nimport type {\n\tElysiaTypeCustomErrorCallback,\n\tFileOptions,\n\tFileUnit\n} from './types'\nimport type { MaybeArray } from '../types'\n\nexport const tryParse = (v: unknown, schema: TAnySchema) => {\n\ttry {\n\t\treturn JSON.parse(v as string)\n\t} catch {\n\t\tthrow new ValidationError('property', schema, v)\n\t}\n}\n\nexport function createType<TSchema = unknown, TReturn = unknown>(\n\tkind: string,\n\tfunc: TypeRegistry.TypeRegistryValidationFunction<TSchema>\n): TUnsafe<TReturn> {\n\tif (!TypeRegistry.Has(kind)) TypeRegistry.Set<TSchema>(kind, func)\n\n\treturn ((options = {}) => Unsafe({ ...options, [Kind]: kind })) as any\n}\n\nexport const compile = <T extends TAnySchema>(schema: T) => {\n\ttry {\n\t\tconst compiler = TypeCompiler.Compile(schema) as TypeCheck<T> & {\n\t\t\tCreate(): T['static']\n\t\t\tError(v: unknown): asserts v is T['static']\n\t\t}\n\n\t\tcompiler.Create = () => Value.Create(schema)\n\t\tcompiler.Error = (v: unknown) =>\n\t\t\tnew ValidationError('property', schema, v, compiler.Errors(v))\n\n\t\treturn compiler\n\t} catch {\n\t\treturn {\n\t\t\tCheck: (v: unknown) => Value.Check(schema, v),\n\t\t\tCheckThrow: (v: unknown) => {\n\t\t\t\tif (!Value.Check(schema, v))\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t'property',\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tv,\n\t\t\t\t\t\tValue.Errors(schema, v)\n\t\t\t\t\t)\n\t\t\t},\n\t\t\tDecode: (v: unknown) => Value.Decode(schema, v),\n\t\t\tCreate: () => Value.Create(schema),\n\t\t\tError: (v: unknown) =>\n\t\t\t\tnew ValidationError(\n\t\t\t\t\t'property',\n\t\t\t\t\tschema,\n\t\t\t\t\tv,\n\t\t\t\t\tValue.Errors(schema, v)\n\t\t\t\t)\n\t\t}\n\t}\n}\n\nexport const parseFileUnit = (size: FileUnit) => {\n\tif (typeof size === 'string')\n\t\tswitch (size.slice(-1)) {\n\t\t\tcase 'k':\n\t\t\t\treturn +size.slice(0, size.length - 1) * 1024\n\n\t\t\tcase 'm':\n\t\t\t\treturn +size.slice(0, size.length - 1) * 1048576\n\n\t\t\tdefault:\n\t\t\t\treturn +size\n\t\t}\n\n\treturn size\n}\n\nexport const checkFileExtension = (type: string, extension: string) => {\n\tif (type.startsWith(extension)) return true\n\n\treturn (\n\t\textension.charCodeAt(extension.length - 1) === 42 &&\n\t\textension.charCodeAt(extension.length - 2) === 47 &&\n\t\ttype.startsWith(extension.slice(0, -1))\n\t)\n}\n\nlet _fileTypeFromBlobWarn = false\nconst warnIfFileTypeIsNotInstalled = () => {\n\tif (!_fileTypeFromBlobWarn) {\n\t\tconsole.warn(\n\t\t\t\"[Elysia] Attempt to validate file type without 'file-type'. This may lead to security risks. We recommend installing 'file-type' to properly validate file extension.\"\n\t\t)\n\t\t_fileTypeFromBlobWarn = true\n\t}\n}\n\nexport const loadFileType = async () =>\n\timport('file-type')\n\t\t.then((x) => {\n\t\t\t_fileTypeFromBlob = x.fileTypeFromBlob\n\t\t\treturn _fileTypeFromBlob\n\t\t})\n\t\t.catch(warnIfFileTypeIsNotInstalled)\n\nlet _fileTypeFromBlob: Function\nexport const fileTypeFromBlob = (file: Blob | File) => {\n\tif (_fileTypeFromBlob) return _fileTypeFromBlob(file)\n\n\treturn loadFileType().then((mod) => {\n\t\tif (mod) return mod(file)\n\t})\n}\n\nexport const validateFileExtension = async (\n\tfile: MaybeArray<Blob | File | undefined>,\n\textension: string | string[],\n\t// @ts-ignore\n\tname = file?.name ?? ''\n): Promise<boolean> => {\n\tif (Array.isArray(file)) {\n\t\tawait Promise.all(\n\t\t\tfile.map((f) => validateFileExtension(f, extension, name))\n\t\t)\n\n\t\treturn true\n\t}\n\n\tif (!file) return false\n\n\tconst result = await fileTypeFromBlob(file)\n\tif (!result) throw new InvalidFileType(name, extension)\n\n\tif (typeof extension === 'string')\n\t\tif (!checkFileExtension(result.mime, extension))\n\t\t\tthrow new InvalidFileType(name, extension)\n\n\tfor (let i = 0; i < extension.length; i++)\n\t\tif (checkFileExtension(result.mime, extension[i])) return true\n\n\tthrow new InvalidFileType(name, extension)\n}\n\nexport const validateFile = (options: FileOptions, value: any) => {\n\tif (value instanceof ElysiaFile) return true\n\n\tif (!(value instanceof Blob)) return false\n\n\tif (options.minSize && value.size < parseFileUnit(options.minSize))\n\t\treturn false\n\n\tif (options.maxSize && value.size > parseFileUnit(options.maxSize))\n\t\treturn false\n\n\t// This only check file extension based on it's name / mimetype\n\t// to actual check the file type, use `validateFileExtension` instead\n\tif (options.extension) {\n\t\tif (typeof options.extension === 'string')\n\t\t\treturn checkFileExtension(value.type, options.extension)\n\n\t\tfor (let i = 0; i < options.extension.length; i++)\n\t\t\tif (checkFileExtension(value.type, options.extension[i]))\n\t\t\t\treturn true\n\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/**\n * Utility function to inherit add custom error and keep the original Validation error\n *\n * @since 1.3.14\n *\n * @example\n * ```ts\n * import { Elysia, t, errorWithDetail } from 'elysia'\n *\n * new Elysia()\n *\t\t.post('/', () => 'Hello World!', {\n *\t\t\tbody: t.Object({\n *\t\t\t\tx: t.Number({\n *\t\t\t\t\terror: validationDetail('x must be a number')\n *\t\t\t\t})\n *\t\t\t})\n *\t\t})\n */\nexport const validationDetail =\n\t<T>(message: T) =>\n\t(error: Parameters<ElysiaTypeCustomErrorCallback>[0]) => ({\n\t\t...error,\n\t\tmessage\n\t})\n",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"import type { Sucrose } from './sucrose'\nimport type { TraceHandler } from './trace'\n\nimport type {\n\tLifeCycleStore,\n\tMaybeArray,\n\tInputSchema,\n\tBaseMacro,\n\tLifeCycleType,\n\tHookContainer,\n\tGracefulHandler,\n\tPreHandler,\n\tBodyHandler,\n\tTransformHandler,\n\tOptionalHandler,\n\tMapResponse,\n\tErrorHandler,\n\tReplace,\n\tAfterResponseHandler,\n\tSchemaValidator,\n\tAnyLocalHook,\n\tSSEPayload,\n\tPrettify\n} from './types'\nimport { ElysiaFile } from './universal/file'\n\nexport const hasHeaderShorthand = 'toJSON' in new Headers()\n\nexport const replaceUrlPath = (url: string, pathname: string) => {\n\tconst urlObject = new URL(url)\n\turlObject.pathname = pathname\n\treturn urlObject.toString()\n}\n\nexport const isClass = (v: Object) =>\n\t(typeof v === 'function' && /^\\s*class\\s+/.test(v.toString())) ||\n\t// Handle Object.create(null)\n\t(v.toString &&\n\t\t// Handle import * as Sentry from '@sentry/bun'\n\t\t// This also handle [object Date], [object Array]\n\t\t// and FFI value like [object Prisma]\n\t\tv.toString().startsWith('[object ') &&\n\t\tv.toString() !== '[object Object]') ||\n\t// If object prototype is not pure, then probably a class-like object\n\tisNotEmpty(Object.getPrototypeOf(v))\n\nconst isObject = (item: any): item is Object =>\n\titem && typeof item === 'object' && !Array.isArray(item)\n\nexport const mergeDeep = <\n\tA extends Record<string, any>,\n\tB extends Record<string, any>\n>(\n\ttarget: A,\n\tsource: B,\n\toptions?: {\n\t\tskipKeys?: string[]\n\t\toverride?: boolean\n\t}\n): A & B => {\n\tconst skipKeys = options?.skipKeys\n\tconst override = options?.override ?? true\n\n\tif (!isObject(target) || !isObject(source)) return target as A & B\n\n\tfor (const [key, value] of Object.entries(source)) {\n\t\tif (skipKeys?.includes(key)) continue\n\n\t\tif (!isObject(value) || !(key in target) || isClass(value)) {\n\t\t\tif (override || !(key in target))\n\t\t\t\ttarget[key as keyof typeof target] = value\n\n\t\t\tcontinue\n\t\t}\n\n\t\ttarget[key as keyof typeof target] = mergeDeep(\n\t\t\t(target as any)[key] as any,\n\t\t\tvalue,\n\t\t\t{ skipKeys, override }\n\t\t)\n\t}\n\n\treturn target as A & B\n}\nexport const mergeCookie = <const A extends Object, const B extends Object>(\n\ta: A,\n\tb: B\n): A & B => {\n\tconst v = mergeDeep(Object.assign({}, a), b, {\n\t\tskipKeys: ['properties']\n\t}) as A & B\n\n\t// @ts-expect-error\n\tif (v.properties) delete v.properties\n\n\treturn v\n}\n\nexport const mergeObjectArray = <T extends HookContainer>(\n\ta: T | T[] | undefined,\n\tb: T | T[] | undefined\n): T[] | undefined => {\n\tif (!b) return a as any\n\n\t// ! Must copy to remove side-effect\n\tconst array = <T[]>[]\n\tconst checksums = <(number | undefined)[]>[]\n\n\tif (a) {\n\t\tif (!Array.isArray(a)) a = [a]\n\t\tfor (const item of a) {\n\t\t\tarray.push(item)\n\n\t\t\tif (item.checksum) checksums.push(item.checksum)\n\t\t}\n\t}\n\n\tif (b) {\n\t\tif (!Array.isArray(b)) b = [b]\n\t\tfor (const item of b)\n\t\t\tif (!checksums.includes(item.checksum)) array.push(item)\n\t}\n\n\treturn array\n}\n\nexport const primitiveHooks = [\n\t'start',\n\t'request',\n\t'parse',\n\t'transform',\n\t'resolve',\n\t'beforeHandle',\n\t'afterHandle',\n\t'mapResponse',\n\t'afterResponse',\n\t'trace',\n\t'error',\n\t'stop',\n\t'body',\n\t'headers',\n\t'params',\n\t'query',\n\t'response',\n\t'type',\n\t'detail'\n] as const\n\nconst primitiveHookMap = primitiveHooks.reduce(\n\t(acc, x) => ((acc[x] = true), acc),\n\t{} as Record<string, boolean>\n)\n\n// If both are Record<number, ...> then merge them,\n// giving preference to b.\ntype RecordNumber = Record<number, any>\nconst isRecordNumber = (\n\tx: Record<keyof object, unknown> | undefined\n): x is RecordNumber =>\n\ttypeof x === 'object' && Object.keys(x).every((x) => !isNaN(+x))\n\nexport const mergeResponse = (\n\ta: InputSchema['response'],\n\tb: InputSchema['response']\n) => {\n\tif (isRecordNumber(a) && isRecordNumber(b))\n\t\t// Prevent side effect\n\t\treturn Object.assign({}, a, b)\n\telse if (a && !isRecordNumber(a) && isRecordNumber(b))\n\t\treturn Object.assign({ 200: a }, b)\n\n\treturn b ?? a\n}\n\nexport const mergeSchemaValidator = (\n\ta?: SchemaValidator | null,\n\tb?: SchemaValidator | null\n): SchemaValidator => {\n\tif (!a && !b)\n\t\treturn {\n\t\t\tbody: undefined,\n\t\t\theaders: undefined,\n\t\t\tparams: undefined,\n\t\t\tquery: undefined,\n\t\t\tcookie: undefined,\n\t\t\tresponse: undefined\n\t\t}\n\n\treturn {\n\t\tbody: b?.body ?? a?.body,\n\t\theaders: b?.headers ?? a?.headers,\n\t\tparams: b?.params ?? a?.params,\n\t\tquery: b?.query ?? a?.query,\n\t\tcookie: b?.cookie ?? a?.cookie,\n\t\t// @ts-ignore ? This order is correct - SaltyAom\n\t\tresponse: mergeResponse(\n\t\t\t// @ts-ignore\n\t\t\ta?.response,\n\t\t\t// @ts-ignore\n\t\t\tb?.response\n\t\t)\n\t}\n}\n\nexport const mergeHook = (\n\ta?: Partial<LifeCycleStore>,\n\tb?: AnyLocalHook\n\t// { allowMacro = false }: { allowMacro?: boolean } = {}\n): LifeCycleStore => {\n\t// In case if merging union is need\n\t// const customAStore: Record<string, unknown> = {}\n\t// const customBStore: Record<string, unknown> = {}\n\n\t// for (const [key, value] of Object.entries(a)) {\n\t// \tif (primitiveHooks.includes(key as any)) continue\n\n\t// \tcustomAStore[key] = value\n\t// }\n\n\t// for (const [key, value] of Object.entries(b)) {\n\t// \tif (primitiveHooks.includes(key as any)) continue\n\n\t// \tcustomBStore[key] = value\n\t// }\n\n\t// const unioned = Object.keys(customAStore).filter((x) =>\n\t// \tObject.keys(customBStore).includes(x)\n\t// )\n\n\t// // Must provide empty object to prevent reference side-effect\n\t// const customStore = Object.assign({}, customAStore, customBStore)\n\n\t// for (const union of unioned)\n\t// \tcustomStore[union] = mergeObjectArray(\n\t// \t\tcustomAStore[union],\n\t// \t\tcustomBStore[union]\n\t// \t)\n\n\tif (!Object.values(b).find((x) => x !== undefined && x !== null))\n\t\treturn { ...a } as any\n\n\tconst hook = {\n\t\t...a,\n\t\t...b,\n\t\t// Merge local hook first\n\t\t// @ts-ignore\n\t\tbody: b?.body ?? a?.body,\n\t\t// @ts-ignore\n\t\theaders: b?.headers ?? a?.headers,\n\t\t// @ts-ignore\n\t\tparams: b?.params ?? a?.params,\n\t\t// @ts-ignore\n\t\tquery: b?.query ?? a?.query,\n\t\t// @ts-ignore\n\t\tcookie: b?.cookie ?? a?.cookie,\n\t\t// ? This order is correct - SaltyAom\n\t\tresponse: mergeResponse(\n\t\t\t// @ts-ignore\n\t\t\ta?.response,\n\t\t\t// @ts-ignore\n\t\t\tb?.response\n\t\t),\n\t\ttype: a?.type || b?.type,\n\t\tdetail: mergeDeep(\n\t\t\t// @ts-ignore\n\t\t\tb?.detail ?? {},\n\t\t\t// @ts-ignore\n\t\t\ta?.detail ?? {}\n\t\t),\n\t\tparse: mergeObjectArray(a?.parse as any, b?.parse),\n\t\ttransform: mergeObjectArray(a?.transform, b?.transform),\n\t\tbeforeHandle: mergeObjectArray(\n\t\t\tmergeObjectArray(\n\t\t\t\t// @ts-ignore\n\t\t\t\tfnToContainer(a?.resolve, 'resolve'),\n\t\t\t\ta?.beforeHandle\n\t\t\t),\n\t\t\tmergeObjectArray(\n\t\t\t\tfnToContainer(b.resolve, 'resolve'),\n\t\t\t\tb?.beforeHandle\n\t\t\t)\n\t\t),\n\t\tafterHandle: mergeObjectArray(a?.afterHandle, b?.afterHandle),\n\t\tmapResponse: mergeObjectArray(a?.mapResponse, b?.mapResponse) as any,\n\t\tafterResponse: mergeObjectArray(\n\t\t\ta?.afterResponse,\n\t\t\tb?.afterResponse\n\t\t) as any,\n\t\ttrace: mergeObjectArray(a?.trace, b?.trace) as any,\n\t\terror: mergeObjectArray(a?.error, b?.error)\n\t}\n\n\tif (hook.resolve) delete hook.resolve\n\n\treturn hook\n}\n\nexport const lifeCycleToArray = (a: LifeCycleStore) => {\n\tif (a.parse && !Array.isArray(a.parse)) a.parse = [a.parse]\n\n\tif (a.transform && !Array.isArray(a.transform)) a.transform = [a.transform]\n\n\tif (a.afterHandle && !Array.isArray(a.afterHandle))\n\t\ta.afterHandle = [a.afterHandle]\n\n\tif (a.mapResponse && !Array.isArray(a.mapResponse))\n\t\ta.mapResponse = [a.mapResponse]\n\n\tif (a.afterResponse && !Array.isArray(a.afterResponse))\n\t\ta.afterResponse = [a.afterResponse]\n\n\tif (a.trace && !Array.isArray(a.trace)) a.trace = [a.trace]\n\tif (a.error && !Array.isArray(a.error)) a.error = [a.error]\n\n\tlet beforeHandle = []\n\n\t// @ts-expect-error\n\tif (a.resolve) {\n\t\tbeforeHandle = fnToContainer(\n\t\t\t// @ts-expect-error\n\t\t\tArray.isArray(a.resolve) ? a.resolve : [a.resolve],\n\t\t\t'resolve'\n\t\t) as any[]\n\n\t\t// @ts-expect-error\n\t\tdelete a.resolve\n\t}\n\n\tif (a.beforeHandle) {\n\t\tif (beforeHandle.length)\n\t\t\tbeforeHandle = beforeHandle.concat(\n\t\t\t\tArray.isArray(a.beforeHandle)\n\t\t\t\t\t? a.beforeHandle\n\t\t\t\t\t: [a.beforeHandle]\n\t\t\t)\n\t\telse\n\t\t\tbeforeHandle = Array.isArray(a.beforeHandle)\n\t\t\t\t? a.beforeHandle\n\t\t\t\t: [a.beforeHandle]\n\t}\n\n\tif (beforeHandle.length) a.beforeHandle = beforeHandle\n\n\treturn a\n}\n\nconst isBun = typeof Bun !== 'undefined'\nconst hasBunHash = isBun && typeof Bun.hash === 'function'\n\n// https://stackoverflow.com/a/52171480\nexport const checksum = (s: string) => {\n\tif (hasBunHash) return Bun.hash(s) as unknown as number\n\n\tlet h = 9\n\n\tfor (let i = 0; i < s.length; ) h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9)\n\n\treturn (h = h ^ (h >>> 9))\n}\n\nexport const injectChecksum = (\n\tchecksum: number | undefined,\n\tx: MaybeArray<HookContainer> | undefined\n) => {\n\tif (!x) return\n\n\tif (!Array.isArray(x)) {\n\t\t// ? clone fn is required to prevent side-effect from changing hookType\n\t\tconst fn = x\n\n\t\tif (checksum && !fn.checksum) fn.checksum = checksum\n\t\tif (fn.scope === 'scoped') fn.scope = 'local'\n\n\t\treturn fn\n\t}\n\n\t// ? clone fns is required to prevent side-effect from changing hookType\n\tconst fns = [...x]\n\n\tfor (const fn of fns) {\n\t\tif (checksum && !fn.checksum) fn.checksum = checksum\n\n\t\tif (fn.scope === 'scoped') fn.scope = 'local'\n\t}\n\n\treturn fns\n}\n\nexport const mergeLifeCycle = (\n\ta: Partial<LifeCycleStore>,\n\tb: Partial<LifeCycleStore | AnyLocalHook>,\n\tchecksum?: number\n): LifeCycleStore => {\n\treturn {\n\t\tstart: mergeObjectArray(\n\t\t\ta.start,\n\t\t\tinjectChecksum(checksum, b?.start)\n\t\t) as HookContainer<GracefulHandler<any>>[],\n\t\trequest: mergeObjectArray(\n\t\t\ta.request,\n\t\t\tinjectChecksum(checksum, b?.request)\n\t\t) as HookContainer<PreHandler<any, any>>[],\n\t\tparse: mergeObjectArray(\n\t\t\ta.parse,\n\t\t\tinjectChecksum(checksum, b?.parse)\n\t\t) as HookContainer<BodyHandler<any, any>>[],\n\t\ttransform: mergeObjectArray(\n\t\t\ta.transform,\n\t\t\tinjectChecksum(checksum, b?.transform)\n\t\t) as HookContainer<TransformHandler<any, any>>[],\n\t\tbeforeHandle: mergeObjectArray(\n\t\t\tmergeObjectArray(\n\t\t\t\t// @ts-ignore\n\t\t\t\tfnToContainer(a.resolve, 'resolve'),\n\t\t\t\ta.beforeHandle\n\t\t\t),\n\t\t\tinjectChecksum(\n\t\t\t\tchecksum,\n\t\t\t\tmergeObjectArray(\n\t\t\t\t\tfnToContainer(b?.resolve, 'resolve'),\n\t\t\t\t\tb?.beforeHandle\n\t\t\t\t)\n\t\t\t)\n\t\t) as HookContainer<OptionalHandler<any, any>>[],\n\t\tafterHandle: mergeObjectArray(\n\t\t\ta.afterHandle,\n\t\t\tinjectChecksum(checksum, b?.afterHandle)\n\t\t) as HookContainer<OptionalHandler<any, any>>[],\n\t\tmapResponse: mergeObjectArray(\n\t\t\ta.mapResponse,\n\t\t\tinjectChecksum(checksum, b?.mapResponse)\n\t\t) as HookContainer<MapResponse<any, any>>[],\n\t\tafterResponse: mergeObjectArray(\n\t\t\ta.afterResponse,\n\t\t\tinjectChecksum(checksum, b?.afterResponse)\n\t\t) as HookContainer<AfterResponseHandler<any, any>>[],\n\t\t// Already merged on Elysia._use, also logic is more complicated, can't directly merge\n\t\ttrace: mergeObjectArray(\n\t\t\ta.trace,\n\t\t\tinjectChecksum(checksum, b?.trace)\n\t\t) as HookContainer<TraceHandler<any, any>>[],\n\t\terror: mergeObjectArray(\n\t\t\ta.error,\n\t\t\tinjectChecksum(checksum, b?.error)\n\t\t) as HookContainer<ErrorHandler<any, any, any>>[],\n\t\tstop: mergeObjectArray(\n\t\t\ta.stop,\n\t\t\tinjectChecksum(checksum, b?.stop)\n\t\t) as HookContainer<GracefulHandler<any>>[]\n\t}\n}\n\nexport const asHookType = (\n\tfn: HookContainer,\n\tinject: LifeCycleType,\n\t{ skipIfHasType = false }: { skipIfHasType?: boolean }\n) => {\n\tif (!fn) return fn\n\n\tif (!Array.isArray(fn)) {\n\t\tif (skipIfHasType) fn.scope ??= inject\n\t\telse fn.scope = inject\n\n\t\treturn fn\n\t}\n\n\tfor (const x of fn)\n\t\tif (skipIfHasType) x.scope ??= inject\n\t\telse x.scope = inject\n\n\treturn fn\n}\n\nconst filterGlobal = (fn: MaybeArray<HookContainer>) => {\n\tif (!fn) return fn\n\n\tif (!Array.isArray(fn))\n\t\tswitch (fn.scope) {\n\t\t\tcase 'global':\n\t\t\tcase 'scoped':\n\t\t\t\treturn { ...fn }\n\n\t\t\tdefault:\n\t\t\t\treturn { fn }\n\t\t}\n\n\tconst array = <any>[]\n\n\tfor (const x of fn)\n\t\tswitch (x.scope) {\n\t\t\tcase 'global':\n\t\t\tcase 'scoped':\n\t\t\t\tarray.push({\n\t\t\t\t\t...x\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t}\n\n\treturn array\n}\n\nexport const filterGlobalHook = (hook: AnyLocalHook): AnyLocalHook => {\n\treturn {\n\t\t// rest is validator\n\t\t...hook,\n\t\ttype: hook?.type,\n\t\tdetail: hook?.detail,\n\t\tparse: filterGlobal(hook?.parse),\n\t\ttransform: filterGlobal(hook?.transform),\n\t\tbeforeHandle: filterGlobal(hook?.beforeHandle),\n\t\tafterHandle: filterGlobal(hook?.afterHandle),\n\t\tmapResponse: filterGlobal(hook?.mapResponse),\n\t\tafterResponse: filterGlobal(hook?.afterResponse),\n\t\terror: filterGlobal(hook?.error),\n\t\ttrace: filterGlobal(hook?.trace)\n\t}\n}\n\nexport const StatusMap = {\n\tContinue: 100,\n\t'Switching Protocols': 101,\n\tProcessing: 102,\n\t'Early Hints': 103,\n\tOK: 200,\n\tCreated: 201,\n\tAccepted: 202,\n\t'Non-Authoritative Information': 203,\n\t'No Content': 204,\n\t'Reset Content': 205,\n\t'Partial Content': 206,\n\t'Multi-Status': 207,\n\t'Already Reported': 208,\n\t'Multiple Choices': 300,\n\t'Moved Permanently': 301,\n\tFound: 302,\n\t'See Other': 303,\n\t'Not Modified': 304,\n\t'Temporary Redirect': 307,\n\t'Permanent Redirect': 308,\n\t'Bad Request': 400,\n\tUnauthorized: 401,\n\t'Payment Required': 402,\n\tForbidden: 403,\n\t'Not Found': 404,\n\t'Method Not Allowed': 405,\n\t'Not Acceptable': 406,\n\t'Proxy Authentication Required': 407,\n\t'Request Timeout': 408,\n\tConflict: 409,\n\tGone: 410,\n\t'Length Required': 411,\n\t'Precondition Failed': 412,\n\t'Payload Too Large': 413,\n\t'URI Too Long': 414,\n\t'Unsupported Media Type': 415,\n\t'Range Not Satisfiable': 416,\n\t'Expectation Failed': 417,\n\t\"I'm a teapot\": 418,\n\t'Misdirected Request': 421,\n\t'Unprocessable Content': 422,\n\tLocked: 423,\n\t'Failed Dependency': 424,\n\t'Too Early': 425,\n\t'Upgrade Required': 426,\n\t'Precondition Required': 428,\n\t'Too Many Requests': 429,\n\t'Request Header Fields Too Large': 431,\n\t'Unavailable For Legal Reasons': 451,\n\t'Internal Server Error': 500,\n\t'Not Implemented': 501,\n\t'Bad Gateway': 502,\n\t'Service Unavailable': 503,\n\t'Gateway Timeout': 504,\n\t'HTTP Version Not Supported': 505,\n\t'Variant Also Negotiates': 506,\n\t'Insufficient Storage': 507,\n\t'Loop Detected': 508,\n\t'Not Extended': 510,\n\t'Network Authentication Required': 511\n} as const\n\nexport const InvertedStatusMap = Object.fromEntries(\n\tObject.entries(StatusMap).map(([k, v]) => [v, k])\n) as {\n\t[K in keyof StatusMap as StatusMap[K]]: K\n}\n\nexport type StatusMap = typeof StatusMap\nexport type InvertedStatusMap = typeof InvertedStatusMap\n\nfunction removeTrailingEquals(digest: string): string {\n\tlet trimmedDigest = digest\n\n\twhile (trimmedDigest.endsWith('='))\n\t\ttrimmedDigest = trimmedDigest.slice(0, -1)\n\n\treturn trimmedDigest\n}\n\nconst encoder = new TextEncoder()\n\nexport const signCookie = async (val: string, secret: string | null) => {\n\tif (typeof val === 'object') val = JSON.stringify(val)\n\telse if (typeof val !== 'string') val = val + ''\n\n\tif (secret === null) throw new TypeError('Secret key must be provided.')\n\n\tconst secretKey = await crypto.subtle.importKey(\n\t\t'raw',\n\t\tencoder.encode(secret),\n\t\t{ name: 'HMAC', hash: 'SHA-256' },\n\t\tfalse,\n\t\t['sign']\n\t)\n\n\tconst hmacBuffer = await crypto.subtle.sign(\n\t\t'HMAC',\n\t\tsecretKey,\n\t\tencoder.encode(val)\n\t)\n\n\t// console.log({\n\t// \tval,\n\t// \tsecret,\n\t// \thash: removeTrailingEquals(Buffer.from(hmacBuffer).toString('base64'))\n\t// })\n\n\treturn (\n\t\tval +\n\t\t'.' +\n\t\tremoveTrailingEquals(Buffer.from(hmacBuffer).toString('base64'))\n\t)\n}\n\nexport const unsignCookie = async (input: string, secret: string | null) => {\n\tif (typeof input !== 'string')\n\t\tthrow new TypeError('Signed cookie string must be provided.')\n\n\tif (null === secret) throw new TypeError('Secret key must be provided.')\n\n\tconst tentativeValue = input.slice(0, input.lastIndexOf('.'))\n\tconst expectedInput = await signCookie(tentativeValue, secret)\n\n\treturn expectedInput === input ? tentativeValue : false\n}\n\nexport const traceBackMacro = (\n\textension: unknown,\n\tproperty: Record<string, unknown>,\n\tmanage: ReturnType<typeof createMacroManager>\n) => {\n\tif (!extension || typeof extension !== 'object' || !property) return\n\n\tfor (const [key, value] of Object.entries(property)) {\n\t\tif (primitiveHookMap[key] || !(key in extension)) continue\n\n\t\tconst v = extension[\n\t\t\tkey as unknown as keyof typeof extension\n\t\t] as BaseMacro[string]\n\n\t\tif (typeof v === 'function') {\n\t\t\tconst hook = v(value)\n\n\t\t\tif (typeof hook === 'object')\n\t\t\t\tfor (const [k, v] of Object.entries(hook))\n\t\t\t\t\tmanage(k as keyof LifeCycleStore)({\n\t\t\t\t\t\tfn: v as any\n\t\t\t\t\t})\n\t\t}\n\n\t\tdelete property[key as unknown as keyof typeof extension]\n\t}\n}\n\nexport const createMacroManager =\n\t({\n\t\tglobalHook,\n\t\tlocalHook\n\t}: {\n\t\tglobalHook: Partial<LifeCycleStore>\n\t\tlocalHook: Partial<AnyLocalHook>\n\t}) =>\n\t(stackName: keyof LifeCycleStore) =>\n\t(\n\t\ttype:\n\t\t\t| {\n\t\t\t\t\tinsert?: 'before' | 'after'\n\t\t\t\t\tstack?: 'global' | 'local'\n\t\t\t }\n\t\t\t| MaybeArray<HookContainer>,\n\t\tfn?: MaybeArray<HookContainer>\n\t) => {\n\t\tif (typeof type === 'function')\n\t\t\ttype = {\n\t\t\t\tfn: type\n\t\t\t}\n\n\t\t// @ts-expect-error this is available in macro v2\n\t\tif (stackName === 'resolve') {\n\t\t\ttype = {\n\t\t\t\t...type,\n\t\t\t\tsubType: 'resolve'\n\t\t\t}\n\t\t}\n\n\t\tif (!localHook[stackName]) localHook[stackName] = []\n\t\tif (typeof localHook[stackName] === 'function')\n\t\t\tlocalHook[stackName] = [localHook[stackName]]\n\t\tif (!Array.isArray(localHook[stackName]))\n\t\t\tlocalHook[stackName] = [localHook[stackName]]\n\n\t\tif ('fn' in type || Array.isArray(type)) {\n\t\t\tif (Array.isArray(type))\n\t\t\t\tlocalHook[stackName] = (\n\t\t\t\t\tlocalHook[stackName] as unknown[]\n\t\t\t\t).concat(type) as any\n\t\t\telse localHook[stackName].push(type)\n\n\t\t\treturn\n\t\t}\n\n\t\tconst { insert = 'after', stack = 'local' } = type\n\n\t\tif (typeof fn === 'function') fn = { fn }\n\n\t\tif (stack === 'global') {\n\t\t\tif (!Array.isArray(fn)) {\n\t\t\t\tif (insert === 'before') {\n\t\t\t\t\t;(globalHook[stackName] as any[]).unshift(fn)\n\t\t\t\t} else {\n\t\t\t\t\t;(globalHook[stackName] as any[]).push(fn)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (insert === 'before') {\n\t\t\t\t\tglobalHook[stackName] = fn.concat(\n\t\t\t\t\t\tglobalHook[stackName] as any\n\t\t\t\t\t) as any\n\t\t\t\t} else {\n\t\t\t\t\tglobalHook[stackName] = (\n\t\t\t\t\t\tglobalHook[stackName] as any[]\n\t\t\t\t\t).concat(fn)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (!Array.isArray(fn)) {\n\t\t\t\tif (insert === 'before') {\n\t\t\t\t\t;(localHook[stackName] as any[]).unshift(fn)\n\t\t\t\t} else {\n\t\t\t\t\t;(localHook[stackName] as any[]).push(fn)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (insert === 'before') {\n\t\t\t\t\tlocalHook[stackName] = fn.concat(localHook[stackName])\n\t\t\t\t} else {\n\t\t\t\t\tlocalHook[stackName] = localHook[stackName].concat(fn)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\nconst parseNumericString = (message: string | number): number | null => {\n\tif (typeof message === 'number') return message\n\n\tif (message.length < 16) {\n\t\tif (message.trim().length === 0) return null\n\n\t\tconst length = Number(message)\n\t\tif (Number.isNaN(length)) return null\n\n\t\treturn length\n\t}\n\n\t// if 16 digit but less then 9,007,199,254,740,991 then can be parsed\n\tif (message.length === 16) {\n\t\tif (message.trim().length === 0) return null\n\n\t\tconst number = Number(message)\n\t\tif (Number.isNaN(number) || number.toString() !== message) return null\n\n\t\treturn number\n\t}\n\n\treturn null\n}\n\nexport const isNumericString = (message: string | number): boolean =>\n\tparseNumericString(message) !== null\n\nexport class PromiseGroup implements PromiseLike<void> {\n\troot: Promise<any> | null = null\n\tpromises: Promise<any>[] = []\n\n\tconstructor(\n\t\tpublic onError: (error: any) => void = console.error,\n\t\tpublic onFinally: () => void = () => {}\n\t) {}\n\n\t/**\n\t * The number of promises still being awaited.\n\t */\n\tget size() {\n\t\treturn this.promises.length\n\t}\n\n\t/**\n\t * Add a promise to the group.\n\t * @returns The promise that was added.\n\t */\n\tadd<T>(promise: Promise<T>) {\n\t\tthis.promises.push(promise)\n\t\tthis.root ||= this.drain()\n\n\t\tif (this.promises.length === 1) this.then(this.onFinally)\n\t\treturn promise\n\t}\n\n\tprivate async drain() {\n\t\twhile (this.promises.length > 0) {\n\t\t\ttry {\n\t\t\t\tawait this.promises[0]\n\t\t\t} catch (error) {\n\t\t\t\tthis.onError(error)\n\t\t\t}\n\t\t\tthis.promises.shift()\n\t\t}\n\t\tthis.root = null\n\t}\n\n\t// Allow the group to be awaited.\n\tthen<TResult1 = void, TResult2 = never>(\n\t\tonfulfilled?:\n\t\t\t| ((value: void) => TResult1 | PromiseLike<TResult1>)\n\t\t\t| undefined\n\t\t\t| null,\n\t\tonrejected?:\n\t\t\t| ((reason: any) => TResult2 | PromiseLike<TResult2>)\n\t\t\t| undefined\n\t\t\t| null\n\t): PromiseLike<TResult1 | TResult2> {\n\t\treturn (this.root ?? Promise.resolve()).then(onfulfilled, onrejected)\n\t}\n}\n\nexport const fnToContainer = (\n\tfn: MaybeArray<Function | HookContainer>,\n\t/** Only add subType to non contained fn */\n\tsubType?: HookContainer['subType']\n): MaybeArray<HookContainer> => {\n\tif (!fn) return fn\n\n\tif (!Array.isArray(fn)) {\n\t\t// parse can be a label since 1.2.0\n\t\tif (typeof fn === 'function' || typeof fn === 'string')\n\t\t\treturn subType ? { fn, subType } : { fn }\n\t\telse if ('fn' in fn) return fn\n\t}\n\n\tconst fns = <HookContainer[]>[]\n\tfor (const x of fn) {\n\t\t// parse can be a label since 1.2.0\n\t\tif (typeof x === 'function' || typeof x === 'string')\n\t\t\tfns.push(subType ? { fn: x, subType } : { fn: x })\n\t\telse if ('fn' in x) fns.push(x)\n\t}\n\n\treturn fns\n}\n\nexport const localHookToLifeCycleStore = (a: AnyLocalHook): LifeCycleStore => {\n\tif (a.start) a.start = fnToContainer(a.start)\n\tif (a.request) a.request = fnToContainer(a.request)\n\tif (a.parse) a.parse = fnToContainer(a.parse)\n\tif (a.transform) a.transform = fnToContainer(a.transform)\n\tif (a.beforeHandle) a.beforeHandle = fnToContainer(a.beforeHandle)\n\tif (a.afterHandle) a.afterHandle = fnToContainer(a.afterHandle)\n\tif (a.mapResponse) a.mapResponse = fnToContainer(a.mapResponse)\n\tif (a.afterResponse) a.afterResponse = fnToContainer(a.afterResponse)\n\tif (a.trace) a.trace = fnToContainer(a.trace)\n\tif (a.error) a.error = fnToContainer(a.error)\n\tif (a.stop) a.stop = fnToContainer(a.stop)\n\n\treturn a\n}\n\nexport const lifeCycleToFn = (a: Partial<LifeCycleStore>): AnyLocalHook => {\n\tconst lifecycle = Object.create(null)\n\n\tif (a.start?.map) lifecycle.start = a.start.map((x) => x.fn)\n\tif (a.request?.map) lifecycle.request = a.request.map((x) => x.fn)\n\tif (a.parse?.map) lifecycle.parse = a.parse.map((x) => x.fn)\n\tif (a.transform?.map) lifecycle.transform = a.transform.map((x) => x.fn)\n\tif (a.beforeHandle?.map)\n\t\tlifecycle.beforeHandle = a.beforeHandle.map((x) => x.fn)\n\tif (a.afterHandle?.map)\n\t\tlifecycle.afterHandle = a.afterHandle.map((x) => x.fn)\n\tif (a.mapResponse?.map)\n\t\tlifecycle.mapResponse = a.mapResponse.map((x) => x.fn)\n\tif (a.afterResponse?.map)\n\t\tlifecycle.afterResponse = a.afterResponse.map((x) => x.fn)\n\tif (a.error?.map) lifecycle.error = a.error.map((x) => x.fn)\n\tif (a.stop?.map) lifecycle.stop = a.stop.map((x) => x.fn)\n\n\tif (a.trace?.map) lifecycle.trace = a.trace.map((x) => x.fn)\n\telse lifecycle.trace = []\n\n\treturn lifecycle\n}\n\nexport const cloneInference = (inference: Sucrose.Inference) =>\n\t({\n\t\tbody: inference.body,\n\t\tcookie: inference.cookie,\n\t\theaders: inference.headers,\n\t\tquery: inference.query,\n\t\tset: inference.set,\n\t\tserver: inference.server,\n\t\tpath: inference.path,\n\t\troute: inference.route,\n\t\turl: inference.url\n\t}) satisfies Sucrose.Inference\n\n/**\n *\n * @param url URL to redirect to\n * @param HTTP status code to send,\n */\nexport const redirect = (\n\turl: string,\n\tstatus: 301 | 302 | 303 | 307 | 308 = 302\n) => Response.redirect(url, status)\n\nexport type redirect = typeof redirect\n\nexport const ELYSIA_FORM_DATA = Symbol('ElysiaFormData')\nexport type ELYSIA_FORM_DATA = typeof ELYSIA_FORM_DATA\n\ntype IsTuple<T> = T extends readonly any[]\n\t? number extends T['length']\n\t\t? false\n\t\t: true\n\t: false\n\nexport type ElysiaFormData<T extends Record<keyof any, unknown>> = FormData & {\n\t[ELYSIA_FORM_DATA]: Replace<T, Blob | ElysiaFile, File> extends infer A\n\t\t? {\n\t\t\t\t[key in keyof A]: IsTuple<A[key]> extends true\n\t\t\t\t\t? // @ts-ignore Trust me bro\n\t\t\t\t\t\tA[key][number] extends Blob | ElysiaFile\n\t\t\t\t\t\t? File[]\n\t\t\t\t\t\t: A[key]\n\t\t\t\t\t: A[key]\n\t\t\t}\n\t\t: T\n}\n\nexport const ELYSIA_REQUEST_ID = Symbol('ElysiaRequestId')\nexport type ELYSIA_REQUEST_ID = typeof ELYSIA_REQUEST_ID\n\nexport const form = <const T extends Record<keyof any, unknown>>(\n\titems: T\n): ElysiaFormData<T> => {\n\tconst formData = new FormData()\n\t// @ts-ignore\n\tformData[ELYSIA_FORM_DATA] = {}\n\n\tif (items)\n\t\tfor (const [key, value] of Object.entries(items)) {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tformData[ELYSIA_FORM_DATA][key] = []\n\n\t\t\t\tfor (const v of value) {\n\t\t\t\t\tif (value instanceof File)\n\t\t\t\t\t\tformData.append(key, value, value.name)\n\t\t\t\t\telse if (value instanceof ElysiaFile)\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tformData.append(key, value.value, value.value?.name)\n\t\t\t\t\telse formData.append(key, value as any)\n\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tformData[ELYSIA_FORM_DATA][key].push(value)\n\t\t\t\t}\n\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (value instanceof File) formData.append(key, value, value.name)\n\t\t\telse if (value instanceof ElysiaFile)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tformData.append(key, value.value, value.value?.name)\n\t\t\telse formData.append(key, value as any)\n\t\t\t// @ts-expect-error\n\t\t\tformData[ELYSIA_FORM_DATA][key] = value\n\t\t}\n\n\treturn formData as any\n}\n\nexport const randomId = () => {\n\tconst uuid = crypto.randomUUID()\n\treturn uuid.slice(0, 8) + uuid.slice(24, 32)\n}\n\n// ! Deduplicate current instance\nexport const deduplicateChecksum = <T extends Function>(\n\tarray: HookContainer<T>[]\n): HookContainer<T>[] => {\n\tif (!array.length) return []\n\n\tconst hashes: number[] = []\n\n\tfor (let i = 0; i < array.length; i++) {\n\t\tconst item = array[i]\n\n\t\tif (item.checksum) {\n\t\t\tif (hashes.includes(item.checksum)) {\n\t\t\t\tarray.splice(i, 1)\n\t\t\t\ti--\n\t\t\t}\n\n\t\t\thashes.push(item.checksum)\n\t\t}\n\t}\n\n\treturn array\n}\n\n/**\n * Since it's a plugin, which means that ephemeral is demoted to volatile.\n * Which means there's no volatile and all previous ephemeral become volatile\n * We can just promote back without worry\n */\nexport const promoteEvent = (\n\tevents?: (HookContainer | Function)[],\n\tas: 'scoped' | 'global' = 'scoped'\n): void => {\n\tif (!events) return\n\n\tif (as === 'scoped') {\n\t\tfor (const event of events)\n\t\t\tif ('scope' in event && event.scope === 'local')\n\t\t\t\tevent.scope = 'scoped'\n\n\t\treturn\n\t}\n\n\tfor (const event of events) if ('scope' in event) event.scope = 'global'\n}\n\n// type PropertyKeys<T> = {\n// \t[K in keyof T]: T[K] extends (...args: any[]) => any ? never : K\n// }[keyof T]\n\n// type PropertiesOnly<T> = Pick<T, PropertyKeys<T>>\n\n// export const classToObject = <T>(\n// \tinstance: T,\n// \tprocessed: WeakMap<object, object> = new WeakMap()\n// ): T extends object ? PropertiesOnly<T> : T => {\n// \tif (typeof instance !== 'object' || instance === null)\n// \t\treturn instance as any\n\n// \tif (Array.isArray(instance))\n// \t\treturn instance.map((x) => classToObject(x, processed)) as any\n\n// \tif (processed.has(instance)) return processed.get(instance) as any\n\n// \tconst result: Partial<T> = {}\n\n// \tfor (const key of Object.keys(instance) as Array<keyof T>) {\n// \t\tconst value = instance[key]\n// \t\tif (typeof value === 'object' && value !== null)\n// \t\t\tresult[key] = classToObject(value, processed) as T[keyof T]\n// \t\telse result[key] = value\n// \t}\n\n// \tconst prototype = Object.getPrototypeOf(instance)\n// \tif (!prototype) return result as any\n\n// \tconst properties = Object.getOwnPropertyNames(prototype)\n\n// \tfor (const property of properties) {\n// \t\tconst descriptor = Object.getOwnPropertyDescriptor(\n// \t\t\tObject.getPrototypeOf(instance),\n// \t\t\tproperty\n// \t\t)\n\n// \t\tif (descriptor && typeof descriptor.get === 'function') {\n// \t\t\t// ? Very important to prevent prototype pollution\n// \t\t\tif (property === '__proto__') continue\n\n// \t\t\t;(result as any)[property as keyof typeof instance] = classToObject(\n// \t\t\t\tinstance[property as keyof typeof instance]\n// \t\t\t)\n// \t\t}\n// \t}\n\n// \treturn result as any\n// }\n\nexport const getLoosePath = (path: string) => {\n\tif (path.charCodeAt(path.length - 1) === 47)\n\t\treturn path.slice(0, path.length - 1)\n\n\treturn path + '/'\n}\n\nexport const isNotEmpty = (obj?: Object) => {\n\tif (!obj) return false\n\n\tfor (const _ in obj) return true\n\n\treturn false\n}\n\nexport const encodePath = (path: string, { dynamic = false } = {}) => {\n\tlet encoded = encodeURIComponent(path).replace(/%2F/g, '/')\n\n\tif (dynamic) encoded = encoded.replace(/%3A/g, ':').replace(/%3F/g, '?')\n\n\treturn encoded\n}\n\nexport const supportPerMethodInlineHandler = (() => {\n\tif (typeof Bun === 'undefined') return true\n\n\tconst semver = Bun.version.split('.')\n\tif (+semver[0] < 1 || +semver[1] < 2 || +semver[2] < 14) return false\n\n\treturn true\n})()\n\ntype FormatSSEPayload<T = unknown> = T extends string\n\t? { readonly data: T }\n\t: Prettify<SSEPayload<T>>\n\n/**\n * Return a Server Sent Events (SSE) payload\n *\n * @example\n * ```ts\n * import { sse } from 'elysia'\n *\n * new Elysia()\n * .get('/sse', function*() {\n * yield sse('Hello, world!')\n * yield sse({\n * event: 'message',\n * data: { message: 'This is a JSON object' }\n * })\n * }\n */\nexport const sse = <\n\tconst T extends\n\t\t| string\n\t\t| SSEPayload\n\t\t| Generator\n\t\t| AsyncGenerator\n\t\t| ReadableStream\n>(\n\t_payload: T\n): T extends string\n\t? { readonly data: T }\n\t: T extends SSEPayload\n\t\t? T\n\t\t: T extends ReadableStream<infer A>\n\t\t\t? ReadableStream<FormatSSEPayload<A>>\n\t\t\t: T extends Generator<infer A, infer B, infer C>\n\t\t\t\t? Generator<FormatSSEPayload<A>, B, C>\n\t\t\t\t: T extends AsyncGenerator<infer A, infer B, infer C>\n\t\t\t\t\t? AsyncGenerator<FormatSSEPayload<A>, B, C>\n\t\t\t\t\t: T => {\n\tif (_payload instanceof ReadableStream) {\n\t\t// @ts-expect-error\n\t\t_payload.sse = true\n\t\treturn _payload as any\n\t}\n\n\tconst payload: SSEPayload =\n\t\ttypeof _payload === 'string'\n\t\t\t? { data: _payload }\n\t\t\t: (_payload as SSEPayload)\n\n\t// if (payload.id === undefined) payload.id = randomId()\n\n\t// @ts-ignore\n\tpayload.sse = true\n\n\t// @ts-ignore\n\tpayload.toSSE = () => {\n\t\tlet payloadString = ''\n\n\t\tif (payload.id !== undefined && payload.id !== null)\n\t\t\tpayloadString += `id: ${payload.id}\\n`\n\t\tif (payload.event) payloadString += `event: ${payload.event}\\n`\n\t\tif (payload.retry !== undefined)\n\t\t\tpayloadString += `retry: ${payload.retry}\\n`\n\n\t\tif (payload.data === null) payloadString += 'data: null\\n'\n\t\telse if (typeof payload.data === 'string')\n\t\t\tpayloadString += `data: ${payload.data}\\n`\n\t\telse if (typeof payload.data === 'object')\n\t\t\tpayloadString += `data: ${JSON.stringify(payload.data)}\\n`\n\n\t\tif (payloadString) payloadString += '\\n'\n\n\t\treturn payloadString\n\t}\n\n\treturn payload as any\n}\n",
|
|
16
16
|
"/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-constant-condition */\nimport { checksum } from './utils'\nimport { isBun } from './universal/utils'\n\nimport type { Handler, HookContainer, LifeCycleStore } from './types'\n\nexport namespace Sucrose {\n\texport interface Inference {\n\t\tquery: boolean\n\t\theaders: boolean\n\t\tbody: boolean\n\t\tcookie: boolean\n\t\tset: boolean\n\t\tserver: boolean\n\t\troute: boolean\n\t\turl: boolean\n\t\tpath: boolean\n\t}\n\n\texport interface LifeCycle extends Partial<LifeCycleStore> {\n\t\thandler?: Handler\n\t}\n}\n\n/**\n * Separate stringified function body and paramter\n *\n * @example\n * ```typescript\n * separateFunction('async ({ hello }) => { return hello }') // => ['({ hello })', '{ return hello }']\n * ```\n */\nexport const separateFunction = (\n\tcode: string\n): [string, string, { isArrowReturn: boolean }] => {\n\t// Remove async keyword without removing space (both minify and non-minify)\n\tif (code.startsWith('async')) code = code.slice(5)\n\tcode = code.trimStart()\n\n\tlet index = -1\n\n\t// JSC: Starts with '(', is an arrow function\n\tif (code.charCodeAt(0) === 40) {\n\t\tindex = code.indexOf('=>', code.indexOf(')'))\n\n\t\tif (index !== -1) {\n\t\t\tlet bracketEndIndex = index\n\t\t\t// Walk back to find bracket end\n\t\t\twhile (bracketEndIndex > 0)\n\t\t\t\tif (code.charCodeAt(--bracketEndIndex) === 41) break\n\n\t\t\tlet body = code.slice(index + 2)\n\t\t\tif (body.charCodeAt(0) === 32) body = body.trimStart()\n\n\t\t\treturn [\n\t\t\t\tcode.slice(1, bracketEndIndex),\n\t\t\t\tbody,\n\t\t\t\t{\n\t\t\t\t\tisArrowReturn: body.charCodeAt(0) !== 123\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t}\n\n\t// V8: bracket is removed for 1 parameter arrow function\n\tif (/^(\\w+)=>/g.test(code)) {\n\t\tindex = code.indexOf('=>')\n\n\t\tif (index !== -1) {\n\t\t\tlet body = code.slice(index + 2)\n\t\t\tif (body.charCodeAt(0) === 32) body = body.trimStart()\n\n\t\t\treturn [\n\t\t\t\tcode.slice(0, index),\n\t\t\t\tbody,\n\t\t\t\t{\n\t\t\t\t\tisArrowReturn: body.charCodeAt(0) !== 123\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t}\n\n\t// Using function keyword\n\tif (code.startsWith('function')) {\n\t\tindex = code.indexOf('(')\n\t\tconst end = code.indexOf(')')\n\n\t\treturn [\n\t\t\tcode.slice(index + 1, end),\n\t\t\tcode.slice(end + 2),\n\t\t\t{\n\t\t\t\tisArrowReturn: false\n\t\t\t}\n\t\t]\n\t}\n\n\t// Probably Declare as method\n\tconst start = code.indexOf('(')\n\n\tif (start !== -1) {\n\t\tconst sep = code.indexOf('\\n', 2)\n\t\tconst parameter = code.slice(0, sep)\n\t\tconst end = parameter.lastIndexOf(')') + 1\n\n\t\tconst body = code.slice(sep + 1)\n\n\t\treturn [\n\t\t\tparameter.slice(start, end),\n\t\t\t'{' + body,\n\t\t\t{\n\t\t\t\tisArrowReturn: false\n\t\t\t}\n\t\t]\n\t}\n\n\t// Unknown case\n\tconst x = code.split('\\n', 2)\n\n\treturn [x[0], x[1], { isArrowReturn: false }]\n}\n\n/**\n * Get range between bracket pair\n *\n * @example\n * ```typescript\n * bracketPairRange('hello: { world: { a } }, elysia') // [6, 20]\n * ```\n */\nexport const bracketPairRange = (parameter: string): [number, number] => {\n\tconst start = parameter.indexOf('{')\n\tif (start === -1) return [-1, 0]\n\n\tlet end = start + 1\n\tlet deep = 1\n\n\tfor (; end < parameter.length; end++) {\n\t\tconst char = parameter.charCodeAt(end)\n\n\t\t// Open bracket\n\t\tif (char === 123) deep++\n\t\t// Close bracket\n\t\telse if (char === 125) deep--\n\n\t\tif (deep === 0) break\n\t}\n\n\tif (deep !== 0) return [0, parameter.length]\n\n\treturn [start, end + 1]\n}\n\n/**\n * Similar to `bracketPairRange` but in reverse order\n * Get range between bracket pair from end to beginning\n *\n * @example\n * ```typescript\n * bracketPairRange('hello: { world: { a } }, elysia') // [6, 20]\n * ```\n */\nexport const bracketPairRangeReverse = (\n\tparameter: string\n): [number, number] => {\n\tconst end = parameter.lastIndexOf('}')\n\tif (end === -1) return [-1, 0]\n\n\tlet start = end - 1\n\tlet deep = 1\n\n\tfor (; start >= 0; start--) {\n\t\tconst char = parameter.charCodeAt(start)\n\n\t\t// Open bracket\n\t\tif (char === 125) deep++\n\t\t// Close bracket\n\t\telse if (char === 123) deep--\n\n\t\tif (deep === 0) break\n\t}\n\n\tif (deep !== 0) return [-1, 0]\n\n\treturn [start, end + 1]\n}\n\nexport const removeColonAlias = (parameter: string) => {\n\twhile (true) {\n\t\tconst start = parameter.indexOf(':')\n\t\tif (start === -1) break\n\n\t\tlet end = parameter.indexOf(',', start)\n\t\tif (end === -1) end = parameter.indexOf('}', start) - 1\n\t\tif (end === -2) end = parameter.length\n\n\t\tparameter = parameter.slice(0, start) + parameter.slice(end)\n\t}\n\n\treturn parameter\n}\n\n/**\n * Retrieve only root paramters of a function\n *\n * @example\n * ```typescript\n * retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => {\n * parameters: ['hello', 'elysia'],\n * hasParenthesis: true\n * }\n * ```\n */\nexport const retrieveRootParamters = (parameter: string) => {\n\tlet hasParenthesis = false\n\n\t// Remove () from parameter\n\tif (parameter.charCodeAt(0) === 40) parameter = parameter.slice(1, -1)\n\n\t// Remove {} from parameter\n\tif (parameter.charCodeAt(0) === 123) {\n\t\thasParenthesis = true\n\t\tparameter = parameter.slice(1, -1)\n\t}\n\n\tparameter = parameter.replace(/( |\\t|\\n)/g, '').trim()\n\tlet parameters = <string[]>[]\n\n\t// Object destructuring\n\twhile (true) {\n\t\t// eslint-disable-next-line prefer-const\n\t\tlet [start, end] = bracketPairRange(parameter)\n\t\tif (start === -1) break\n\n\t\t// Remove colon from object structuring cast\n\t\tparameters.push(parameter.slice(0, start - 1))\n\t\tif (parameter.charCodeAt(end) === 44) end++\n\t\tparameter = parameter.slice(end)\n\t}\n\n\tparameter = removeColonAlias(parameter)\n\tif (parameter) parameters = parameters.concat(parameter.split(','))\n\n\tconst parameterMap: Record<string, true> = Object.create(null)\n\tfor (const p of parameters) {\n\t\tif (p.indexOf(',') === -1) {\n\t\t\tparameterMap[p] = true\n\t\t\tcontinue\n\t\t}\n\n\t\tfor (const q of p.split(',')) parameterMap[q.trim()] = true\n\t}\n\n\treturn {\n\t\thasParenthesis,\n\t\tparameters: parameterMap\n\t}\n}\n\n/**\n * Find inference from parameter\n *\n * @param parameter stringified parameter\n */\nexport const findParameterReference = (\n\tparameter: string,\n\tinference: Sucrose.Inference\n) => {\n\tconst { parameters, hasParenthesis } = retrieveRootParamters(parameter)\n\n\t// Check if root is an object destructuring\n\tif (parameters.query) inference.query = true\n\tif (parameters.headers) inference.headers = true\n\tif (parameters.body) inference.body = true\n\tif (parameters.cookie) inference.cookie = true\n\tif (parameters.set) inference.set = true\n\tif (parameters.server) inference.server = true\n\tif (parameters.route) inference.route = true\n\tif (parameters.url) inference.url = true\n\tif (parameters.path) inference.path = true\n\n\tif (hasParenthesis) return `{ ${Object.keys(parameters).join(', ')} }`\n\n\treturn Object.keys(parameters).join(', ')\n}\n\nconst findEndIndex = (\n\ttype: string,\n\tcontent: string,\n\tindex?: number | undefined\n) => {\n\tconst regex = new RegExp(\n\t\t`${type.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}[\\\\n\\\\t,; ]`\n\t)\n\n\tif (index !== undefined) regex.lastIndex = index\n\n\tconst match = regex.exec(content)\n\n\treturn match ? match.index : -1\n}\n\nconst findEndQueryBracketIndex = (\n\ttype: string,\n\tcontent: string,\n\tindex?: number | undefined\n) => {\n\tconst bracketEndIndex = content.indexOf(type + ']', index)\n\tconst singleQuoteIndex = content.indexOf(type + \"'\", index)\n\tconst doubleQuoteIndex = content.indexOf(type + '\"', index)\n\n\t// Pick the smallest index that is not -1 or 0\n\treturn (\n\t\t[bracketEndIndex, singleQuoteIndex, doubleQuoteIndex]\n\t\t\t.filter((i) => i > 0)\n\t\t\t.sort((a, b) => a - b)[0] || -1\n\t)\n}\n\n/**\n * Find alias of variable from function body\n *\n * @example\n * ```typescript\n * findAlias('body', '{ const a = body, b = body }') // => ['a', 'b']\n * ```\n */\nexport const findAlias = (type: string, body: string, depth = 0) => {\n\tif (depth > 5) return []\n\n\tconst aliases: string[] = []\n\n\tlet content = body\n\n\twhile (true) {\n\t\tlet index = findEndIndex(' = ' + type, content)\n\t\t// V8 engine minified the code\n\t\tif (index === -1) index = findEndIndex('=' + type, content)\n\n\t\tif (index === -1) {\n\t\t\t/**\n\t\t\t * Check if pattern is at the end of the string\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```typescript\n\t\t\t * 'const a = body' // true\n\t\t\t * ```\n\t\t\t **/\n\t\t\tlet lastIndex = content.indexOf(' = ' + type)\n\t\t\tif (lastIndex === -1) lastIndex = content.indexOf('=' + type)\n\n\t\t\tif (lastIndex + 3 + type.length !== content.length) break\n\n\t\t\tindex = lastIndex\n\t\t}\n\n\t\tconst part = content.slice(0, index)\n\n\t\t// V8 engine minified the code\n\t\tconst lastPart = part.lastIndexOf(' ')\n\t\t/**\n\t\t * aliased variable last character\n\t\t *\n\t\t * @example\n\t\t * ```typescript\n\t\t * const { hello } = body // } is the last character\n\t\t * ```\n\t\t **/\n\t\tlet variable = part.slice(lastPart !== -1 ? lastPart + 1 : -1)\n\n\t\t// Variable is using object destructuring, find the bracket pair\n\t\tif (variable === '}') {\n\t\t\tconst [start, end] = bracketPairRangeReverse(part)\n\n\t\t\taliases.push(removeColonAlias(content.slice(start, end)))\n\n\t\t\tcontent = content.slice(index + 3 + type.length)\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// Remove comma\n\t\twhile (variable.charCodeAt(0) === 44) variable = variable.slice(1)\n\t\twhile (variable.charCodeAt(0) === 9) variable = variable.slice(1)\n\n\t\tif (!variable.includes('(')) aliases.push(variable)\n\n\t\tcontent = content.slice(index + 3 + type.length)\n\t}\n\n\tfor (const alias of aliases) {\n\t\tif (alias.charCodeAt(0) === 123) continue\n\n\t\tconst deepAlias = findAlias(alias, body)\n\t\tif (deepAlias.length > 0) aliases.push(...deepAlias)\n\t}\n\n\treturn aliases\n}\n\n// ? This is normalized to dot notation in Bun\n// const accessor = <T extends string, P extends string>(parent: T, prop: P) =>\n// \t[\n// \t\tparent + '.' + prop,\n// \t\tparent + '[\"' + prop + '\"]',\n// \t\tparent + \"['\" + prop + \"']\"\n// \t] as const\n\nexport const extractMainParameter = (parameter: string) => {\n\tif (!parameter) return\n\n\tif (parameter.charCodeAt(0) !== 123) return parameter\n\n\tparameter = parameter.slice(2, -2)\n\n\tconst hasComma = parameter.includes(',')\n\tif (!hasComma) {\n\t\tconst index = parameter.indexOf('...')\n\t\t// This happens when spread operator is used as the only parameter\n\t\tif (index !== -1) return parameter.slice(parameter.indexOf('...') + 3)\n\n\t\treturn\n\t}\n\n\tconst spreadIndex = parameter.indexOf('...')\n\tif (spreadIndex === -1) return\n\n\t// Spread parameter is always the last parameter, no need for further checking\n\treturn parameter.slice(spreadIndex + 3).trimEnd()\n}\n\n/**\n * Analyze if context is mentioned in body\n */\nexport const inferBodyReference = (\n\tcode: string,\n\taliases: string[],\n\tinference: Sucrose.Inference\n) => {\n\tconst access = (type: string, alias: string) =>\n\t\tnew RegExp(\n\t\t\t`${alias}\\\\.(${type})|${alias}\\\\[\"${type}\"\\\\]|${alias}\\\\['${type}'\\\\]`\n\t\t).test(code)\n\n\tfor (const alias of aliases) {\n\t\tif (!alias) continue\n\n\t\t// Scan object destructured property\n\t\tif (alias.charCodeAt(0) === 123) {\n\t\t\tconst parameters = retrieveRootParamters(alias).parameters\n\n\t\t\tif (parameters.query) inference.query = true\n\t\t\tif (parameters.headers) inference.headers = true\n\t\t\tif (parameters.body) inference.body = true\n\t\t\tif (parameters.cookie) inference.cookie = true\n\t\t\tif (parameters.set) inference.set = true\n\t\t\tif (parameters.server) inference.server = true\n\t\t\tif (parameters.url) inference.url = true\n\t\t\tif (parameters.route) inference.route = true\n\t\t\tif (parameters.path) inference.path = true\n\n\t\t\tcontinue\n\t\t}\n\n\t\tif (\n\t\t\t!inference.query &&\n\t\t\t(access('query', alias) ||\n\t\t\t\tcode.includes('return ' + alias) ||\n\t\t\t\tcode.includes('return ' + alias + '.query'))\n\t\t)\n\t\t\tinference.query = true\n\n\t\tif (!inference.headers && access('headers', alias))\n\t\t\tinference.headers = true\n\n\t\tif (!inference.body && access('body', alias)) inference.body = true\n\n\t\tif (!inference.cookie && access('cookie', alias))\n\t\t\tinference.cookie = true\n\n\t\tif (!inference.set && access('set', alias)) inference.set = true\n\t\tif (!inference.server && access('server', alias))\n\t\t\tinference.server = true\n\n\t\tif (!inference.route && access('route', alias)) inference.route = true\n\t\tif (!inference.url && access('url', alias)) inference.url = true\n\t\tif (!inference.path && access('path', alias)) inference.path = true\n\n\t\tif (\n\t\t\tinference.query &&\n\t\t\tinference.headers &&\n\t\t\tinference.body &&\n\t\t\tinference.cookie &&\n\t\t\tinference.set &&\n\t\t\tinference.server &&\n\t\t\tinference.route &&\n\t\t\tinference.url &&\n\t\t\tinference.path\n\t\t)\n\t\t\tbreak\n\t}\n\n\treturn aliases\n}\n\nexport const removeDefaultParameter = (parameter: string) => {\n\twhile (true) {\n\t\tconst index = parameter.indexOf('=')\n\t\tif (index === -1) break\n\n\t\tconst commaIndex = parameter.indexOf(',', index)\n\t\tconst bracketIndex = parameter.indexOf('}', index)\n\n\t\tconst end =\n\t\t\t[commaIndex, bracketIndex]\n\t\t\t\t.filter((i) => i > 0)\n\t\t\t\t.sort((a, b) => a - b)[0] || -1\n\n\t\tif (end === -1) {\n\t\t\tparameter = parameter.slice(0, index)\n\n\t\t\tbreak\n\t\t}\n\n\t\tparameter = parameter.slice(0, index) + parameter.slice(end)\n\t}\n\n\treturn parameter\n\t\t.split(',')\n\t\t.map((i) => i.trim())\n\t\t.join(', ')\n}\n\nexport const isContextPassToFunction = (\n\tcontext: string,\n\tbody: string,\n\tinference: Sucrose.Inference\n) => {\n\t// ! Function is passed to another function, assume as all is accessed\n\ttry {\n\t\tconst captureFunction = new RegExp(`\\\\w\\\\((.*?)?${context}`, 'gs')\n\t\tcaptureFunction.test(body)\n\n\t\t/*\n\t\tSince JavaScript engine already format the code (removing whitespace, newline, etc.),\n\t\twe can safely assume that the next character is either a closing bracket or a comma\n\t\tif the function is passed to another function\n\t\t*/\n\t\tconst nextChar = body.charCodeAt(captureFunction.lastIndex)\n\n\t\tif (nextChar === 41 || nextChar === 44) {\n\t\t\tinference.query = true\n\t\t\tinference.headers = true\n\t\t\tinference.body = true\n\t\t\tinference.cookie = true\n\t\t\tinference.set = true\n\t\t\tinference.server = true\n\t\t\tinference.url = true\n\t\t\tinference.route = true\n\t\t\tinference.path = true\n\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t} catch (error) {\n\t\tconsole.log(\n\t\t\t'[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:'\n\t\t)\n\t\tconsole.log('--- body ---')\n\t\tconsole.log(body)\n\t\tconsole.log('--- context ---')\n\t\tconsole.log(context)\n\n\t\treturn true\n\t}\n}\n\nlet pendingGC: number | undefined\nlet caches = <Record<number, Sucrose.Inference>>{}\n\nexport const clearSucroseCache = (delay = 0) => {\n\tif (pendingGC) clearTimeout(pendingGC)\n\n\tpendingGC = setTimeout(() => {\n\t\tcaches = {}\n\n\t\tpendingGC = undefined\n\t\tif (isBun) Bun.gc(false)\n\t}, delay) as unknown as number\n}\n\nexport const mergeInference = (a: Sucrose.Inference, b: Sucrose.Inference) => {\n\treturn {\n\t\tbody: a.body || b.body,\n\t\tcookie: a.cookie || b.cookie,\n\t\theaders: a.headers || b.headers,\n\t\tquery: a.query || b.query,\n\t\tset: a.set || b.set,\n\t\tserver: a.server || b.server,\n\t\turl: a.url || b.url,\n\t\troute: a.route || b.route,\n\t\tpath: a.path || b.path\n\t}\n}\n\nexport const sucrose = (\n\tlifeCycle: Sucrose.LifeCycle,\n\tinference: Sucrose.Inference = {\n\t\tquery: false,\n\t\theaders: false,\n\t\tbody: false,\n\t\tcookie: false,\n\t\tset: false,\n\t\tserver: false,\n\t\turl: false,\n\t\troute: false,\n\t\tpath: false\n\t}\n): Sucrose.Inference => {\n\tconst events = <(Handler | HookContainer)[]>[]\n\n\tif (lifeCycle.request?.length) events.push(...lifeCycle.request)\n\tif (lifeCycle.beforeHandle?.length) events.push(...lifeCycle.beforeHandle)\n\tif (lifeCycle.parse?.length) events.push(...lifeCycle.parse)\n\tif (lifeCycle.error?.length) events.push(...lifeCycle.error)\n\tif (lifeCycle.transform?.length) events.push(...lifeCycle.transform)\n\tif (lifeCycle.afterHandle?.length) events.push(...lifeCycle.afterHandle)\n\tif (lifeCycle.mapResponse?.length) events.push(...lifeCycle.mapResponse)\n\tif (lifeCycle.afterResponse?.length) events.push(...lifeCycle.afterResponse)\n\n\tif (lifeCycle.handler && typeof lifeCycle.handler === 'function')\n\t\tevents.push(lifeCycle.handler as Handler)\n\n\tfor (let i = 0; i < events.length; i++) {\n\t\tconst e = events[i]\n\t\tif (!e) continue\n\n\t\tconst event = typeof e === 'object' ? e.fn : e\n\n\t\t// parse can be either a function or string\n\t\tif (typeof event !== 'function') continue\n\n\t\tconst content = event.toString()\n\t\tconst key = checksum(content)\n\t\tconst cachedInference = caches[key]\n\t\tif (cachedInference) {\n\t\t\tinference = mergeInference(inference, cachedInference)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst fnInference: Sucrose.Inference = {\n\t\t\tquery: false,\n\t\t\theaders: false,\n\t\t\tbody: false,\n\t\t\tcookie: false,\n\t\t\tset: false,\n\t\t\tserver: false,\n\t\t\turl: false,\n\t\t\troute: false,\n\t\t\tpath: false\n\t\t}\n\n\t\tconst [parameter, body] = separateFunction(content)\n\n\t\tconst rootParameters = findParameterReference(parameter, fnInference)\n\t\tconst mainParameter = extractMainParameter(rootParameters)\n\n\t\tif (mainParameter) {\n\t\t\tconst aliases = findAlias(mainParameter, body.slice(1, -1))\n\t\t\taliases.splice(0, -1, mainParameter)\n\n\t\t\tlet code = body\n\n\t\t\tif (\n\t\t\t\tcode.charCodeAt(0) === 123 &&\n\t\t\t\tcode.charCodeAt(body.length - 1) === 125\n\t\t\t)\n\t\t\t\tcode = code.slice(1, -1)\n\n\t\t\tif (!isContextPassToFunction(mainParameter, code, fnInference))\n\t\t\t\tinferBodyReference(code, aliases, fnInference)\n\n\t\t\tif (\n\t\t\t\t!fnInference.query &&\n\t\t\t\tcode.includes('return ' + mainParameter + '.query')\n\t\t\t)\n\t\t\t\tfnInference.query = true\n\t\t}\n\n\t\tif (!caches[key]) caches[key] = fnInference\n\n\t\tinference = mergeInference(inference, fnInference)\n\n\t\tif (\n\t\t\tinference.query &&\n\t\t\tinference.headers &&\n\t\t\tinference.body &&\n\t\t\tinference.cookie &&\n\t\t\tinference.set &&\n\t\t\tinference.server &&\n\t\t\tinference.url &&\n\t\t\tinference.route &&\n\t\t\tinference.path\n\t\t)\n\t\t\tbreak\n\t}\n\n\treturn inference\n}\n",
|
|
17
17
|
"import { parse, serialize } from 'cookie'\n\nimport decode from 'fast-decode-uri-component'\n\nimport { isNotEmpty, unsignCookie } from './utils'\nimport { InvalidCookieSignature } from './error'\n\nimport type { Context } from './context'\nimport type { Prettify } from './types'\n\nexport interface CookieOptions {\n\t/**\n\t * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no\n\t * domain is set, and most clients will consider the cookie to apply to only\n\t * the current domain.\n\t */\n\tdomain?: string | undefined\n\n\t/**\n\t * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default,\n\t * no expiration is set, and most clients will consider this a \"non-persistent cookie\" and will delete\n\t * it on a condition like exiting a web browser application.\n\t *\n\t * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}\n\t * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is\n\t * possible not all clients by obey this, so if both are set, they should\n\t * point to the same date and time.\n\t */\n\texpires?: Date | undefined\n\t/**\n\t * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.\n\t * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By\n\t * default, the `HttpOnly` attribute is not set.\n\t *\n\t * *Note* be careful when setting this to true, as compliant clients will\n\t * not allow client-side JavaScript to see the cookie in `document.cookie`.\n\t */\n\thttpOnly?: boolean | undefined\n\t/**\n\t * Specifies the number (in seconds) to be the value for the `Max-Age`\n\t * `Set-Cookie` attribute. The given number will be converted to an integer\n\t * by rounding down. By default, no maximum age is set.\n\t *\n\t * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}\n\t * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is\n\t * possible not all clients by obey this, so if both are set, they should\n\t * point to the same date and time.\n\t */\n\tmaxAge?: number | undefined\n\t/**\n\t * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.\n\t * By default, the path is considered the \"default path\".\n\t */\n\tpath?: string | undefined\n\t/**\n\t * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].\n\t *\n\t * - `'low'` will set the `Priority` attribute to `Low`.\n\t * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.\n\t * - `'high'` will set the `Priority` attribute to `High`.\n\t *\n\t * More information about the different priority levels can be found in\n\t * [the specification][rfc-west-cookie-priority-00-4.1].\n\t *\n\t * **note** This is an attribute that has not yet been fully standardized, and may change in the future.\n\t * This also means many clients may ignore this attribute until they understand it.\n\t */\n\tpriority?: 'low' | 'medium' | 'high' | undefined\n\t/**\n\t * Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](rfc-cutler-httpbis-partitioned-cookies)\n\t * attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the\n\t * `Partitioned` attribute is not set.\n\t *\n\t * **note** This is an attribute that has not yet been fully standardized, and may change in the future.\n\t * This also means many clients may ignore this attribute until they understand it.\n\t *\n\t * More information about can be found in [the proposal](https://github.com/privacycg/CHIPS)\n\t */\n\tpartitioned?: boolean | undefined\n\t/**\n\t * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.\n\t *\n\t * - `true` will set the `SameSite` attribute to `Strict` for strict same\n\t * site enforcement.\n\t * - `false` will not set the `SameSite` attribute.\n\t * - `'lax'` will set the `SameSite` attribute to Lax for lax same site\n\t * enforcement.\n\t * - `'strict'` will set the `SameSite` attribute to Strict for strict same\n\t * site enforcement.\n\t * - `'none'` will set the SameSite attribute to None for an explicit\n\t * cross-site cookie.\n\t *\n\t * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.\n\t *\n\t * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.\n\t */\n\tsameSite?: true | false | 'lax' | 'strict' | 'none' | undefined\n\t/**\n\t * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the\n\t * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.\n\t *\n\t * *Note* be careful when setting this to `true`, as compliant clients will\n\t * not send the cookie back to the server in the future if the browser does\n\t * not have an HTTPS connection.\n\t */\n\tsecure?: boolean | undefined\n\n\t/**\n\t * Secret key for signing cookie\n\t *\n\t * If array is passed, will use Key Rotation.\n\t *\n\t * Key rotation is when an encryption key is retired\n\t * and replaced by generating a new cryptographic key.\n\t */\n\tsecrets?: string | string[]\n}\n\nexport type ElysiaCookie = Prettify<\n\tCookieOptions & {\n\t\tvalue?: unknown\n\t}\n>\n\ntype Updater<T> = T | ((value: T) => T)\n\nexport class Cookie<T> implements ElysiaCookie {\n\tconstructor(\n\t\tprivate name: string,\n\t\tprivate jar: Record<string, ElysiaCookie>,\n\t\tprivate initial: Partial<ElysiaCookie> = {}\n\t) {}\n\n\tget cookie() {\n\t\treturn this.jar[this.name] ?? this.initial\n\t}\n\n\tset cookie(jar: ElysiaCookie) {\n\t\tif (!(this.name in this.jar)) this.jar[this.name] = this.initial\n\n\t\tthis.jar[this.name] = jar\n\t}\n\n\tprotected get setCookie() {\n\t\tif (!(this.name in this.jar)) this.jar[this.name] = this.initial\n\n\t\treturn this.jar[this.name]\n\t}\n\n\tprotected set setCookie(jar: ElysiaCookie) {\n\t\tthis.cookie = jar\n\t}\n\n\tget value(): T {\n\t\treturn this.cookie.value as T\n\t}\n\n\tset value(value: T) {\n\t\tthis.setCookie.value = value\n\t}\n\n\tget expires() {\n\t\treturn this.cookie.expires\n\t}\n\n\tset expires(expires) {\n\t\tthis.setCookie.expires = expires\n\t}\n\n\tget maxAge() {\n\t\treturn this.cookie.maxAge\n\t}\n\n\tset maxAge(maxAge) {\n\t\tthis.setCookie.maxAge = maxAge\n\t}\n\n\tget domain() {\n\t\treturn this.cookie.domain\n\t}\n\n\tset domain(domain) {\n\t\tthis.setCookie.domain = domain\n\t}\n\n\tget path() {\n\t\treturn this.cookie.path\n\t}\n\n\tset path(path) {\n\t\tthis.setCookie.path = path\n\t}\n\n\tget secure() {\n\t\treturn this.cookie.secure\n\t}\n\n\tset secure(secure) {\n\t\tthis.setCookie.secure = secure\n\t}\n\n\tget httpOnly() {\n\t\treturn this.cookie.httpOnly\n\t}\n\n\tset httpOnly(httpOnly) {\n\t\tthis.setCookie.httpOnly = httpOnly\n\t}\n\n\tget sameSite() {\n\t\treturn this.cookie.sameSite\n\t}\n\n\tset sameSite(sameSite) {\n\t\tthis.setCookie.sameSite = sameSite\n\t}\n\n\tget priority() {\n\t\treturn this.cookie.priority\n\t}\n\n\tset priority(priority) {\n\t\tthis.setCookie.priority = priority\n\t}\n\n\tget partitioned() {\n\t\treturn this.cookie.partitioned\n\t}\n\n\tset partitioned(partitioned) {\n\t\tthis.setCookie.partitioned = partitioned\n\t}\n\n\tget secrets() {\n\t\treturn this.cookie.secrets\n\t}\n\n\tset secrets(secrets) {\n\t\tthis.setCookie.secrets = secrets\n\t}\n\n\tupdate(config: Updater<Partial<ElysiaCookie>>) {\n\t\tthis.setCookie = Object.assign(\n\t\t\tthis.cookie,\n\t\t\ttypeof config === 'function' ? config(this.cookie) : config\n\t\t)\n\n\t\treturn this\n\t}\n\n\tset(config: Updater<Partial<ElysiaCookie>>) {\n\t\tthis.setCookie = Object.assign(\n\t\t\t{\n\t\t\t\t...this.initial,\n\t\t\t\tvalue: this.value\n\t\t\t},\n\t\t\ttypeof config === 'function' ? config(this.cookie) : config\n\t\t)\n\n\t\treturn this\n\t}\n\n\tremove() {\n\t\tif (this.value === undefined) return\n\n\t\tthis.set({\n\t\t\texpires: new Date(0),\n\t\t\tmaxAge: 0,\n\t\t\tvalue: ''\n\t\t})\n\n\t\treturn this\n\t}\n\n\ttoString() {\n\t\treturn typeof this.value === 'object'\n\t\t\t? JSON.stringify(this.value)\n\t\t\t: (this.value?.toString() ?? '')\n\t}\n}\n\nexport const createCookieJar = (\n\tset: Context['set'],\n\tstore: Record<string, ElysiaCookie>,\n\tinitial?: Partial<ElysiaCookie>\n): Record<string, Cookie<unknown>> => {\n\tif (!set.cookie) set.cookie = {}\n\n\treturn new Proxy(store, {\n\t\tget(_, key: string) {\n\t\t\tif (key in store)\n\t\t\t\treturn new Cookie(\n\t\t\t\t\tkey,\n\t\t\t\t\tset.cookie as Record<string, ElysiaCookie>,\n\t\t\t\t\tObject.assign({}, initial ?? {}, store[key])\n\t\t\t\t)\n\n\t\t\treturn new Cookie(\n\t\t\t\tkey,\n\t\t\t\tset.cookie as Record<string, ElysiaCookie>,\n\t\t\t\tObject.assign({}, initial)\n\t\t\t)\n\t\t}\n\t}) as Record<string, Cookie<unknown>>\n}\n\nexport const parseCookie = async (\n\tset: Context['set'],\n\tcookieString?: string | null,\n\t{\n\t\tsecrets,\n\t\tsign,\n\t\t...initial\n\t}: CookieOptions & {\n\t\tsign?: true | string | string[]\n\t} = {}\n) => {\n\tif (!cookieString) return createCookieJar(set, {}, initial)\n\n\tconst isStringKey = typeof secrets === 'string'\n\tif (sign && sign !== true && !Array.isArray(sign)) sign = [sign]\n\n\tconst jar: Record<string, ElysiaCookie> = {}\n\n\n\tconst cookies = parse(cookieString)\n\tfor (const [name, v] of Object.entries(cookies)) {\n\t\tif (v === undefined) continue\n\n\t\tlet value = decode(v)\n\n\t\tif (sign === true || sign?.includes(name)) {\n\t\t\tif (!secrets)\n\t\t\t\tthrow new Error('No secret is provided to cookie plugin')\n\n\t\t\tif (isStringKey) {\n\t\t\t\tconst temp = await unsignCookie(value as string, secrets)\n\t\t\t\tif (temp === false) throw new InvalidCookieSignature(name)\n\n\t\t\t\tvalue = temp\n\t\t\t} else {\n\t\t\t\tlet decoded = true\n\t\t\t\tfor (let i = 0; i < secrets.length; i++) {\n\t\t\t\t\tconst temp = await unsignCookie(value as string, secrets[i])\n\n\t\t\t\t\tif (temp !== false) {\n\t\t\t\t\t\tdecoded = true\n\t\t\t\t\t\tvalue = temp\n\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!decoded) throw new InvalidCookieSignature(name)\n\t\t\t}\n\t\t}\n\n\t\tjar[name] = {\n\t\t\tvalue\n\t\t}\n\t}\n\n\treturn createCookieJar(set, jar, initial)\n}\n\nexport const serializeCookie = (cookies: Context['set']['cookie']) => {\n\tif (!cookies || !isNotEmpty(cookies)) return undefined\n\n\tconst set: string[] = []\n\n\tfor (const [key, property] of Object.entries(cookies)) {\n\t\tif (!key || !property) continue\n\n\t\tconst value = property.value\n\t\tif (value === undefined || value === null) continue\n\n\t\tset.push(\n\t\t\tserialize(\n\t\t\t\tkey,\n\t\t\t\ttypeof value === 'object' ? JSON.stringify(value) : value + '',\n\t\t\t\tproperty\n\t\t\t)\n\t\t)\n\t}\n\n\tif (set.length === 0) return undefined\n\tif (set.length === 1) return set[0]\n\n\treturn set\n}\n",
|
|
18
|
-
"import { serializeCookie } from '../cookies'\nimport { hasHeaderShorthand, isNotEmpty, StatusMap } from '../utils'\n\nimport type { Context } from '../context'\nimport { isBun } from '../universal/utils'\n\nexport const handleFile = (\n\tresponse: File | Blob,\n\tset?: Context['set']\n): Response => {\n\tif (!isBun && response instanceof Promise)\n\t\treturn response.then((res) => handleFile(res, set)) as any\n\n\tconst size = response.size\n\tconst immutable =\n\t\tset &&\n\t\t(set.status === 206 ||\n\t\t\tset.status === 304 ||\n\t\t\tset.status === 412 ||\n\t\t\tset.status === 416)\n\n\tconst defaultHeader = immutable\n\t\t? ({\n\t\t\t\t'transfer-encoding': 'chunked'\n\t\t\t} as Record<string, string>)\n\t\t: ({\n\t\t\t\t'accept-ranges': 'bytes',\n\t\t\t\t'content-range': size\n\t\t\t\t\t? `bytes 0-${size - 1}/${size}`\n\t\t\t\t\t: undefined,\n\t\t\t\t'transfer-encoding': 'chunked'\n\t\t\t} as Record<string, string>)\n\n\tif (!set && !size) return new Response(response as Blob)\n\n\tif (!set)\n\t\treturn new Response(response as Blob, {\n\t\t\theaders: defaultHeader\n\t\t})\n\n\tif (set.headers instanceof Headers) {\n\t\tfor (const key of Object.keys(defaultHeader))\n\t\t\tif (key in set.headers) set.headers.append(key, defaultHeader[key])\n\n\t\tif (immutable) {\n\t\t\tset.headers.delete('content-length')\n\t\t\tset.headers.delete('accept-ranges')\n\t\t}\n\n\t\treturn new Response(response as Blob, set as any)\n\t}\n\n\tif (isNotEmpty(set.headers))\n\t\treturn new Response(response as Blob, {\n\t\t\tstatus: set.status as number,\n\t\t\theaders: Object.assign(defaultHeader, set.headers)\n\t\t})\n\n\treturn new Response(response as Blob, {\n\t\tstatus: set.status as number,\n\t\theaders: defaultHeader\n\t})\n}\n\nexport const parseSetCookies = (headers: Headers, setCookie: string[]) => {\n\tif (!headers) return headers\n\n\theaders.delete('set-cookie')\n\n\tfor (let i = 0; i < setCookie.length; i++) {\n\t\tconst index = setCookie[i].indexOf('=')\n\n\t\theaders.append(\n\t\t\t'set-cookie',\n\t\t\t`${setCookie[i].slice(0, index)}=${\n\t\t\t\tsetCookie[i].slice(index + 1) || ''\n\t\t\t}`\n\t\t)\n\t}\n\n\treturn headers\n}\n\nexport const responseToSetHeaders = (\n\tresponse: Response,\n\tset?: Context['set']\n) => {\n\tif (set?.headers) {\n\t\tif (response) {\n\t\t\tif (hasHeaderShorthand)\n\t\t\t\tObject.assign(set.headers, response.headers.toJSON())\n\t\t\telse\n\t\t\t\tfor (const [key, value] of response.headers.entries())\n\t\t\t\t\tif (key in set.headers) set.headers[key] = value\n\t\t}\n\n\t\tif (set.status === 200) set.status = response.status\n\n\t\t// ? `content-encoding` prevent response streaming\n\t\tif (set.headers['content-encoding'])\n\t\t\tdelete set.headers['content-encoding']\n\n\t\treturn set\n\t}\n\n\tif (!response)\n\t\treturn {\n\t\t\theaders: {},\n\t\t\tstatus: set?.status ?? 200\n\t\t}\n\n\tif (hasHeaderShorthand) {\n\t\tset = {\n\t\t\theaders: response.headers.toJSON(),\n\t\t\tstatus: set?.status ?? 200\n\t\t}\n\n\t\t// ? `content-encoding` prevent response streaming\n\t\tif (set.headers['content-encoding'])\n\t\t\tdelete set.headers['content-encoding']\n\n\t\treturn set\n\t}\n\n\tset = {\n\t\theaders: {},\n\t\tstatus: set?.status ?? 200\n\t}\n\n\tfor (const [key, value] of response.headers.entries()) {\n\t\t// ? `content-encoding` prevent response streaming\n\n\t\tif (key === 'content-encoding') continue\n\n\t\tif (key in set.headers) set.headers[key] = value\n\t}\n\n\treturn set\n}\n\ntype CreateHandlerParameter = {\n\tmapResponse(\n\t\tresponse: unknown,\n\t\tset: Context['set'],\n\t\trequest?: Request\n\t): Response\n\tmapCompactResponse(response: unknown, request?: Request): Response\n}\n\nexport const createStreamHandler =\n\t({ mapResponse, mapCompactResponse }: CreateHandlerParameter) =>\n\tasync (\n\t\tgenerator: Generator | AsyncGenerator | ReadableStream,\n\t\tset?: Context['set'],\n\t\trequest?: Request\n\t) => {\n\t\t// Since ReadableStream doesn't have next, init might be undefined\n\t\tlet init = (generator as Generator).next?.() as\n\t\t\t| IteratorResult<unknown>\n\t\t\t| undefined\n\n\t\tif (init instanceof Promise) init = await init\n\n\t\t// Generator or ReadableStream is returned from a generator function\n\t\tif (init?.value instanceof ReadableStream) {\n\t\t\t// @ts-ignore\n\t\t\tgenerator = init.value\n\t\t} else if (init && (typeof init?.done === 'undefined' || init?.done)) {\n\t\t\tif (set) return mapResponse(init.value, set, request)\n\t\t\treturn mapCompactResponse(init.value, request)\n\t\t}\n\n\t\tconst isSSE =\n\t\t\t// @ts-ignore First SSE result is wrapped with sse()\n\t\t\tinit?.value?.sse ??\n\t\t\t// @ts-ignore ReadableStream is wrapped with sse()\n\t\t\tgenerator?.sse ??\n\t\t\t// User explicitly set content-type to SSE\n\t\t\tset?.headers['content-type']?.startsWith('text/event-stream')\n\n\t\tconst format = isSSE\n\t\t\t? (data: string) => `data: ${data}\\n\\n`\n\t\t\t: (data: string) => data\n\n\t\tconst contentType = isSSE\n\t\t\t? 'text/event-stream'\n\t\t\t: init?.value && typeof init?.value === 'object'\n\t\t\t\t? 'application/json'\n\t\t\t\t: 'text/plain'\n\n\t\tif (set?.headers) {\n\t\t\tif (!set.headers['transfer-encoding'])\n\t\t\t\tset.headers['transfer-encoding'] = 'chunked'\n\t\t\tif (!set.headers['content-type'])\n\t\t\t\tset.headers['content-type'] = contentType\n\t\t\tif (!set.headers['cache-control'])\n\t\t\t\tset.headers['cache-control'] = 'no-cache'\n\t\t} else\n\t\t\tset = {\n\t\t\t\tstatus: 200,\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': contentType,\n\t\t\t\t\t'transfer-encoding': 'chunked',\n\t\t\t\t\t'cache-control': 'no-cache',\n\t\t\t\t\tconnection: 'keep-alive'\n\t\t\t\t}\n\t\t\t}\n\n\t\treturn new Response(\n\t\t\tnew ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tlet end = false\n\n\t\t\t\t\trequest?.signal?.addEventListener('abort', () => {\n\t\t\t\t\t\tend = true\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcontroller.close()\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t})\n\n\t\t\t\t\tif (!init || init.value instanceof ReadableStream) {\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tinit.value !== undefined &&\n\t\t\t\t\t\tinit.value !== null\n\t\t\t\t\t) {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tif (init.value.toSSE)\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcontroller.enqueue(init.value.toSSE())\n\t\t\t\t\t\telse if (typeof init.value === 'object')\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\tformat(JSON.stringify(init.value))\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\tformat(init.value.toString())\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\telse controller.enqueue(format(init.value.toString()))\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor await (const chunk of generator) {\n\t\t\t\t\t\t\tif (end) break\n\t\t\t\t\t\t\tif (chunk === undefined || chunk === null) continue\n\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tif (chunk.toSSE)\n\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\tcontroller.enqueue(chunk.toSSE())\n\t\t\t\t\t\t\telse if (typeof chunk === 'object')\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\t\tformat(JSON.stringify(chunk))\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(format(chunk.toString()))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse controller.enqueue(format(chunk.toString()))\n\n\t\t\t\t\t\t\t// Wait for the next event loop\n\t\t\t\t\t\t\t// Otherwise the data will be mixed up\n\t\t\t\t\t\t\tawait new Promise<void>((resolve) =>\n\t\t\t\t\t\t\t\tsetTimeout(() => resolve(), 0)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.warn(error)\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontroller.close()\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// nothing\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t\tset as any\n\t\t)\n\t}\n\nexport async function* streamResponse(response: Response) {\n\tconst body = response.body\n\n\tif (!body) return\n\n\tconst reader = body.getReader()\n\tconst decoder = new TextDecoder()\n\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await reader.read()\n\t\t\tif (done) break\n\n\t\t\tif (typeof value === 'string') yield value\n\t\t\telse yield decoder.decode(value)\n\t\t}\n\t} finally {\n\t\treader.releaseLock()\n\t}\n}\n\nexport const handleSet = (set: Context['set']) => {\n\tif (typeof set.status === 'string') set.status = StatusMap[set.status]\n\n\tif (set.cookie && isNotEmpty(set.cookie)) {\n\t\tconst cookie = serializeCookie(set.cookie)\n\n\t\tif (cookie) set.headers['set-cookie'] = cookie\n\t}\n\n\tif (set.headers['set-cookie'] && Array.isArray(set.headers['set-cookie'])) {\n\t\tset.headers = parseSetCookies(\n\t\t\tnew Headers(set.headers as any) as Headers,\n\t\t\tset.headers['set-cookie']\n\t\t) as any\n\t}\n}\n\nexport const createResponseHandler = (handler: CreateHandlerParameter) => {\n\tconst handleStream = createStreamHandler(handler)\n\n\treturn (response: Response, set: Context['set'], request?: Request) => {\n\t\tlet isCookieSet = false\n\n\t\tif (set.headers instanceof Headers)\n\t\t\tfor (const key of set.headers.keys()) {\n\t\t\t\tif (key === 'set-cookie') {\n\t\t\t\t\tif (isCookieSet) continue\n\n\t\t\t\t\tisCookieSet = true\n\n\t\t\t\t\tfor (const cookie of set.headers.getSetCookie())\n\t\t\t\t\t\tresponse.headers.append('set-cookie', cookie)\n\t\t\t\t} else response.headers.append(key, set.headers?.get(key) ?? '')\n\t\t\t}\n\t\telse\n\t\t\tfor (const key in set.headers)\n\t\t\t\t(response as Response).headers.append(\n\t\t\t\t\tkey,\n\t\t\t\t\tset.headers[key] as any\n\t\t\t\t)\n\n\t\tconst status = set.status ?? 200\n\n\t\tif (\n\t\t\t(response as Response).status !== status &&\n\t\t\tstatus !== 200 &&\n\t\t\t((response.status as number) <= 300 ||\n\t\t\t\t(response.status as number) > 400)\n\t\t)\n\t\t\treturn response.text().then((value) => {\n\t\t\t\tconst newResponse = new Response(value, {\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t\tstatus: set.status as number\n\t\t\t\t})\n\n\n\t\t\t\tif (\n\t\t\t\t\t!(newResponse as Response).headers.has('content-length') &&\n\t\t\t\t\t(newResponse as Response).headers.get(\n\t\t\t\t\t\t'transfer-encoding'\n\t\t\t\t\t) === 'chunked'\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(\n\t\t\t\t\t\tstreamResponse(newResponse as Response),\n\t\t\t\t\t\tresponseToSetHeaders(newResponse as Response, set),\n\t\t\t\t\t\trequest\n\t\t\t\t\t) as any\n\n\t\t\t\treturn newResponse\n\t\t\t})\n\n\t\tif (\n\t\t\t!(response as Response).headers.has('content-length') &&\n\t\t\t(response as Response).headers.get('transfer-encoding') ===\n\t\t\t\t'chunked'\n\t\t)\n\t\t\treturn handleStream(\n\t\t\t\tstreamResponse(response as Response),\n\t\t\t\tresponseToSetHeaders(response as Response, set),\n\t\t\t\trequest\n\t\t\t) as any\n\n\t\treturn response\n\t}\n}\n",
|
|
19
|
-
"/* eslint-disable sonarjs/no-nested-switch */\n/* eslint-disable sonarjs/no-duplicate-string */\nimport {\n\tcreateResponseHandler,\n\tcreateStreamHandler,\n\thandleFile,\n\thandleSet,\n\tresponseToSetHeaders,\n\tstreamResponse\n} from '../utils'\n\nimport { ElysiaFile } from '../../universal/file'\nimport { isNotEmpty } from '../../utils'\nimport { Cookie } from '../../cookies'\nimport { ElysiaCustomStatusResponse } from '../../error'\n\nimport type { Context } from '../../context'\nimport type { AnyLocalHook } from '../../types'\n\nconst handleElysiaFile = (\n\tfile: ElysiaFile,\n\tset: Context['set'] = {\n\t\theaders: {}\n\t}\n) => {\n\tconst path = file.path\n\t// @ts-ignore\n\tconst contentType = mime[path.slice(path.lastIndexOf('.') + 1)]\n\tif (contentType) set.headers['content-type'] = contentType\n\n\tif (\n\t\tfile.stats &&\n\t\tset.status !== 206 &&\n\t\tset.status !== 304 &&\n\t\tset.status !== 412 &&\n\t\tset.status !== 416\n\t)\n\t\treturn file.stats!.then((stat) => {\n\t\t\tconst size = stat.size as number\n\n\t\t\tif (size !== undefined) {\n\t\t\t\tset.headers['content-range'] = `bytes 0-${size - 1}/${size}`\n\t\t\t\tset.headers['content-length'] = size\n\t\t\t}\n\n\t\t\treturn handleFile(file.value as any, set)\n\t\t}) as any\n\n\treturn handleFile(file.value as any, set)\n}\n\nexport const mapResponse = (\n\tresponse: unknown,\n\tset: Context['set'],\n\trequest?: Request\n): Response => {\n\tif (isNotEmpty(set.headers) || set.status !== 200 || set.cookie) {\n\t\thandleSet(set)\n\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\tset.headers['content-type'] = 'text/plain'\n\t\t\t\treturn new Response(response as string, set as any)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleElysiaFile(response as ElysiaFile, set)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as Blob, set as any)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return new Response('', set as any)\n\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'Response':\n\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Promise':\n\t\t\t\treturn (response as Promise<any>).then((x) =>\n\t\t\t\t\tmapResponse(x, set, request)\n\t\t\t\t) as any\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapResponse((response as Function)(), set, request)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response(\n\t\t\t\t\t(response as number | boolean).toString(),\n\t\t\t\t\tset as any\n\t\t\t\t)\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData, set as any)\n\n\t\t\tdefault:\n\t\t\t\t// recheck Response, Promise, Error because some library may extends Response\n\t\t\t\tif (response instanceof Response)\n\t\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any, set as any)\n\t\t}\n\t}\n\n\t// Stream response defers a 'set' API, assume that it may include 'set'\n\tif (\n\t\t// @ts-expect-error\n\t\ttypeof response?.next === 'function' ||\n\t\tresponse instanceof ReadableStream\n\t)\n\t\treturn handleStream(response as any, set, request) as any\n\n\treturn mapCompactResponse(response, request)\n}\n\nexport const mapEarlyResponse = (\n\tresponse: unknown,\n\tset: Context['set'],\n\trequest?: Request\n): Response | undefined => {\n\tif (response === undefined || response === null) return\n\n\tif (isNotEmpty(set.headers) || set.status !== 200 || set.cookie) {\n\t\thandleSet(set)\n\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\tset.headers['content-type'] = 'text/plain'\n\t\t\t\treturn new Response(response as string, set as any)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleElysiaFile(response as ElysiaFile, set)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as File | Blob, set)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return\n\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'Response':\n\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\tcase 'Promise':\n\t\t\t\t// @ts-ignore\n\t\t\t\treturn (response as Promise<unknown>).then((x) =>\n\t\t\t\t\tmapEarlyResponse(x, set)\n\t\t\t\t)\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapEarlyResponse((response as Function)(), set)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response(\n\t\t\t\t\t(response as number | boolean).toString(),\n\t\t\t\t\tset as any\n\t\t\t\t)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData)\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tdefault:\n\t\t\t\tif (response instanceof Response)\n\t\t\t\t\treturn handleResponse(response, set, request)\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapEarlyResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any, set as any)\n\t\t}\n\t} else\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\tset.headers['content-type'] = 'text/plain'\n\t\t\t\treturn new Response(response as string)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleElysiaFile(response as ElysiaFile, set)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as File | Blob, set)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return new Response('')\n\n\t\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\tcase 'Response':\n\t\t\t\treturn response as Response\n\n\t\t\tcase 'Promise':\n\t\t\t\t// @ts-ignore\n\t\t\t\treturn (response as Promise<unknown>).then((x) => {\n\t\t\t\t\tconst r = mapEarlyResponse(x, set)\n\t\t\t\t\tif (r !== undefined) return r\n\t\t\t\t})\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapCompactResponse((response as Function)(), request)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response((response as number | boolean).toString())\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData)\n\n\t\t\tdefault:\n\t\t\t\tif (response instanceof Response) return response\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapEarlyResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any)\n\t\t}\n}\n\nexport const mapCompactResponse = (\n\tresponse: unknown,\n\trequest?: Request\n): Response => {\n\tswitch (response?.constructor?.name) {\n\t\tcase 'String':\n\t\t\treturn new Response(response as string, {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'text/plain'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'Object':\n\t\tcase 'Array':\n\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'ElysiaFile':\n\t\t\treturn handleElysiaFile(response as ElysiaFile)\n\n\t\tcase 'File':\n\t\t\treturn handleFile(response as File)\n\n\t\tcase 'Blob':\n\t\t\treturn handleFile(response as File | Blob)\n\n\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\treturn mapResponse(\n\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t{\n\t\t\t\t\tstatus: (response as ElysiaCustomStatusResponse<200>).code,\n\t\t\t\t\theaders: {}\n\t\t\t\t}\n\t\t\t)\n\n\t\tcase undefined:\n\t\t\tif (!response) return new Response('')\n\n\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'Response':\n\t\t\treturn response as Response\n\n\t\tcase 'Error':\n\t\t\treturn errorToResponse(response as Error)\n\n\t\tcase 'Promise':\n\t\t\treturn (response as any as Promise<unknown>).then((x) =>\n\t\t\t\tmapCompactResponse(x, request)\n\t\t\t) as any\n\n\t\t// ? Maybe response or Blob\n\t\tcase 'Function':\n\t\t\treturn mapCompactResponse((response as Function)(), request)\n\n\t\tcase 'Number':\n\t\tcase 'Boolean':\n\t\t\treturn new Response((response as number | boolean).toString())\n\n\t\tcase 'FormData':\n\t\t\treturn new Response(response as FormData)\n\n\t\tdefault:\n\t\t\tif (response instanceof Response) return response\n\n\t\t\tif (response instanceof Promise)\n\t\t\t\treturn response.then((x) =>\n\t\t\t\t\tmapCompactResponse(x, request)\n\t\t\t\t) as any\n\n\t\t\tif (response instanceof Error)\n\t\t\t\treturn errorToResponse(response as Error)\n\n\t\t\tif (response instanceof ElysiaCustomStatusResponse)\n\t\t\t\treturn mapResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: (response as ElysiaCustomStatusResponse<200>)\n\t\t\t\t\t\t\t.code,\n\t\t\t\t\t\theaders: {}\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\tif (\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\tresponse instanceof ReadableStream\n\t\t\t)\n\t\t\t\treturn handleStream(response as any, undefined, request) as any\n\n\t\t\t// @ts-expect-error\n\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t// @ts-expect-error\n\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t// @ts-expect-error\n\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\treturn mapCompactResponse((response as any).toResponse())\n\n\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t\t\t}\n\t\t\t\t\t}) as any\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new Response(response as any)\n\t}\n}\n\nexport const errorToResponse = (error: Error, set?: Context['set']) =>\n\tnew Response(\n\t\tJSON.stringify({\n\t\t\tname: error?.name,\n\t\t\tmessage: error?.message,\n\t\t\tcause: error?.cause\n\t\t}),\n\t\t{\n\t\t\tstatus:\n\t\t\t\tset?.status !== 200 ? ((set?.status as number) ?? 500) : 500,\n\t\t\theaders: set?.headers as any\n\t\t}\n\t)\n\nexport const createStaticHandler = (\n\thandle: unknown,\n\thooks: Partial<AnyLocalHook>,\n\tsetHeaders: Context['set']['headers'] = {}\n): (() => Response) | undefined => {\n\tif (typeof handle === 'function') return\n\n\tconst response = mapResponse(handle, {\n\t\theaders: setHeaders\n\t})\n\n\tif (\n\t\t!hooks.parse?.length &&\n\t\t!hooks.transform?.length &&\n\t\t!hooks.beforeHandle?.length &&\n\t\t!hooks.afterHandle?.length\n\t)\n\t\treturn () => response.clone() as Response\n}\n\nconst handleResponse = createResponseHandler({\n\tmapResponse,\n\tmapCompactResponse\n})\n\nconst handleStream = createStreamHandler({\n\tmapResponse,\n\tmapCompactResponse\n})\n",
|
|
18
|
+
"import { serializeCookie } from '../cookies'\nimport { hasHeaderShorthand, isNotEmpty, StatusMap } from '../utils'\n\nimport type { Context } from '../context'\nimport { isBun } from '../universal/utils'\n\nexport const handleFile = (\n\tresponse: File | Blob,\n\tset?: Context['set']\n): Response => {\n\tif (!isBun && response instanceof Promise)\n\t\treturn response.then((res) => handleFile(res, set)) as any\n\n\tconst size = response.size\n\tconst immutable =\n\t\tset &&\n\t\t(set.status === 206 ||\n\t\t\tset.status === 304 ||\n\t\t\tset.status === 412 ||\n\t\t\tset.status === 416)\n\n\tconst defaultHeader = immutable\n\t\t? ({\n\t\t\t\t'transfer-encoding': 'chunked'\n\t\t\t} as Record<string, string>)\n\t\t: ({\n\t\t\t\t'accept-ranges': 'bytes',\n\t\t\t\t'content-range': size\n\t\t\t\t\t? `bytes 0-${size - 1}/${size}`\n\t\t\t\t\t: undefined,\n\t\t\t\t'transfer-encoding': 'chunked'\n\t\t\t} as Record<string, string>)\n\n\tif (!set && !size) return new Response(response as Blob)\n\n\tif (!set)\n\t\treturn new Response(response as Blob, {\n\t\t\theaders: defaultHeader\n\t\t})\n\n\tif (set.headers instanceof Headers) {\n\t\tfor (const key of Object.keys(defaultHeader))\n\t\t\tif (key in set.headers) set.headers.append(key, defaultHeader[key])\n\n\t\tif (immutable) {\n\t\t\tset.headers.delete('content-length')\n\t\t\tset.headers.delete('accept-ranges')\n\t\t}\n\n\t\treturn new Response(response as Blob, set as any)\n\t}\n\n\tif (isNotEmpty(set.headers))\n\t\treturn new Response(response as Blob, {\n\t\t\tstatus: set.status as number,\n\t\t\theaders: Object.assign(defaultHeader, set.headers)\n\t\t})\n\n\treturn new Response(response as Blob, {\n\t\tstatus: set.status as number,\n\t\theaders: defaultHeader\n\t})\n}\n\nexport const parseSetCookies = (headers: Headers, setCookie: string[]) => {\n\tif (!headers) return headers\n\n\theaders.delete('set-cookie')\n\n\tfor (let i = 0; i < setCookie.length; i++) {\n\t\tconst index = setCookie[i].indexOf('=')\n\n\t\theaders.append(\n\t\t\t'set-cookie',\n\t\t\t`${setCookie[i].slice(0, index)}=${\n\t\t\t\tsetCookie[i].slice(index + 1) || ''\n\t\t\t}`\n\t\t)\n\t}\n\n\treturn headers\n}\n\nexport const responseToSetHeaders = (\n\tresponse: Response,\n\tset?: Context['set']\n) => {\n\tif (set?.headers) {\n\t\tif (response) {\n\t\t\tif (hasHeaderShorthand)\n\t\t\t\tObject.assign(set.headers, response.headers.toJSON())\n\t\t\telse\n\t\t\t\tfor (const [key, value] of response.headers.entries())\n\t\t\t\t\tif (key in set.headers) set.headers[key] = value\n\t\t}\n\n\t\tif (set.status === 200) set.status = response.status\n\n\t\t// ? `content-encoding` prevent response streaming\n\t\tif (set.headers['content-encoding'])\n\t\t\tdelete set.headers['content-encoding']\n\n\t\treturn set\n\t}\n\n\tif (!response)\n\t\treturn {\n\t\t\theaders: {},\n\t\t\tstatus: set?.status ?? 200\n\t\t}\n\n\tif (hasHeaderShorthand) {\n\t\tset = {\n\t\t\theaders: response.headers.toJSON(),\n\t\t\tstatus: set?.status ?? 200\n\t\t}\n\n\t\t// ? `content-encoding` prevent response streaming\n\t\tif (set.headers['content-encoding'])\n\t\t\tdelete set.headers['content-encoding']\n\n\t\treturn set\n\t}\n\n\tset = {\n\t\theaders: {},\n\t\tstatus: set?.status ?? 200\n\t}\n\n\tfor (const [key, value] of response.headers.entries()) {\n\t\t// ? `content-encoding` prevent response streaming\n\n\t\tif (key === 'content-encoding') continue\n\n\t\tif (key in set.headers) set.headers[key] = value\n\t}\n\n\treturn set\n}\n\ntype CreateHandlerParameter = {\n\tmapResponse(\n\t\tresponse: unknown,\n\t\tset: Context['set'],\n\t\trequest?: Request\n\t): Response\n\tmapCompactResponse(response: unknown, request?: Request): Response\n}\n\nexport const createStreamHandler =\n\t({ mapResponse, mapCompactResponse }: CreateHandlerParameter) =>\n\tasync (\n\t\tgenerator: Generator | AsyncGenerator | ReadableStream,\n\t\tset?: Context['set'],\n\t\trequest?: Request\n\t) => {\n\t\t// Since ReadableStream doesn't have next, init might be undefined\n\t\tlet init = (generator as Generator).next?.() as\n\t\t\t| IteratorResult<unknown>\n\t\t\t| undefined\n\n\t\tif (init instanceof Promise) init = await init\n\n\t\t// Generator or ReadableStream is returned from a generator function\n\t\tif (init?.value instanceof ReadableStream) {\n\t\t\t// @ts-ignore\n\t\t\tgenerator = init.value\n\t\t} else if (init && (typeof init?.done === 'undefined' || init?.done)) {\n\t\t\tif (set) return mapResponse(init.value, set, request)\n\t\t\treturn mapCompactResponse(init.value, request)\n\t\t}\n\n\t\tconst isSSE =\n\t\t\t// @ts-ignore First SSE result is wrapped with sse()\n\t\t\tinit?.value?.sse ??\n\t\t\t// @ts-ignore ReadableStream is wrapped with sse()\n\t\t\tgenerator?.sse ??\n\t\t\t// User explicitly set content-type to SSE\n\t\t\tset?.headers['content-type']?.startsWith('text/event-stream')\n\n\t\tconst format = isSSE\n\t\t\t? (data: string) => `data: ${data}\\n\\n`\n\t\t\t: (data: string) => data\n\n\t\tconst contentType = isSSE\n\t\t\t? 'text/event-stream'\n\t\t\t: init?.value && typeof init?.value === 'object'\n\t\t\t\t? 'application/json'\n\t\t\t\t: 'text/plain'\n\n\t\tif (set?.headers) {\n\t\t\tif (!set.headers['transfer-encoding'])\n\t\t\t\tset.headers['transfer-encoding'] = 'chunked'\n\t\t\tif (!set.headers['content-type'])\n\t\t\t\tset.headers['content-type'] = contentType\n\t\t\tif (!set.headers['cache-control'])\n\t\t\t\tset.headers['cache-control'] = 'no-cache'\n\t\t} else\n\t\t\tset = {\n\t\t\t\tstatus: 200,\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': contentType,\n\t\t\t\t\t'transfer-encoding': 'chunked',\n\t\t\t\t\t'cache-control': 'no-cache',\n\t\t\t\t\tconnection: 'keep-alive'\n\t\t\t\t}\n\t\t\t}\n\n\t\treturn new Response(\n\t\t\tnew ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tlet end = false\n\n\t\t\t\t\trequest?.signal?.addEventListener('abort', () => {\n\t\t\t\t\t\tend = true\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcontroller.close()\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t})\n\n\t\t\t\t\tif (!init || init.value instanceof ReadableStream) {\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tinit.value !== undefined &&\n\t\t\t\t\t\tinit.value !== null\n\t\t\t\t\t) {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tif (init.value.toSSE)\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcontroller.enqueue(init.value.toSSE())\n\t\t\t\t\t\telse if (typeof init.value === 'object')\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\tformat(JSON.stringify(init.value))\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\tformat(init.value.toString())\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\telse controller.enqueue(format(init.value.toString()))\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor await (const chunk of generator) {\n\t\t\t\t\t\t\tif (end) break\n\t\t\t\t\t\t\tif (chunk === undefined || chunk === null) continue\n\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tif (chunk.toSSE) {\n\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\tcontroller.enqueue(chunk.toSSE())\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (typeof chunk === 'object')\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\t\t\tformat(JSON.stringify(chunk))\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\t\t\t\tformat(chunk.toString())\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(format(chunk.toString()))\n\n\t\t\t\t\t\t\t\tif (!isSSE)\n\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t * Wait for the next event loop\n\t\t\t\t\t\t\t\t\t * otherwise the data will be mixed up\n\t\t\t\t\t\t\t\t\t *\n\t\t\t\t\t\t\t\t\t * @see https://github.com/elysiajs/elysia/issues/741\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\tawait new Promise<void>((resolve) =>\n\t\t\t\t\t\t\t\t\t\tsetTimeout(() => resolve(), 0)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.warn(error)\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontroller.close()\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// nothing\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t\tset as any\n\t\t)\n\t}\n\nexport async function* streamResponse(response: Response) {\n\tconst body = response.body\n\n\tif (!body) return\n\n\tconst reader = body.getReader()\n\tconst decoder = new TextDecoder()\n\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await reader.read()\n\t\t\tif (done) break\n\n\t\t\tif (typeof value === 'string') yield value\n\t\t\telse yield decoder.decode(value)\n\t\t}\n\t} finally {\n\t\treader.releaseLock()\n\t}\n}\n\nexport const handleSet = (set: Context['set']) => {\n\tif (typeof set.status === 'string') set.status = StatusMap[set.status]\n\n\tif (set.cookie && isNotEmpty(set.cookie)) {\n\t\tconst cookie = serializeCookie(set.cookie)\n\n\t\tif (cookie) set.headers['set-cookie'] = cookie\n\t}\n\n\tif (set.headers['set-cookie'] && Array.isArray(set.headers['set-cookie'])) {\n\t\tset.headers = parseSetCookies(\n\t\t\tnew Headers(set.headers as any) as Headers,\n\t\t\tset.headers['set-cookie']\n\t\t) as any\n\t}\n}\n\nexport const createResponseHandler = (handler: CreateHandlerParameter) => {\n\tconst handleStream = createStreamHandler(handler)\n\n\treturn (response: Response, set: Context['set'], request?: Request) => {\n\t\tlet isCookieSet = false\n\n\t\tif (set.headers instanceof Headers)\n\t\t\tfor (const key of set.headers.keys()) {\n\t\t\t\tif (key === 'set-cookie') {\n\t\t\t\t\tif (isCookieSet) continue\n\n\t\t\t\t\tisCookieSet = true\n\n\t\t\t\t\tfor (const cookie of set.headers.getSetCookie())\n\t\t\t\t\t\tresponse.headers.append('set-cookie', cookie)\n\t\t\t\t} else response.headers.append(key, set.headers?.get(key) ?? '')\n\t\t\t}\n\t\telse\n\t\t\tfor (const key in set.headers)\n\t\t\t\t(response as Response).headers.append(\n\t\t\t\t\tkey,\n\t\t\t\t\tset.headers[key] as any\n\t\t\t\t)\n\n\t\tconst status = set.status ?? 200\n\n\t\tif (\n\t\t\t(response as Response).status !== status &&\n\t\t\tstatus !== 200 &&\n\t\t\t((response.status as number) <= 300 ||\n\t\t\t\t(response.status as number) > 400)\n\t\t)\n\t\t\treturn response.text().then((value) => {\n\t\t\t\tconst newResponse = new Response(value, {\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t\tstatus: set.status as number\n\t\t\t\t})\n\n\t\t\t\tif (\n\t\t\t\t\t!(newResponse as Response).headers.has('content-length') &&\n\t\t\t\t\t(newResponse as Response).headers.get(\n\t\t\t\t\t\t'transfer-encoding'\n\t\t\t\t\t) === 'chunked'\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(\n\t\t\t\t\t\tstreamResponse(newResponse as Response),\n\t\t\t\t\t\tresponseToSetHeaders(newResponse as Response, set),\n\t\t\t\t\t\trequest\n\t\t\t\t\t) as any\n\n\t\t\t\treturn newResponse\n\t\t\t})\n\n\t\tif (\n\t\t\t!(response as Response).headers.has('content-length') &&\n\t\t\t(response as Response).headers.get('transfer-encoding') ===\n\t\t\t\t'chunked'\n\t\t)\n\t\t\treturn handleStream(\n\t\t\t\tstreamResponse(response as Response),\n\t\t\t\tresponseToSetHeaders(response as Response, set),\n\t\t\t\trequest\n\t\t\t) as any\n\n\t\treturn response\n\t}\n}\n",
|
|
19
|
+
"/* eslint-disable sonarjs/no-nested-switch */\n/* eslint-disable sonarjs/no-duplicate-string */\nimport {\n\tcreateResponseHandler,\n\tcreateStreamHandler,\n\thandleFile,\n\thandleSet\n} from '../utils'\n\nimport { ElysiaFile, mime } from '../../universal/file'\nimport { isNotEmpty } from '../../utils'\nimport { Cookie } from '../../cookies'\nimport { ElysiaCustomStatusResponse } from '../../error'\n\nimport type { Context } from '../../context'\nimport type { AnyLocalHook } from '../../types'\n\nconst handleElysiaFile = (\n\tfile: ElysiaFile,\n\tset: Context['set'] = {\n\t\theaders: {}\n\t}\n) => {\n\tconst path = file.path\n\tconst contentType =\n\t\tmime[path.slice(path.lastIndexOf('.') + 1) as any as keyof typeof mime]\n\n\tif (contentType) set.headers['content-type'] = contentType\n\n\tif (\n\t\tfile.stats &&\n\t\tset.status !== 206 &&\n\t\tset.status !== 304 &&\n\t\tset.status !== 412 &&\n\t\tset.status !== 416\n\t)\n\t\treturn file.stats!.then((stat) => {\n\t\t\tconst size = stat.size as number\n\n\t\t\tif (size !== undefined) {\n\t\t\t\tset.headers['content-range'] = `bytes 0-${size - 1}/${size}`\n\t\t\t\tset.headers['content-length'] = size\n\t\t\t}\n\n\t\t\treturn handleFile(file.value as any, set)\n\t\t}) as any\n\n\treturn handleFile(file.value as any, set)\n}\n\nexport const mapResponse = (\n\tresponse: unknown,\n\tset: Context['set'],\n\trequest?: Request\n): Response => {\n\tif (isNotEmpty(set.headers) || set.status !== 200 || set.cookie) {\n\t\thandleSet(set)\n\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\tset.headers['content-type'] = 'text/plain'\n\t\t\t\treturn new Response(response as string, set as any)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleElysiaFile(response as ElysiaFile, set)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as Blob, set as any)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return new Response('', set as any)\n\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'Response':\n\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Promise':\n\t\t\t\treturn (response as Promise<any>).then((x) =>\n\t\t\t\t\tmapResponse(x, set, request)\n\t\t\t\t) as any\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapResponse((response as Function)(), set, request)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response(\n\t\t\t\t\t(response as number | boolean).toString(),\n\t\t\t\t\tset as any\n\t\t\t\t)\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData, set as any)\n\n\t\t\tdefault:\n\t\t\t\t// recheck Response, Promise, Error because some library may extends Response\n\t\t\t\tif (response instanceof Response)\n\t\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any, set as any)\n\t\t}\n\t}\n\n\t// Stream response defers a 'set' API, assume that it may include 'set'\n\tif (\n\t\t// @ts-expect-error\n\t\ttypeof response?.next === 'function' ||\n\t\tresponse instanceof ReadableStream\n\t)\n\t\treturn handleStream(response as any, set, request) as any\n\n\treturn mapCompactResponse(response, request)\n}\n\nexport const mapEarlyResponse = (\n\tresponse: unknown,\n\tset: Context['set'],\n\trequest?: Request\n): Response | undefined => {\n\tif (response === undefined || response === null) return\n\n\tif (isNotEmpty(set.headers) || set.status !== 200 || set.cookie) {\n\t\thandleSet(set)\n\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\tset.headers['content-type'] = 'text/plain'\n\t\t\t\treturn new Response(response as string, set as any)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleElysiaFile(response as ElysiaFile, set)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as File | Blob, set)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return\n\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'Response':\n\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\tcase 'Promise':\n\t\t\t\t// @ts-ignore\n\t\t\t\treturn (response as Promise<unknown>).then((x) =>\n\t\t\t\t\tmapEarlyResponse(x, set)\n\t\t\t\t)\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapEarlyResponse((response as Function)(), set)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response(\n\t\t\t\t\t(response as number | boolean).toString(),\n\t\t\t\t\tset as any\n\t\t\t\t)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData)\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tdefault:\n\t\t\t\tif (response instanceof Response)\n\t\t\t\t\treturn handleResponse(response, set, request)\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapEarlyResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any, set as any)\n\t\t}\n\t} else\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\tset.headers['content-type'] = 'text/plain'\n\t\t\t\treturn new Response(response as string)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleElysiaFile(response as ElysiaFile, set)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as File | Blob, set)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return new Response('')\n\n\t\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\tcase 'Response':\n\t\t\t\treturn response as Response\n\n\t\t\tcase 'Promise':\n\t\t\t\t// @ts-ignore\n\t\t\t\treturn (response as Promise<unknown>).then((x) => {\n\t\t\t\t\tconst r = mapEarlyResponse(x, set)\n\t\t\t\t\tif (r !== undefined) return r\n\t\t\t\t})\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapCompactResponse((response as Function)(), request)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response((response as number | boolean).toString())\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData)\n\n\t\t\tdefault:\n\t\t\t\tif (response instanceof Response) return response\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapEarlyResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any)\n\t\t}\n}\n\nexport const mapCompactResponse = (\n\tresponse: unknown,\n\trequest?: Request\n): Response => {\n\tswitch (response?.constructor?.name) {\n\t\tcase 'String':\n\t\t\treturn new Response(response as string, {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'text/plain'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'Object':\n\t\tcase 'Array':\n\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'ElysiaFile':\n\t\t\treturn handleElysiaFile(response as ElysiaFile)\n\n\t\tcase 'File':\n\t\t\treturn handleFile(response as File)\n\n\t\tcase 'Blob':\n\t\t\treturn handleFile(response as File | Blob)\n\n\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\treturn mapResponse(\n\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t{\n\t\t\t\t\tstatus: (response as ElysiaCustomStatusResponse<200>).code,\n\t\t\t\t\theaders: {}\n\t\t\t\t}\n\t\t\t)\n\n\t\tcase undefined:\n\t\t\tif (!response) return new Response('')\n\n\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'Response':\n\t\t\treturn response as Response\n\n\t\tcase 'Error':\n\t\t\treturn errorToResponse(response as Error)\n\n\t\tcase 'Promise':\n\t\t\treturn (response as any as Promise<unknown>).then((x) =>\n\t\t\t\tmapCompactResponse(x, request)\n\t\t\t) as any\n\n\t\t// ? Maybe response or Blob\n\t\tcase 'Function':\n\t\t\treturn mapCompactResponse((response as Function)(), request)\n\n\t\tcase 'Number':\n\t\tcase 'Boolean':\n\t\t\treturn new Response((response as number | boolean).toString())\n\n\t\tcase 'FormData':\n\t\t\treturn new Response(response as FormData)\n\n\t\tdefault:\n\t\t\tif (response instanceof Response) return response\n\n\t\t\tif (response instanceof Promise)\n\t\t\t\treturn response.then((x) =>\n\t\t\t\t\tmapCompactResponse(x, request)\n\t\t\t\t) as any\n\n\t\t\tif (response instanceof Error)\n\t\t\t\treturn errorToResponse(response as Error)\n\n\t\t\tif (response instanceof ElysiaCustomStatusResponse)\n\t\t\t\treturn mapResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: (response as ElysiaCustomStatusResponse<200>)\n\t\t\t\t\t\t\t.code,\n\t\t\t\t\t\theaders: {}\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\tif (\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\tresponse instanceof ReadableStream\n\t\t\t)\n\t\t\t\treturn handleStream(response as any, undefined, request) as any\n\n\t\t\t// @ts-expect-error\n\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t// @ts-expect-error\n\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t// @ts-expect-error\n\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\treturn mapCompactResponse((response as any).toResponse())\n\n\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t\t\t}\n\t\t\t\t\t}) as any\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new Response(response as any)\n\t}\n}\n\nexport const errorToResponse = (error: Error, set?: Context['set']) =>\n\tnew Response(\n\t\tJSON.stringify({\n\t\t\tname: error?.name,\n\t\t\tmessage: error?.message,\n\t\t\tcause: error?.cause\n\t\t}),\n\t\t{\n\t\t\tstatus:\n\t\t\t\tset?.status !== 200 ? ((set?.status as number) ?? 500) : 500,\n\t\t\theaders: set?.headers as any\n\t\t}\n\t)\n\nexport const createStaticHandler = (\n\thandle: unknown,\n\thooks: Partial<AnyLocalHook>,\n\tsetHeaders: Context['set']['headers'] = {}\n): (() => Response) | undefined => {\n\tif (typeof handle === 'function') return\n\n\tconst response = mapResponse(handle, {\n\t\theaders: setHeaders\n\t})\n\n\tif (\n\t\t!hooks.parse?.length &&\n\t\t!hooks.transform?.length &&\n\t\t!hooks.beforeHandle?.length &&\n\t\t!hooks.afterHandle?.length\n\t)\n\t\treturn () => response.clone() as Response\n}\n\nconst handleResponse = createResponseHandler({\n\tmapResponse,\n\tmapCompactResponse\n})\n\nconst handleStream = createStreamHandler({\n\tmapResponse,\n\tmapCompactResponse\n})\n",
|
|
20
20
|
"import {\n\tmapResponse,\n\tmapEarlyResponse,\n\tmapCompactResponse,\n\tcreateStaticHandler\n} from './handler'\n\nimport type { ElysiaAdapter } from '../types'\n\nexport const WebStandardAdapter: ElysiaAdapter = {\n\tname: 'web-standard',\n\tisWebStandard: true,\n\thandler: {\n\t\tmapResponse,\n\t\tmapEarlyResponse,\n\t\tmapCompactResponse,\n\t\tcreateStaticHandler\n\t},\n\tcomposeHandler: {\n\t\tmapResponseContext: 'c.request',\n\t\tpreferWebstandardHeaders: true,\n\t\t// @ts-ignore Bun specific\n\t\theaders:\n\t\t\t'c.headers={}\\n' +\n\t\t\t'for(const [k,v] of c.request.headers.entries())' +\n\t\t\t'c.headers[k]=v\\n',\n\t\tparser: {\n\t\t\tjson(isOptional) {\n\t\t\t\tif (isOptional)\n\t\t\t\t\treturn `try{c.body=await c.request.json()}catch{}\\n`\n\t\t\t\treturn `c.body=await c.request.json()\\n`\n\t\t\t},\n\t\t\ttext() {\n\t\t\t\treturn `c.body=await c.request.text()\\n`\n\t\t\t},\n\t\t\turlencoded() {\n\t\t\t\treturn `c.body=parseQuery(await c.request.text())\\n`\n\t\t\t},\n\t\t\tarrayBuffer() {\n\t\t\t\treturn `c.body=await c.request.arrayBuffer()\\n`\n\t\t\t},\n\t\t\tformData(isOptional) {\n\t\t\t\tlet fnLiteral = '\\nc.body={}\\n'\n\n\t\t\t\tif (isOptional)\n\t\t\t\t\tfnLiteral += `let form;try{form=await c.request.formData()}catch{}`\n\t\t\t\telse fnLiteral += `const form=await c.request.formData()\\n`\n\n\t\t\t\treturn (\n\t\t\t\t\tfnLiteral +\n\t\t\t\t\t`for(const key of form.keys()){` +\n\t\t\t\t\t`if(c.body[key]) continue\\n` +\n\t\t\t\t\t`const value=form.getAll(key)\\n` +\n\t\t\t\t\t`if(value.length===1)` +\n\t\t\t\t\t`c.body[key]=value[0]\\n` +\n\t\t\t\t\t`else c.body[key]=value` +\n\t\t\t\t\t`}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t},\n\tasync stop(app, closeActiveConnections) {\n\t\tif (!app.server)\n\t\t\tthrow new Error(\n\t\t\t\t\"Elysia isn't running. Call `app.listen` to start the server.\"\n\t\t\t)\n\n\t\tif (app.server) {\n\t\t\tapp.server.stop(closeActiveConnections)\n\t\t\tapp.server = null\n\n\t\t\tif (app.event.stop?.length)\n\t\t\t\tfor (let i = 0; i < app.event.stop.length; i++)\n\t\t\t\t\tapp.event.stop[i].fn(app)\n\t\t}\n\t},\n\tcomposeGeneralHandler: {\n\t\tparameters: 'r',\n\t\tcreateContext(app) {\n\t\t\tlet decoratorsLiteral = ''\n\t\t\tlet fnLiteral = ''\n\n\t\t\t// @ts-expect-error private\n\t\t\tconst defaultHeaders = app.setHeaders\n\n\t\t\tfor (const key of Object.keys(app.decorator))\n\t\t\t\tdecoratorsLiteral += `,'${key}':decorator['${key}']`\n\n\t\t\tconst standardHostname =\n\t\t\t\tapp.config.handler?.standardHostname ?? true\n\t\t\tconst hasTrace = !!app.event.trace?.length\n\n\t\t\tfnLiteral +=\n\t\t\t\t`const u=r.url,` +\n\t\t\t\t`s=u.indexOf('/',${standardHostname ? 11 : 7}),` +\n\t\t\t\t`qi=u.indexOf('?',s+1)\\n` +\n\t\t\t\t`let p\\n` +\n\t\t\t\t`if(qi===-1)p=u.substring(s)\\n` +\n\t\t\t\t`else p=u.substring(s, qi)\\n`\n\n\t\t\tif (hasTrace) fnLiteral += `const id=randomId()\\n`\n\n\t\t\tfnLiteral +=\n\t\t\t\t`const c={request:r,` +\n\t\t\t\t`store,` +\n\t\t\t\t`qi,` +\n\t\t\t\t`path:p,` +\n\t\t\t\t`url:u,` +\n\t\t\t\t`redirect,` +\n\t\t\t\t`error:status,` +\n\t\t\t\t`status,` +\n\t\t\t\t`set:{headers:`\n\n\t\t\tfnLiteral += Object.keys(defaultHeaders ?? {}).length\n\t\t\t\t? 'Object.assign({},app.setHeaders)'\n\t\t\t\t: 'Object.create(null)'\n\n\t\t\tfnLiteral += `,status:200}`\n\n\t\t\t// @ts-expect-error private\n\t\t\tif (app.inference.server)\n\t\t\t\tfnLiteral += `,get server(){return app.getServer()}`\n\t\t\tif (hasTrace) fnLiteral += ',[ELYSIA_REQUEST_ID]:id'\n\t\t\tfnLiteral += decoratorsLiteral\n\t\t\tfnLiteral += `}\\n`\n\n\t\t\treturn fnLiteral\n\t\t},\n\t\terror404(hasEventHook, hasErrorHook, afterHandle = '') {\n\t\t\tlet findDynamicRoute =\n\t\t\t\t`if(route===null){` +\n\t\t\t\tafterHandle +\n\t\t\t\t'\\nreturn '\n\n\t\t\tif (hasErrorHook)\n\t\t\t\tfindDynamicRoute += `app.handleError(c,notFound,false,${this.parameters})`\n\t\t\telse\n\t\t\t\tfindDynamicRoute += hasEventHook\n\t\t\t\t\t? `new Response(error404Message,{` +\n\t\t\t\t\t\t`status:c.set.status===200?404:c.set.status,` +\n\t\t\t\t\t\t`headers:c.set.headers` +\n\t\t\t\t\t\t`})`\n\t\t\t\t\t: `error404.clone()`\n\n\t\t\tfindDynamicRoute += '}'\n\n\t\t\treturn {\n\t\t\t\tdeclare: hasErrorHook\n\t\t\t\t\t? ''\n\t\t\t\t\t: `const error404Message=notFound.message.toString()\\n` +\n\t\t\t\t\t\t`const error404=new Response(error404Message,{status:404})\\n`,\n\t\t\t\tcode: findDynamicRoute\n\t\t\t}\n\t\t}\n\t},\n\tcomposeError: {\n\t\tmapResponseContext: '',\n\t\tvalidationError:\n\t\t\t`return new Response(` +\n\t\t\t`error.message,` +\n\t\t\t`{` +\n\t\t\t`headers:Object.assign(` +\n\t\t\t`{'content-type':'application/json'},` +\n\t\t\t`set.headers` +\n\t\t\t`),` +\n\t\t\t`status:set.status` +\n\t\t\t`}` +\n\t\t\t`)`,\n\t\tunknownError:\n\t\t\t`return new Response(` +\n\t\t\t`error.message,` +\n\t\t\t`{headers:set.headers,status:error.status??set.status??500}` +\n\t\t\t`)`\n\t},\n\tlisten() {\n\t\treturn () => {\n\t\t\tthrow new Error(\n\t\t\t\t'WebStandard does not support listen, you might want to export default Elysia.fetch instead'\n\t\t\t)\n\t\t}\n\t}\n}\n",
|
|
21
21
|
"// Similar to adapter/web-standard/handler but\n// string case is omitted header out\n// (this has a significant performance difference on Bun)\n\n/* eslint-disable sonarjs/no-nested-switch */\n/* eslint-disable sonarjs/no-duplicate-string */\nimport {\n\tcreateResponseHandler,\n\tcreateStreamHandler,\n\thandleFile,\n\thandleSet,\n\tresponseToSetHeaders,\n\tstreamResponse\n} from '../utils'\n\nimport { ElysiaFile } from '../../universal/file'\nimport { isNotEmpty } from '../../utils'\nimport { Cookie } from '../../cookies'\nimport { ElysiaCustomStatusResponse } from '../../error'\n\nimport type { Context } from '../../context'\nimport type { AnyLocalHook } from '../../types'\n\nexport const mapResponse = (\n\tresponse: unknown,\n\tset: Context['set'],\n\trequest?: Request\n): Response => {\n\tif (isNotEmpty(set.headers) || set.status !== 200 || set.cookie) {\n\t\thandleSet(set)\n\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\treturn new Response(response as string, set as any)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleFile((response as ElysiaFile).value as File)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as Blob, set as any)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return new Response('', set as any)\n\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'Response':\n\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Promise':\n\t\t\t\treturn (response as Promise<any>).then((x) =>\n\t\t\t\t\tmapResponse(x, set, request)\n\t\t\t\t) as any\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapResponse((response as Function)(), set, request)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response(\n\t\t\t\t\t(response as number | boolean).toString(),\n\t\t\t\t\tset as any\n\t\t\t\t)\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData, set as any)\n\n\t\t\tdefault:\n\t\t\t\t// recheck Response, Promise, Error because some library may extends Response\n\t\t\t\tif (response instanceof Response)\n\t\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any, set as any)\n\t\t}\n\t}\n\n\t// Stream response defers a 'set' API, assume that it may include 'set'\n\tif (\n\t\t// @ts-expect-error\n\t\ttypeof response?.next === 'function' ||\n\t\tresponse instanceof ReadableStream\n\t)\n\t\treturn handleStream(response as any, set, request) as any\n\n\treturn mapCompactResponse(response, request)\n}\n\nexport const mapEarlyResponse = (\n\tresponse: unknown,\n\tset: Context['set'],\n\trequest?: Request\n): Response | undefined => {\n\tif (response === undefined || response === null) return\n\n\tif (isNotEmpty(set.headers) || set.status !== 200 || set.cookie) {\n\t\thandleSet(set)\n\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\treturn new Response(response as string, set as any)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleFile((response as ElysiaFile).value as File)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as File | Blob, set)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return\n\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'Response':\n\t\t\t\treturn handleResponse(response as Response, set, request)\n\n\t\t\tcase 'Promise':\n\t\t\t\t// @ts-ignore\n\t\t\t\treturn (response as Promise<unknown>).then((x) =>\n\t\t\t\t\tmapEarlyResponse(x, set)\n\t\t\t\t)\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapEarlyResponse((response as Function)(), set)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response(\n\t\t\t\t\t(response as number | boolean).toString(),\n\t\t\t\t\tset as any\n\t\t\t\t)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData)\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tdefault:\n\t\t\t\tif (response instanceof Response)\n\t\t\t\t\treturn handleResponse(response, set, request)\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapEarlyResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any, set as any)\n\t\t}\n\t} else\n\t\tswitch (response?.constructor?.name) {\n\t\t\tcase 'String':\n\t\t\t\treturn new Response(response as string)\n\n\t\t\tcase 'Array':\n\t\t\tcase 'Object':\n\t\t\t\tset.headers['content-type'] = 'application/json'\n\t\t\t\treturn new Response(JSON.stringify(response), set as any)\n\n\t\t\tcase 'ElysiaFile':\n\t\t\t\treturn handleFile((response as ElysiaFile).value as File)\n\n\t\t\tcase 'File':\n\t\t\t\treturn handleFile(response as File, set as any)\n\n\t\t\tcase 'Blob':\n\t\t\t\treturn handleFile(response as File | Blob, set)\n\n\t\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\t\tset.status = (response as ElysiaCustomStatusResponse<200>).code\n\n\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\tset,\n\t\t\t\t\trequest\n\t\t\t\t)\n\n\t\t\tcase undefined:\n\t\t\t\tif (!response) return new Response('')\n\n\t\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\tcase 'Response':\n\t\t\t\treturn response as Response\n\n\t\t\tcase 'Promise':\n\t\t\t\t// @ts-ignore\n\t\t\t\treturn (response as Promise<unknown>).then((x) => {\n\t\t\t\t\tconst r = mapEarlyResponse(x, set)\n\t\t\t\t\tif (r !== undefined) return r\n\t\t\t\t})\n\n\t\t\tcase 'Error':\n\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\tcase 'Function':\n\t\t\t\treturn mapCompactResponse((response as Function)(), request)\n\n\t\t\tcase 'Number':\n\t\t\tcase 'Boolean':\n\t\t\t\treturn new Response((response as number | boolean).toString())\n\n\t\t\tcase 'Cookie':\n\t\t\t\tif (response instanceof Cookie)\n\t\t\t\t\treturn new Response(response.value, set as any)\n\n\t\t\t\treturn new Response(response?.toString(), set as any)\n\n\t\t\tcase 'FormData':\n\t\t\t\treturn new Response(response as FormData)\n\n\t\t\tdefault:\n\t\t\t\tif (response instanceof Response) return response\n\n\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\tif (response instanceof Error)\n\t\t\t\t\treturn errorToResponse(response as Error, set)\n\n\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\tset.status = (\n\t\t\t\t\t\tresponse as ElysiaCustomStatusResponse<200>\n\t\t\t\t\t).code\n\n\t\t\t\t\treturn mapEarlyResponse(\n\t\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t\tset,\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\t\tresponse instanceof ReadableStream\n\t\t\t\t)\n\t\t\t\t\treturn handleStream(response as any, set, request) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treturn response.then((x) => mapEarlyResponse(x, set)) as any\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\t\treturn mapEarlyResponse((response as any).toResponse(), set)\n\n\t\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\t\tif (!set.headers['Content-Type'])\n\t\t\t\t\t\t\tset.headers['Content-Type'] = 'application/json'\n\n\t\t\t\t\t\treturn new Response(\n\t\t\t\t\t\t\tJSON.stringify(response),\n\t\t\t\t\t\t\tset as any\n\t\t\t\t\t\t) as any\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Response(response as any)\n\t\t}\n}\n\nexport const mapCompactResponse = (\n\tresponse: unknown,\n\trequest?: Request\n): Response => {\n\tswitch (response?.constructor?.name) {\n\t\tcase 'String':\n\t\t\treturn new Response(response as string)\n\n\t\tcase 'Object':\n\t\tcase 'Array':\n\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'ElysiaFile':\n\t\t\treturn handleFile((response as ElysiaFile).value as File)\n\n\t\tcase 'File':\n\t\t\treturn handleFile(response as File)\n\n\t\tcase 'Blob':\n\t\t\treturn handleFile(response as File | Blob)\n\n\t\tcase 'ElysiaCustomStatusResponse':\n\t\t\treturn mapResponse(\n\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t{\n\t\t\t\t\tstatus: (response as ElysiaCustomStatusResponse<200>).code,\n\t\t\t\t\theaders: {}\n\t\t\t\t}\n\t\t\t)\n\n\t\tcase undefined:\n\t\t\tif (!response) return new Response('')\n\n\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\n\t\tcase 'Response':\n\t\t\treturn response as Response\n\n\t\tcase 'Error':\n\t\t\treturn errorToResponse(response as Error)\n\n\t\tcase 'Promise':\n\t\t\treturn (response as any as Promise<unknown>).then((x) =>\n\t\t\t\tmapCompactResponse(x, request)\n\t\t\t) as any\n\n\t\t// ? Maybe response or Blob\n\t\tcase 'Function':\n\t\t\treturn mapCompactResponse((response as Function)(), request)\n\n\t\tcase 'Number':\n\t\tcase 'Boolean':\n\t\t\treturn new Response((response as number | boolean).toString())\n\n\t\tcase 'FormData':\n\t\t\treturn new Response(response as FormData)\n\n\t\tdefault:\n\t\t\tif (response instanceof Response) return response\n\n\t\t\tif (response instanceof Promise)\n\t\t\t\treturn response.then((x) =>\n\t\t\t\t\tmapCompactResponse(x, request)\n\t\t\t\t) as any\n\n\t\t\tif (response instanceof Error)\n\t\t\t\treturn errorToResponse(response as Error)\n\n\t\t\tif (response instanceof ElysiaCustomStatusResponse)\n\t\t\t\treturn mapResponse(\n\t\t\t\t\t(response as ElysiaCustomStatusResponse<200>).response,\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: (response as ElysiaCustomStatusResponse<200>)\n\t\t\t\t\t\t\t.code,\n\t\t\t\t\t\theaders: {}\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\tif (\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttypeof response?.next === 'function' ||\n\t\t\t\tresponse instanceof ReadableStream\n\t\t\t)\n\t\t\t\treturn handleStream(response as any, undefined, request) as any\n\n\t\t\t// @ts-expect-error\n\t\t\tif (typeof response?.then === 'function')\n\t\t\t\t// @ts-expect-error\n\t\t\t\treturn response.then((x) => mapResponse(x, set)) as any\n\n\t\t\t// @ts-expect-error\n\t\t\tif (typeof response?.toResponse === 'function')\n\t\t\t\treturn mapCompactResponse((response as any).toResponse())\n\n\t\t\tif ('charCodeAt' in (response as any)) {\n\t\t\t\tconst code = (response as any).charCodeAt(0)\n\n\t\t\t\tif (code === 123 || code === 91) {\n\t\t\t\t\treturn new Response(JSON.stringify(response), {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t\t\t}\n\t\t\t\t\t}) as any\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new Response(response as any)\n\t}\n}\n\nexport const errorToResponse = (error: Error, set?: Context['set']) =>\n\tnew Response(\n\t\tJSON.stringify({\n\t\t\tname: error?.name,\n\t\t\tmessage: error?.message,\n\t\t\tcause: error?.cause\n\t\t}),\n\t\t{\n\t\t\tstatus:\n\t\t\t\tset?.status !== 200 ? ((set?.status as number) ?? 500) : 500,\n\t\t\theaders: set?.headers as any\n\t\t}\n\t)\n\nexport const createStaticHandler = (\n\thandle: unknown,\n\thooks: Partial<AnyLocalHook>,\n\tsetHeaders: Context['set']['headers'] = {}\n): (() => Response) | undefined => {\n\tif (typeof handle === 'function') return\n\n\tconst response = mapResponse(handle, {\n\t\theaders: setHeaders\n\t})\n\n\tif (\n\t\t!hooks.parse?.length &&\n\t\t!hooks.transform?.length &&\n\t\t!hooks.beforeHandle?.length &&\n\t\t!hooks.afterHandle?.length\n\t)\n\t\treturn () => response.clone() as Response\n}\n\nconst handleResponse = createResponseHandler({\n\tmapResponse,\n\tmapCompactResponse\n})\n\nconst handleStream = createStreamHandler({\n\tmapResponse,\n\tmapCompactResponse\n})\n",
|
|
22
|
-
"import type { AnyElysia } from '.'\n\nimport { Value } from '@sinclair/typebox/value'\nimport {\n\tKind,\n\tOptionalKind,\n\tTypeBoxError,\n\ttype TAnySchema,\n\ttype TSchema\n} from '@sinclair/typebox'\n\nimport decode from 'fast-decode-uri-component'\nimport { parseQuery, parseQueryFromURL } from './parse-query'\n\nimport {\n\tELYSIA_REQUEST_ID,\n\tgetLoosePath,\n\tlifeCycleToFn,\n\trandomId,\n\tredirect,\n\tsignCookie,\n\tisNotEmpty,\n\tencodePath,\n\tmergeCookie\n} from './utils'\nimport { isBun } from './universal/utils'\nimport { ParseError, status } from './error'\n\nimport {\n\tNotFoundError,\n\tValidationError,\n\tERROR_CODE,\n\tElysiaCustomStatusResponse\n} from './error'\nimport { ELYSIA_TRACE, type TraceHandler } from './trace'\n\nimport {\n\tcoercePrimitiveRoot,\n\tElysiaTypeCheck,\n\tgetCookieValidator,\n\tgetSchemaValidator,\n\thasType,\n\tisUnion,\n\tunwrapImportSchema\n} from './schema'\nimport { Sucrose, sucrose } from './sucrose'\nimport { parseCookie, type CookieOptions } from './cookies'\nimport { validateFileExtension } from './type-system/utils'\n\nimport type { TraceEvent } from './trace'\nimport type {\n\tComposedHandler,\n\tElysiaConfig,\n\tHandler,\n\tHookContainer,\n\tLifeCycleStore,\n\tSchemaValidator\n} from './types'\n\nconst allocateIf = (value: string, condition: unknown) =>\n\tcondition ? value : ''\n\nconst defaultParsers = [\n\t'json',\n\t'text',\n\t'urlencoded',\n\t'arrayBuffer',\n\t'formdata',\n\t'application/json',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'text/plain',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'application/x-www-form-urlencoded',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'application/octet-stream',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'multipart/form-data'\n]\n\nconst createReport = ({\n\tcontext = 'c',\n\ttrace = [],\n\taddFn\n}: {\n\tcontext?: string\n\ttrace?: (TraceHandler | HookContainer<TraceHandler>)[]\n\taddFn(string: string): void\n}) => {\n\tif (!trace.length)\n\t\treturn () => {\n\t\t\treturn {\n\t\t\t\tresolveChild() {\n\t\t\t\t\treturn () => {}\n\t\t\t\t},\n\t\t\t\tresolve() {}\n\t\t\t}\n\t\t}\n\n\tfor (let i = 0; i < trace.length; i++)\n\t\taddFn(\n\t\t\t`let report${i},reportChild${i},reportErr${i},reportErrChild${i};` +\n\t\t\t\t`let trace${i}=${context}[ELYSIA_TRACE]?.[${i}]??trace[${i}](${context});\\n`\n\t\t)\n\n\treturn (\n\t\tevent: TraceEvent,\n\t\t{\n\t\t\tname,\n\t\t\ttotal = 0\n\t\t}: {\n\t\t\tname?: string\n\t\t\tattribute?: string\n\t\t\ttotal?: number\n\t\t} = {}\n\t) => {\n\t\t// ? For debug specific event\n\t\t// if (event !== 'mapResponse')\n\t\t// \treturn {\n\t\t// \t\tresolveChild() {\n\t\t// \t\t\treturn () => {}\n\t\t// \t\t},\n\t\t// \t\tresolve() {}\n\t\t// \t}\n\n\t\tif (!name) name = 'anonymous'\n\n\t\tconst reporter = event === 'error' ? 'reportErr' : 'report'\n\n\t\tfor (let i = 0; i < trace.length; i++)\n\t\t\taddFn(\n\t\t\t\t`${reporter}${i} = trace${i}.${event}({` +\n\t\t\t\t\t`id,` +\n\t\t\t\t\t`event:'${event}',` +\n\t\t\t\t\t`name:'${name}',` +\n\t\t\t\t\t`begin:performance.now(),` +\n\t\t\t\t\t`total:${total}` +\n\t\t\t\t\t`})\\n`\n\t\t\t)\n\n\t\treturn {\n\t\t\tresolve() {\n\t\t\t\tfor (let i = 0; i < trace.length; i++)\n\t\t\t\t\taddFn(`${reporter}${i}.resolve()\\n`)\n\t\t\t},\n\t\t\tresolveChild(name: string) {\n\t\t\t\tfor (let i = 0; i < trace.length; i++)\n\t\t\t\t\taddFn(\n\t\t\t\t\t\t`${reporter}Child${i}=${reporter}${i}.resolveChild?.shift()?.({` +\n\t\t\t\t\t\t\t`id,` +\n\t\t\t\t\t\t\t`event:'${event}',` +\n\t\t\t\t\t\t\t`name:'${name}',` +\n\t\t\t\t\t\t\t`begin:performance.now()` +\n\t\t\t\t\t\t\t`})\\n`\n\t\t\t\t\t)\n\n\t\t\t\treturn (binding?: string) => {\n\t\t\t\t\tfor (let i = 0; i < trace.length; i++) {\n\t\t\t\t\t\tif (binding)\n\t\t\t\t\t\t\t// Don't report error because HTTP response is expected and not an actual error to look for\n\t\t\t\t\t\t\t// if (${binding} instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\t\t\t// ${reporter}Child${i}?.(${binding}.error)\n\t\t\t\t\t\t\t// ${reporter}Child${i}?.()\\n\n\t\t\t\t\t\t\t// } else\n\t\t\t\t\t\t\taddFn(\n\t\t\t\t\t\t\t\t`if(${binding} instanceof Error){` +\n\t\t\t\t\t\t\t\t\t`${reporter}Child${i}?.(${binding}) ` +\n\t\t\t\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t\t\t\t`${reporter}Child${i}?.()` +\n\t\t\t\t\t\t\t\t\t'}'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\telse addFn(`${reporter}Child${i}?.()\\n`)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst composeCleaner = ({\n\tschema,\n\tname,\n\ttype,\n\ttypeAlias = type,\n\tnormalize,\n\tignoreTryCatch = false\n}: {\n\tschema: ElysiaTypeCheck<any>\n\tname: string\n\ttype: keyof SchemaValidator\n\ttypeAlias?: string\n\tnormalize: ElysiaConfig<''>['normalize']\n\tignoreTryCatch?: boolean\n}) => {\n\tif (!normalize || !schema.Clean) return ''\n\n\tif (normalize === true || normalize === 'exactMirror') {\n\t\tif (ignoreTryCatch)\n\t\t\treturn `${name}=validator.${typeAlias}.Clean(${name})\\n`\n\n\t\treturn (\n\t\t\t`try{` +\n\t\t\t`${name}=validator.${typeAlias}.Clean(${name})\\n` +\n\t\t\t`}catch{}`\n\t\t)\n\t}\n\n\tif (normalize === 'typebox')\n\t\treturn `${name}=validator.${typeAlias}.Clean(${name})\\n`\n\n\treturn ''\n}\n\nconst composeValidationFactory = ({\n\tinjectResponse = '',\n\tnormalize = false,\n\tvalidator,\n\tencodeSchema = false,\n\tisStaticResponse = false,\n\thasSanitize = false\n}: {\n\tinjectResponse?: string\n\tnormalize?: ElysiaConfig<''>['normalize']\n\tvalidator: SchemaValidator\n\tencodeSchema?: boolean\n\tisStaticResponse?: boolean\n\thasSanitize?: boolean\n}) => ({\n\tvalidate: (type: string, value = `c.${type}`) =>\n\t\t`c.set.status=422;throw new ValidationError('${type}',validator.${type},${value})`,\n\tresponse: (name = 'r') => {\n\t\tif (isStaticResponse) return ''\n\n\t\tlet code = injectResponse + '\\n'\n\n\t\tcode +=\n\t\t\t`if(${name} instanceof ElysiaCustomStatusResponse){` +\n\t\t\t`c.set.status=${name}.code\\n` +\n\t\t\t`${name}=${name}.response` +\n\t\t\t`}` +\n\t\t\t`switch(c.set.status){`\n\n\t\tfor (const [status, value] of Object.entries(validator.response!)) {\n\t\t\tcode += `\\ncase ${status}:if(${name} instanceof Response)break\\n`\n\n\t\t\tconst noValidate = value.schema?.noValidate === true\n\n\t\t\tconst appliedCleaner = noValidate || hasSanitize\n\n\t\t\tconst clean = ({ ignoreTryCatch = false } = {}) =>\n\t\t\t\tcomposeCleaner({\n\t\t\t\t\tname,\n\t\t\t\t\tschema: value,\n\t\t\t\t\ttype: 'response',\n\t\t\t\t\ttypeAlias: `response[${status}]`,\n\t\t\t\t\tnormalize,\n\t\t\t\t\tignoreTryCatch\n\t\t\t\t})\n\n\t\t\tif (appliedCleaner) code += clean()\n\n\t\t\tconst applyErrorCleaner =\n\t\t\t\t!appliedCleaner && normalize && !noValidate\n\n\t\t\t// Encode call TypeCheck.Check internally\n\t\t\tif (encodeSchema && value.hasTransform) {\n\t\t\t\tcode +=\n\t\t\t\t\t`try{` +\n\t\t\t\t\t`${name}=validator.response[${status}].Encode(${name})\\n`\n\n\t\t\t\tif (!appliedCleaner) code += clean({ ignoreTryCatch: true })\n\n\t\t\t\tcode +=\n\t\t\t\t\t`c.set.status=${status}` +\n\t\t\t\t\t`}catch{` +\n\t\t\t\t\t(applyErrorCleaner\n\t\t\t\t\t\t? `try{\\n` +\n\t\t\t\t\t\t\tclean({ ignoreTryCatch: true }) +\n\t\t\t\t\t\t\t`${name}=validator.response[${status}].Encode(${name})\\n` +\n\t\t\t\t\t\t\t`}catch{` +\n\t\t\t\t\t\t\t`throw new ValidationError('response',validator.response[${status}],${name})` +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t\t\t: `throw new ValidationError('response',validator.response[${status}],${name})`) +\n\t\t\t\t\t`}`\n\t\t\t} else {\n\t\t\t\tif (!appliedCleaner) code += clean()\n\n\t\t\t\tif (!noValidate)\n\t\t\t\t\tcode +=\n\t\t\t\t\t\t`if(validator.response[${status}].Check(${name})===false)` +\n\t\t\t\t\t\t`throw new ValidationError('response',validator.response[${status}],${name})\\n` +\n\t\t\t\t\t\t`c.set.status=${status}\\n`\n\t\t\t}\n\n\t\t\tcode += 'break\\n'\n\t\t}\n\n\t\treturn code + '}'\n\t}\n})\n\nconst isAsyncName = (v: Function | HookContainer) => {\n\t// @ts-ignore\n\tconst fn = v?.fn ?? v\n\n\treturn fn.constructor.name === 'AsyncFunction'\n}\n\nconst matchResponseClone = /=>\\s?response\\.clone\\(/\nconst matchFnReturn = /(?:return|=>)\\s?\\S+\\(|a(?:sync|wait)/\n\nexport const isAsync = (v: Function | HookContainer) => {\n\tconst isObject = typeof v === 'object'\n\n\tif (isObject && v.isAsync !== undefined) return v.isAsync\n\n\tconst fn = isObject ? v.fn : v\n\n\tif (fn.constructor.name === 'AsyncFunction') return true\n\n\tconst literal: string = fn.toString()\n\n\tif (matchResponseClone.test(literal)) {\n\t\tif (isObject) v.isAsync = false\n\n\t\treturn false\n\t}\n\n\tconst result = matchFnReturn.test(literal)\n\n\tif (isObject) v.isAsync = result\n\n\treturn result\n}\n\nconst hasReturn = (v: string | HookContainer<any> | Function) => {\n\tconst isObject = typeof v === 'object'\n\n\tif (isObject && v.hasReturn !== undefined) return v.hasReturn\n\n\tconst fnLiteral = isObject\n\t\t? v.fn.toString()\n\t\t: typeof v === 'string'\n\t\t\t? v.toString()\n\t\t\t: v\n\n\tconst parenthesisEnd = fnLiteral.indexOf(')')\n\n\t// Is direct arrow function return eg. () => 1\n\tif (\n\t\tfnLiteral.charCodeAt(parenthesisEnd + 2) === 61 &&\n\t\tfnLiteral.charCodeAt(parenthesisEnd + 5) !== 123\n\t) {\n\t\tif (isObject) v.hasReturn = true\n\n\t\treturn true\n\t}\n\n\tconst result = fnLiteral.includes('return')\n\n\tif (isObject) v.hasReturn = result\n\n\treturn result\n}\n\nconst isGenerator = (v: Function | HookContainer) => {\n\t// @ts-ignore\n\tconst fn = v?.fn ?? v\n\n\treturn (\n\t\tfn.constructor.name === 'AsyncGeneratorFunction' ||\n\t\tfn.constructor.name === 'GeneratorFunction'\n\t)\n}\n\nconst coerceTransformDecodeError = (\n\tfnLiteral: string,\n\ttype: string,\n\tvalue = `c.${type}`\n) =>\n\t`try{${fnLiteral}}catch(error){` +\n\t`if(error.constructor.name === 'TransformDecodeError'){` +\n\t`c.set.status=422\\n` +\n\t`throw error.error ?? new ValidationError('${type}',validator.${type},${value})}` +\n\t`}`\n\nexport const composeHandler = ({\n\tapp,\n\tpath,\n\tmethod,\n\thooks,\n\tvalidator,\n\thandler,\n\tallowMeta = false,\n\tinference\n}: {\n\tapp: AnyElysia\n\tpath: string\n\tmethod: string\n\thooks: Partial<LifeCycleStore>\n\tvalidator: SchemaValidator\n\thandler: unknown | Handler<any, any>\n\tallowMeta?: boolean\n\tinference: Sucrose.Inference\n}): ComposedHandler => {\n\tconst adapter = app['~adapter'].composeHandler\n\tconst adapterHandler = app['~adapter'].handler\n\tconst isHandleFn = typeof handler === 'function'\n\n\tif (!isHandleFn) {\n\t\thandler = adapterHandler.mapResponse(handler, {\n\t\t\t// @ts-expect-error private property\n\t\t\theaders: app.setHeaders ?? {}\n\t\t})\n\n\t\tconst isResponse =\n\t\t\thandler instanceof Response ||\n\t\t\t// @ts-ignore If it's not instanceof Response, it might be a polyfill (only on Node)\n\t\t\t(handler?.constructor?.name === 'Response' &&\n\t\t\t\ttypeof (handler as Response)?.clone === 'function')\n\n\t\tif (\n\t\t\thooks.parse?.length &&\n\t\t\thooks.transform?.length &&\n\t\t\thooks.beforeHandle?.length &&\n\t\t\thooks.afterHandle?.length\n\t\t) {\n\t\t\tif (isResponse)\n\t\t\t\treturn Function(\n\t\t\t\t\t'a',\n\t\t\t\t\t'\"use strict\";\\n' + `return function(){return a.clone()}`\n\t\t\t\t)(handler)\n\n\t\t\treturn Function(\n\t\t\t\t'a',\n\t\t\t\t'\"use strict\";\\n' + 'return function(){return a}'\n\t\t\t)(handler)\n\t\t}\n\n\t\tif (isResponse) {\n\t\t\tconst response = handler as Response\n\n\t\t\thandler = () => response.clone()\n\t\t}\n\t}\n\n\tconst handle = isHandleFn ? `handler(c)` : `handler`\n\n\tconst hasTrace = !!hooks.trace?.length\n\tlet fnLiteral = ''\n\n\tinference = sucrose(hooks, inference)\n\tinference = sucrose(\n\t\t{\n\t\t\thandler: handler as any\n\t\t},\n\t\tinference\n\t)\n\n\tif (adapter.declare) {\n\t\tconst literal = adapter.declare(inference)\n\n\t\tif (literal) fnLiteral += literal\n\t}\n\n\tif (inference.server)\n\t\tfnLiteral +=\n\t\t\t\"Object.defineProperty(c,'server',{\" +\n\t\t\t'get:function(){return getServer()}' +\n\t\t\t'})\\n'\n\n\tvalidator.createBody?.()\n\tvalidator.createQuery?.()\n\tvalidator.createHeaders?.()\n\tvalidator.createParams?.()\n\tvalidator.createCookie?.()\n\tvalidator.createResponse?.()\n\n\tconst hasValidation =\n\t\t!!validator.body ||\n\t\t!!validator.headers ||\n\t\t!!validator.params ||\n\t\t!!validator.query ||\n\t\t!!validator.cookie ||\n\t\t!!validator.response\n\n\tconst hasQuery = inference.query || !!validator.query\n\n\tconst requestNoBody =\n\t\thooks.parse?.length === 1 &&\n\t\t// @ts-expect-error\n\t\thooks.parse[0].fn === 'none'\n\n\tconst hasBody =\n\t\tmethod !== '' &&\n\t\tmethod !== 'GET' &&\n\t\tmethod !== 'HEAD' &&\n\t\t(inference.body || !!validator.body || !!hooks.parse?.length) &&\n\t\t!requestNoBody\n\n\t// @ts-expect-error private\n\tconst defaultHeaders = app.setHeaders\n\tconst hasDefaultHeaders =\n\t\tdefaultHeaders && !!Object.keys(defaultHeaders).length\n\n\t// ? defaultHeaders doesn't imply that user will use headers in handler\n\tconst hasHeaders =\n\t\tinference.headers ||\n\t\t!!validator.headers ||\n\t\t(adapter.preferWebstandardHeaders !== true && inference.body)\n\n\tconst hasCookie = inference.cookie || !!validator.cookie\n\n\tconst cookieMeta: {\n\t\tsecrets?: string | string[]\n\t\tsign: string[] | true\n\t\tproperties: { [x: string]: Object }\n\t} = validator.cookie?.config\n\t\t? mergeCookie(validator?.cookie?.config, app.config.cookie as any)\n\t\t: app.config.cookie\n\n\tlet _encodeCookie = ''\n\tconst encodeCookie = () => {\n\t\tif (_encodeCookie) return _encodeCookie\n\n\t\tif (cookieMeta?.sign) {\n\t\t\tif (!cookieMeta.secrets)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`t.Cookie required secret which is not set in (${method}) ${path}.`\n\t\t\t\t)\n\n\t\t\tconst secret = !cookieMeta.secrets\n\t\t\t\t? undefined\n\t\t\t\t: typeof cookieMeta.secrets === 'string'\n\t\t\t\t\t? cookieMeta.secrets\n\t\t\t\t\t: cookieMeta.secrets[0]\n\n\t\t\t_encodeCookie +=\n\t\t\t\t'const _setCookie = c.set.cookie\\n' + 'if(_setCookie){'\n\n\t\t\tif (cookieMeta.sign === true)\n\t\t\t\t_encodeCookie +=\n\t\t\t\t\t'for(const [key, cookie] of Object.entries(_setCookie)){' +\n\t\t\t\t\t`c.set.cookie[key].value=await signCookie(cookie.value,'${secret}')` +\n\t\t\t\t\t'}'\n\t\t\telse\n\t\t\t\tfor (const name of cookieMeta.sign)\n\t\t\t\t\t_encodeCookie +=\n\t\t\t\t\t\t`if(_setCookie['${name}']?.value)` +\n\t\t\t\t\t\t`c.set.cookie['${name}'].value=await signCookie(_setCookie['${name}'].value,'${secret}')\\n`\n\n\t\t\t_encodeCookie += '}\\n'\n\t\t}\n\n\t\treturn _encodeCookie\n\t}\n\n\tconst normalize = app.config.normalize\n\tconst encodeSchema = app.config.encodeSchema\n\n\tconst validation = composeValidationFactory({\n\t\tnormalize,\n\t\tvalidator,\n\t\tencodeSchema,\n\t\tisStaticResponse: handler instanceof Response,\n\t\thasSanitize: !!app.config.sanitize\n\t})\n\n\tif (hasHeaders) fnLiteral += adapter.headers\n\n\tif (hasTrace) fnLiteral += 'const id=c[ELYSIA_REQUEST_ID]\\n'\n\n\tconst report = createReport({\n\t\ttrace: hooks.trace,\n\t\taddFn: (word) => {\n\t\t\tfnLiteral += word\n\t\t}\n\t})\n\n\tfnLiteral += 'try{'\n\n\tif (hasCookie) {\n\t\tconst get = (name: keyof CookieOptions, defaultValue?: unknown) => {\n\t\t\t// @ts-ignore\n\t\t\tconst value = cookieMeta?.[name] ?? defaultValue\n\t\t\tif (!value)\n\t\t\t\treturn typeof defaultValue === 'string'\n\t\t\t\t\t? `${name}:\"${defaultValue}\",`\n\t\t\t\t\t: `${name}:${defaultValue},`\n\n\t\t\tif (typeof value === 'string') return `${name}:'${value}',`\n\t\t\tif (value instanceof Date)\n\t\t\t\treturn `${name}: new Date(${value.getTime()}),`\n\n\t\t\treturn `${name}:${value},`\n\t\t}\n\n\t\tconst options = cookieMeta\n\t\t\t? `{secrets:${\n\t\t\t\t\tcookieMeta.secrets !== undefined\n\t\t\t\t\t\t? typeof cookieMeta.secrets === 'string'\n\t\t\t\t\t\t\t? `'${cookieMeta.secrets}'`\n\t\t\t\t\t\t\t: '[' +\n\t\t\t\t\t\t\t\tcookieMeta.secrets.reduce(\n\t\t\t\t\t\t\t\t\t(a, b) => a + `'${b}',`,\n\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t) +\n\t\t\t\t\t\t\t\t']'\n\t\t\t\t\t\t: 'undefined'\n\t\t\t\t},` +\n\t\t\t\t`sign:${\n\t\t\t\t\tcookieMeta.sign === true\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: cookieMeta.sign !== undefined\n\t\t\t\t\t\t\t? '[' +\n\t\t\t\t\t\t\t\tcookieMeta.sign.reduce(\n\t\t\t\t\t\t\t\t\t(a, b) => a + `'${b}',`,\n\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t) +\n\t\t\t\t\t\t\t\t']'\n\t\t\t\t\t\t\t: 'undefined'\n\t\t\t\t},` +\n\t\t\t\tget('domain') +\n\t\t\t\tget('expires') +\n\t\t\t\tget('httpOnly') +\n\t\t\t\tget('maxAge') +\n\t\t\t\tget('path', '/') +\n\t\t\t\tget('priority') +\n\t\t\t\tget('sameSite') +\n\t\t\t\tget('secure') +\n\t\t\t\t'}'\n\t\t\t: 'undefined'\n\n\t\tif (hasHeaders)\n\t\t\tfnLiteral += `\\nc.cookie=await parseCookie(c.set,c.headers.cookie,${options})\\n`\n\t\telse\n\t\t\tfnLiteral += `\\nc.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${options})\\n`\n\t}\n\n\tif (hasQuery) {\n\t\tconst destructured = <\n\t\t\t{\n\t\t\t\tkey: string\n\t\t\t\tisArray: boolean\n\t\t\t\tisNestedObjectArray: boolean\n\t\t\t\tisObject: boolean\n\t\t\t\tanyOf: boolean\n\t\t\t}[]\n\t\t>[]\n\n\t\tconst schema = validator.query?.schema\n\t\tif (\n\t\t\tschema &&\n\t\t\t(schema.type === 'object' ||\n\t\t\t\t(schema[Kind] === 'Import' && schema.$defs[schema.$ref]))\n\t\t) {\n\t\t\tconst properties =\n\t\t\t\tschema.properties ?? schema.$defs[schema.$ref].properties\n\n\t\t\tif (!validator.query!.hasAdditionalProperties)\n\t\t\t\tfor (const [key, _value] of Object.entries(properties)) {\n\t\t\t\t\tlet value = _value as TAnySchema\n\n\t\t\t\t\tconst isArray =\n\t\t\t\t\t\tvalue.type === 'array' ||\n\t\t\t\t\t\t!!value.anyOf?.some(\n\t\t\t\t\t\t\t(v: TSchema) =>\n\t\t\t\t\t\t\t\tv.type === 'string' &&\n\t\t\t\t\t\t\t\tv.format === 'ArrayString'\n\t\t\t\t\t\t)\n\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (\n\t\t\t\t\t\tvalue &&\n\t\t\t\t\t\tOptionalKind in value &&\n\t\t\t\t\t\tvalue.type === 'array' &&\n\t\t\t\t\t\tvalue.items\n\t\t\t\t\t)\n\t\t\t\t\t\tvalue = value.items\n\n\t\t\t\t\tconst { type, anyOf } = value\n\n\t\t\t\t\tdestructured.push({\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tisArray,\n\t\t\t\t\t\tisNestedObjectArray:\n\t\t\t\t\t\t\t(isArray && value.items?.type === 'object') ||\n\t\t\t\t\t\t\t!!value.items?.anyOf?.some(\n\t\t\t\t\t\t\t\t(x: TSchema) =>\n\t\t\t\t\t\t\t\t\tx.type === 'object' || x.type === 'array'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tisObject:\n\t\t\t\t\t\t\ttype === 'object' ||\n\t\t\t\t\t\t\tanyOf?.some(\n\t\t\t\t\t\t\t\t(v: TSchema) =>\n\t\t\t\t\t\t\t\t\tv.type === 'string' &&\n\t\t\t\t\t\t\t\t\tv.format === 'ArrayString'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tanyOf: !!anyOf\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t}\n\n\t\tif (!destructured.length) {\n\t\t\tfnLiteral +=\n\t\t\t\t'if(c.qi===-1){' +\n\t\t\t\t'c.query={}' +\n\t\t\t\t'}else{' +\n\t\t\t\t'c.query=parseQueryFromURL(c.url,c.qi+1)' +\n\t\t\t\t'}'\n\t\t} else {\n\t\t\tfnLiteral += 'if(c.qi!==-1){' + `let url='&'+c.url.slice(c.qi+1)\\n`\n\n\t\t\tlet index = 0\n\t\t\tfor (const {\n\t\t\t\tkey,\n\t\t\t\tisArray,\n\t\t\t\tisObject,\n\t\t\t\tisNestedObjectArray,\n\t\t\t\tanyOf\n\t\t\t} of destructured) {\n\t\t\t\tconst encoded = encodeURIComponent(key)\n\n\t\t\t\tconst init =\n\t\t\t\t\t(index === 0 ? 'let ' : '') +\n\t\t\t\t\t`memory=url.indexOf('&${encoded}=')` +\n\t\t\t\t\t`\\nlet a${index}\\n`\n\n\t\t\t\tif (isArray) {\n\t\t\t\t\tfnLiteral += init\n\n\t\t\t\t\tif (isNestedObjectArray)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`while(memory!==-1){` +\n\t\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t\t`if(a${index}===undefined)\\n` +\n\t\t\t\t\t\t\t`a${index}=''\\n` +\n\t\t\t\t\t\t\t`else\\n` +\n\t\t\t\t\t\t\t`a${index}+=','\\n` +\n\t\t\t\t\t\t\t`let temp\\n` +\n\t\t\t\t\t\t\t`if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`else temp=decodeURIComponent(url.slice(start, memory).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`const charCode=temp.charCodeAt(0)\\n` +\n\t\t\t\t\t\t\t`if(charCode!==91&&charCode !== 123)\\n` +\n\t\t\t\t\t\t\t`temp='\"'+temp+'\"'\\n` +\n\t\t\t\t\t\t\t`a${index}+=temp\\n` +\n\t\t\t\t\t\t\t`if(memory===-1)break\\n` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&${encoded}=',memory)\\n` +\n\t\t\t\t\t\t\t`if(memory===-1)break` +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`try{` +\n\t\t\t\t\t\t\t`if(a${index}.charCodeAt(0)===91)` +\n\t\t\t\t\t\t\t`a${index} = JSON.parse(a${index})\\n` +\n\t\t\t\t\t\t\t`else\\n` +\n\t\t\t\t\t\t\t`a${index}=JSON.parse('['+a${index}+']')` +\n\t\t\t\t\t\t\t`}catch{}\\n`\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`while(memory!==-1){` +\n\t\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t\t`if(a${index}===undefined)` +\n\t\t\t\t\t\t\t`a${index}=[]\\n` +\n\t\t\t\t\t\t\t`if(memory===-1){` +\n\t\t\t\t\t\t\t`const temp=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`if(temp.includes(',')){a${index}=a${index}.concat(temp.split(','))}` +\n\t\t\t\t\t\t\t`else{a${index}.push(decodeURIComponent(url.slice(start).replace(/\\\\+/g,' ')))}\\n` +\n\t\t\t\t\t\t\t`break` +\n\t\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t\t`const temp=decodeURIComponent(url.slice(start, memory).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`if(temp.includes(',')){a${index}=a${index}.concat(temp.split(','))}` +\n\t\t\t\t\t\t\t`else{a${index}.push(temp)}\\n` +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&${encoded}=',memory)\\n` +\n\t\t\t\t\t\t\t`if(memory===-1) break\\n` +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t} else if (isObject)\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\tinit +\n\t\t\t\t\t\t`if(memory!==-1){` +\n\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t`if(memory===-1)a${index}=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))` +\n\t\t\t\t\t\t`else a${index}=decodeURIComponent(url.slice(start,memory).replace(/\\\\+/g,' '))` +\n\t\t\t\t\t\t`if(a${index}!==undefined)` +\n\t\t\t\t\t\t`try{` +\n\t\t\t\t\t\t`a${index}=JSON.parse(a${index})` +\n\t\t\t\t\t\t`}catch{}` +\n\t\t\t\t\t\t'}'\n\t\t\t\t// Might be union primitive and array\n\t\t\t\telse {\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\tinit +\n\t\t\t\t\t\t`if(memory!==-1){` +\n\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t`if(memory===-1)a${index}=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t`else{` +\n\t\t\t\t\t\t`a${index}=decodeURIComponent(url.slice(start,memory).replace(/\\\\+/g,' '))`\n\n\t\t\t\t\tif (anyOf)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`\\nlet deepMemory=url.indexOf('&${encoded}=',memory)\\n` +\n\t\t\t\t\t\t\t`if(deepMemory!==-1){` +\n\t\t\t\t\t\t\t`a${index}=[a${index}]\\n` +\n\t\t\t\t\t\t\t`let first=true\\n` +\n\t\t\t\t\t\t\t`while(true){` +\n\t\t\t\t\t\t\t`const start=deepMemory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t\t`if(first)first=false\\n` +\n\t\t\t\t\t\t\t`else deepMemory = url.indexOf('&', start)\\n` +\n\t\t\t\t\t\t\t`let value\\n` +\n\t\t\t\t\t\t\t`if(deepMemory===-1)value=url.slice(start).replace(/\\\\+/g,' ')\\n` +\n\t\t\t\t\t\t\t`else value=url.slice(start, deepMemory).replace(/\\\\+/g,' ')\\n` +\n\t\t\t\t\t\t\t`value=decodeURIComponent(value)\\n` +\n\t\t\t\t\t\t\t`if(value===null){if(deepMemory===-1){break}else{continue}}\\n` +\n\t\t\t\t\t\t\t`const vStart=value.charCodeAt(0)\\n` +\n\t\t\t\t\t\t\t`const vEnd=value.charCodeAt(value.length - 1)\\n` +\n\t\t\t\t\t\t\t`if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))\\n` +\n\t\t\t\t\t\t\t`try{` +\n\t\t\t\t\t\t\t`a${index}.push(JSON.parse(value))` +\n\t\t\t\t\t\t\t`}catch{` +\n\t\t\t\t\t\t\t`a${index}.push(value)` +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`if(deepMemory===-1)break` +\n\t\t\t\t\t\t\t`}}`\n\n\t\t\t\t\tfnLiteral += '}}'\n\t\t\t\t}\n\n\t\t\t\tindex++\n\t\t\t\tfnLiteral += '\\n'\n\t\t\t}\n\n\t\t\tfnLiteral +=\n\t\t\t\t`c.query={` +\n\t\t\t\tdestructured\n\t\t\t\t\t.map(({ key }, index) => `'${key}':a${index}`)\n\t\t\t\t\t.join(',') +\n\t\t\t\t`}`\n\n\t\t\t// If there are no query parameters, set it to an empty object\n\t\t\tfnLiteral += `} else c.query = {}\\n`\n\t\t}\n\t}\n\n\tconst isAsyncHandler = typeof handler === 'function' && isAsync(handler)\n\n\tconst saveResponse =\n\t\thasTrace || hooks.afterResponse?.length ? 'c.response= ' : ''\n\n\tconst maybeAsync =\n\t\thasCookie ||\n\t\thasBody ||\n\t\tisAsyncHandler ||\n\t\t!!hooks.parse?.length ||\n\t\t!!hooks.afterHandle?.some(isAsync) ||\n\t\t!!hooks.beforeHandle?.some(isAsync) ||\n\t\t!!hooks.transform?.some(isAsync) ||\n\t\t!!hooks.mapResponse?.some(isAsync)\n\n\tconst maybeStream =\n\t\t(typeof handler === 'function' ? isGenerator(handler as any) : false) ||\n\t\t!!hooks.beforeHandle?.some(isGenerator) ||\n\t\t!!hooks.afterHandle?.some(isGenerator) ||\n\t\t!!hooks.transform?.some(isGenerator)\n\n\tconst responseKeys = Object.keys(validator.response ?? {})\n\tconst hasMultipleResponses = responseKeys.length > 1\n\tconst hasSingle200 =\n\t\tresponseKeys.length === 0 ||\n\t\t(responseKeys.length === 1 && responseKeys[0] === '200')\n\n\tconst hasSet =\n\t\tinference.cookie ||\n\t\tinference.set ||\n\t\thasHeaders ||\n\t\thasTrace ||\n\t\thasMultipleResponses ||\n\t\t!hasSingle200 ||\n\t\t(isHandleFn && hasDefaultHeaders) ||\n\t\tmaybeStream\n\n\tconst afterResponse = () => {\n\t\tif (!hooks.afterResponse?.length) return ''\n\n\t\tlet afterResponse = ''\n\t\tconst prefix = hooks.afterResponse?.some(isAsync) ? 'async ' : ''\n\n\t\tafterResponse += `\\nsetImmediate(${prefix}()=>{`\n\n\t\tconst reporter = report('afterResponse', {\n\t\t\ttotal: hooks.afterResponse?.length\n\t\t})\n\n\t\tif (hooks.afterResponse?.length && hooks.afterResponse) {\n\t\t\tfor (let i = 0; i < hooks.afterResponse.length; i++) {\n\t\t\t\tconst endUnit = reporter.resolveChild(\n\t\t\t\t\thooks.afterResponse[i].fn.name\n\t\t\t\t)\n\t\t\t\tconst prefix = isAsync(hooks.afterResponse[i]) ? 'await ' : ''\n\t\t\t\tafterResponse += `\\n${prefix}e.afterResponse[${i}](c)\\n`\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\n\t\tafterResponse += '})\\n'\n\n\t\treturn afterResponse\n\t}\n\n\tconst mapResponse = (r = 'r') => {\n\t\tconst after = afterResponse()\n\t\tconst response = `${hasSet ? 'mapResponse' : 'mapCompactResponse'}(${saveResponse}${r}${hasSet ? ',c.set' : ''}${mapResponseContext})\\n`\n\n\t\tif (!after) `return ${response}`\n\n\t\treturn `const _res=${response}` + after + `return _res`\n\t}\n\n\tconst mapResponseContext =\n\t\tmaybeStream || adapter.mapResponseContext\n\t\t\t? `,${adapter.mapResponseContext}`\n\t\t\t: ''\n\n\tif (hasTrace || inference.route) fnLiteral += `c.route=\\`${path}\\`\\n`\n\n\tconst parseReporter = report('parse', {\n\t\ttotal: hooks.parse?.length\n\t})\n\n\tif (hasBody) {\n\t\tconst hasBodyInference =\n\t\t\t!!hooks.parse?.length || inference.body || validator.body\n\n\t\tif (adapter.parser.declare) fnLiteral += adapter.parser.declare\n\n\t\tfnLiteral += '\\ntry{'\n\n\t\tlet parser: string | undefined =\n\t\t\ttypeof hooks.parse === 'string'\n\t\t\t\t? hooks.parse\n\t\t\t\t: Array.isArray(hooks.parse) && hooks.parse.length === 1\n\t\t\t\t\t? typeof hooks.parse[0] === 'string'\n\t\t\t\t\t\t? hooks.parse[0]\n\t\t\t\t\t\t: typeof hooks.parse[0].fn === 'string'\n\t\t\t\t\t\t\t? hooks.parse[0].fn\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t: undefined\n\n\t\tif (!parser && validator.body && !hooks.parse?.length) {\n\t\t\tconst schema = validator.body.schema\n\t\t\tif (\n\t\t\t\tschema &&\n\t\t\t\tschema.anyOf &&\n\t\t\t\tschema[Kind] === 'Union' &&\n\t\t\t\tschema.anyOf?.length === 2 &&\n\t\t\t\tschema.anyOf?.find((x: TAnySchema) => x[Kind] === 'ElysiaForm')\n\t\t\t)\n\t\t\t\tparser = 'formdata'\n\t\t}\n\n\t\tif (parser && defaultParsers.includes(parser)) {\n\t\t\tconst reporter = report('parse', {\n\t\t\t\ttotal: hooks.parse?.length\n\t\t\t})\n\n\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\tswitch (parser) {\n\t\t\t\tcase 'json':\n\t\t\t\tcase 'application/json':\n\t\t\t\t\tfnLiteral += adapter.parser.json(isOptionalBody)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'text':\n\t\t\t\tcase 'text/plain':\n\t\t\t\t\tfnLiteral += adapter.parser.text(isOptionalBody)\n\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'urlencoded':\n\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\tfnLiteral += adapter.parser.urlencoded(isOptionalBody)\n\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'arrayBuffer':\n\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\tfnLiteral += adapter.parser.arrayBuffer(isOptionalBody)\n\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'formdata':\n\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\tfnLiteral += adapter.parser.formData(isOptionalBody)\n\t\t\t\t\tbreak\n\n\t\t\t\tdefault:\n\t\t\t\t\tif ((parser[0] as string) in app['~parser']) {\n\t\t\t\t\t\tfnLiteral += hasHeaders\n\t\t\t\t\t\t\t? `let contentType = c.headers['content-type']`\n\t\t\t\t\t\t\t: `let contentType = c.request.headers.get('content-type')`\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`\\nif(contentType){` +\n\t\t\t\t\t\t\t`const index=contentType.indexOf(';')\\n` +\n\t\t\t\t\t\t\t`if(index!==-1)contentType=contentType.substring(0,index)}\\n` +\n\t\t\t\t\t\t\t`else{contentType=''}` +\n\t\t\t\t\t\t\t`c.contentType=contentType\\n` +\n\t\t\t\t\t\t\t`let result=parser['${parser}'](c, contentType)\\n` +\n\t\t\t\t\t\t\t`if(result instanceof Promise)result=await result\\n` +\n\t\t\t\t\t\t\t`if(result instanceof ElysiaCustomStatusResponse)throw result\\n` +\n\t\t\t\t\t\t\t`if(result!==undefined)c.body=result\\n` +\n\t\t\t\t\t\t\t'delete c.contentType\\n'\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak\n\t\t\t}\n\n\t\t\treporter.resolve()\n\t\t} else if (hasBodyInference) {\n\t\t\tfnLiteral += '\\n'\n\n\t\t\tfnLiteral += 'let contentType\\n' + 'if(c.request.body)'\n\t\t\tfnLiteral += hasHeaders\n\t\t\t\t? `contentType=c.headers['content-type']\\n`\n\t\t\t\t: `contentType=c.request.headers.get('content-type')\\n`\n\n\t\t\tlet hasDefaultParser = false\n\t\t\tif (hooks.parse?.length)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(contentType){\\n` +\n\t\t\t\t\t`const index=contentType.indexOf(';')\\n` +\n\t\t\t\t\t`\\nif(index!==-1)contentType=contentType.substring(0,index)` +\n\t\t\t\t\t`}else{contentType=''}` +\n\t\t\t\t\t`let used=false\\n` +\n\t\t\t\t\t`c.contentType=contentType\\n`\n\t\t\telse {\n\t\t\t\thasDefaultParser = true\n\t\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(contentType)` +\n\t\t\t\t\t`switch(contentType.charCodeAt(12)){` +\n\t\t\t\t\t`\\ncase 106:` +\n\t\t\t\t\tadapter.parser.json(isOptionalBody) +\n\t\t\t\t\t'break' +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`case 120:` +\n\t\t\t\t\tadapter.parser.urlencoded(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`case 111:` +\n\t\t\t\t\tadapter.parser.arrayBuffer(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`case 114:` +\n\t\t\t\t\tadapter.parser.formData(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`default:` +\n\t\t\t\t\t`if(contentType.charCodeAt(0)===116){` +\n\t\t\t\t\tadapter.parser.text(isOptionalBody) +\n\t\t\t\t\t`}` +\n\t\t\t\t\t`break\\n` +\n\t\t\t\t\t`}`\n\t\t\t}\n\n\t\t\tconst reporter = report('parse', {\n\t\t\t\ttotal: hooks.parse?.length\n\t\t\t})\n\n\t\t\tif (hooks.parse)\n\t\t\t\tfor (let i = 0; i < hooks.parse.length; i++) {\n\t\t\t\t\tconst name = `bo${i}`\n\t\t\t\t\tif (i !== 0) fnLiteral += `\\nif(!used){`\n\n\t\t\t\t\tif (typeof hooks.parse[i].fn === 'string') {\n\t\t\t\t\t\tconst endUnit = reporter.resolveChild(\n\t\t\t\t\t\t\thooks.parse[i].fn as unknown as string\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\t\t\t\tswitch (hooks.parse[i].fn as unknown as string) {\n\t\t\t\t\t\t\tcase 'json':\n\t\t\t\t\t\t\tcase 'application/json':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral += adapter.parser.json(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'text':\n\t\t\t\t\t\t\tcase 'text/plain':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral += adapter.parser.text(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'urlencoded':\n\t\t\t\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\tadapter.parser.urlencoded(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'arrayBuffer':\n\t\t\t\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\tadapter.parser.arrayBuffer(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'formdata':\n\t\t\t\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\tadapter.parser.formData(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\t`let ${name}=parser['${hooks.parse[i].fn}'](c,contentType)\\n` +\n\t\t\t\t\t\t\t\t\t`if(${name} instanceof Promise)${name}=await ${name}\\n` +\n\t\t\t\t\t\t\t\t\t`if(${name}!==undefined){c.body=${name};used=true;}\\n`\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst endUnit = reporter.resolveChild(\n\t\t\t\t\t\t\thooks.parse[i].fn.name\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`let ${name}=e.parse[${i}]\\n` +\n\t\t\t\t\t\t\t`${name}=${name}(c,contentType)\\n` +\n\t\t\t\t\t\t\t`if(${name} instanceof Promise)${name}=await ${name}\\n` +\n\t\t\t\t\t\t\t`if(${name}!==undefined){c.body=${name};used=true}`\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (i !== 0) fnLiteral += `}`\n\n\t\t\t\t\tif (hasDefaultParser) break\n\t\t\t\t}\n\n\t\t\treporter.resolve()\n\n\t\t\tif (!hasDefaultParser) {\n\t\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\t\tif (hooks.parse?.length) fnLiteral += `\\nif(!used){\\n`\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`switch(contentType){` +\n\t\t\t\t\t`case 'application/json':\\n` +\n\t\t\t\t\tadapter.parser.json(isOptionalBody) +\n\t\t\t\t\t`break\\n` +\n\t\t\t\t\t`case 'text/plain':` +\n\t\t\t\t\tadapter.parser.text(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t`case 'application/x-www-form-urlencoded':` +\n\t\t\t\t\tadapter.parser.urlencoded(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t`case 'application/octet-stream':` +\n\t\t\t\t\tadapter.parser.arrayBuffer(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t`case 'multipart/form-data':` +\n\t\t\t\t\tadapter.parser.formData(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n'\n\n\t\t\t\tfor (const key of Object.keys(app['~parser']))\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`case '${key}':` +\n\t\t\t\t\t\t`let bo${key}=parser['${key}'](c,contentType)\\n` +\n\t\t\t\t\t\t`if(bo${key} instanceof Promise)bo${key}=await bo${key}\\n` +\n\t\t\t\t\t\t`if(bo${key} instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\tmapResponse(`bo${key}`) +\n\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t`if(bo${key}!==undefined)c.body=bo${key}\\n` +\n\t\t\t\t\t\t`break` +\n\t\t\t\t\t\t'\\n'\n\n\t\t\t\tif (hooks.parse?.length) fnLiteral += '}'\n\n\t\t\t\tfnLiteral += '}'\n\t\t\t}\n\n\t\t\tif (hooks.parse?.length) fnLiteral += '\\ndelete c.contentType'\n\t\t}\n\n\t\tfnLiteral += '}catch(error){throw new ParseError(error)}'\n\t}\n\n\tparseReporter.resolve()\n\n\tif (hooks?.transform) {\n\t\tconst reporter = report('transform', {\n\t\t\ttotal: hooks.transform.length\n\t\t})\n\n\t\tif (hooks.transform.length) fnLiteral += 'let transformed\\n'\n\n\t\tfor (let i = 0; i < hooks.transform.length; i++) {\n\t\t\tconst transform = hooks.transform[i]\n\n\t\t\tconst endUnit = reporter.resolveChild(transform.fn.name)\n\n\t\t\tfnLiteral += isAsync(transform)\n\t\t\t\t? `transformed=await e.transform[${i}](c)\\n`\n\t\t\t\t: `transformed=e.transform[${i}](c)\\n`\n\n\t\t\tif (transform.subType === 'mapDerive')\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(transformed instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\tmapResponse('transformed') +\n\t\t\t\t\t`}else{` +\n\t\t\t\t\t`transformed.request=c.request\\n` +\n\t\t\t\t\t`transformed.store=c.store\\n` +\n\t\t\t\t\t`transformed.qi=c.qi\\n` +\n\t\t\t\t\t`transformed.path=c.path\\n` +\n\t\t\t\t\t`transformed.url=c.url\\n` +\n\t\t\t\t\t`transformed.redirect=c.redirect\\n` +\n\t\t\t\t\t`transformed.set=c.set\\n` +\n\t\t\t\t\t`transformed.error=c.error\\n` +\n\t\t\t\t\t`c=transformed` +\n\t\t\t\t\t'}'\n\t\t\telse\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(transformed instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\tmapResponse('transformed') +\n\t\t\t\t\t`}else Object.assign(c,transformed)\\n`\n\n\t\t\tendUnit()\n\t\t}\n\n\t\treporter.resolve()\n\t}\n\n\tconst fileUnions = <ElysiaTypeCheck<any>[]>[]\n\n\tif (validator) {\n\t\tif (validator.headers) {\n\t\t\tif (validator.headers.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tvalidator.headers.schema,\n\t\t\t\t\t\t{}\n\t\t\t\t\t) as Object\n\t\t\t\t)) {\n\t\t\t\t\tconst parsed =\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t\t: value\n\n\t\t\t\t\tif (parsed !== undefined)\n\t\t\t\t\t\tfnLiteral += `c.headers['${key}']??=${parsed}\\n`\n\t\t\t\t}\n\n\t\t\tfnLiteral += composeCleaner({\n\t\t\t\tname: 'c.headers',\n\t\t\t\tschema: validator.headers,\n\t\t\t\ttype: 'headers',\n\t\t\t\tnormalize\n\t\t\t})\n\n\t\t\tif (validator.headers.isOptional)\n\t\t\t\tfnLiteral += `if(isNotEmpty(c.headers)){`\n\n\t\t\tif (validator.body?.schema?.noValidate !== true)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.headers.Check(c.headers) === false){` +\n\t\t\t\t\tvalidation.validate('headers') +\n\t\t\t\t\t'}'\n\n\t\t\tif (validator.headers.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`c.headers=validator.headers.Decode(c.headers)\\n`,\n\t\t\t\t\t'headers'\n\t\t\t\t)\n\n\t\t\tif (validator.headers.isOptional) fnLiteral += '}'\n\t\t}\n\n\t\tif (validator.params) {\n\t\t\tif (validator.params.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tvalidator.params.schema,\n\t\t\t\t\t\t{}\n\t\t\t\t\t) as Object\n\t\t\t\t)) {\n\t\t\t\t\tconst parsed =\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t\t: value\n\n\t\t\t\t\tif (parsed !== undefined)\n\t\t\t\t\t\tfnLiteral += `c.params['${key}']??=${parsed}\\n`\n\t\t\t\t}\n\n\t\t\tif (validator.params?.schema?.noValidate !== true)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.params.Check(c.params)===false){` +\n\t\t\t\t\tvalidation.validate('params') +\n\t\t\t\t\t'}'\n\n\t\t\tif (validator.params.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`c.params=validator.params.Decode(c.params)\\n`,\n\t\t\t\t\t'params'\n\t\t\t\t)\n\t\t}\n\n\t\tif (validator.query) {\n\t\t\tif (validator.query.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tvalidator.query.schema,\n\t\t\t\t\t\t{}\n\t\t\t\t\t) as Object\n\t\t\t\t)) {\n\t\t\t\t\tconst parsed =\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t\t: value\n\n\t\t\t\t\tif (parsed !== undefined)\n\t\t\t\t\t\tfnLiteral += `if(c.query['${key}']===undefined)c.query['${key}']=${parsed}\\n`\n\n\t\t\t\t\tfnLiteral += composeCleaner({\n\t\t\t\t\t\tname: 'c.query',\n\t\t\t\t\t\tschema: validator.query,\n\t\t\t\t\t\ttype: 'query',\n\t\t\t\t\t\tnormalize\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\tif (validator.query.isOptional)\n\t\t\t\tfnLiteral += `if(isNotEmpty(c.query)){`\n\n\t\t\tif (validator.query?.schema?.noValidate !== true)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.query.Check(c.query)===false){` +\n\t\t\t\t\tvalidation.validate('query') +\n\t\t\t\t\t`}`\n\n\t\t\tif (validator.query.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`c.query=validator.query.Decode(Object.assign({},c.query))\\n`,\n\t\t\t\t\t'query'\n\t\t\t\t)\n\n\t\t\tif (validator.query.isOptional) fnLiteral += `}`\n\t\t}\n\n\t\tif (hasBody && validator.body) {\n\t\t\tif (validator.body.hasTransform || validator.body.isOptional)\n\t\t\t\tfnLiteral += `const isNotEmptyObject=c.body&&(typeof c.body===\"object\"&&(isNotEmpty(c.body)||c.body instanceof ArrayBuffer))\\n`\n\n\t\t\tconst hasUnion = isUnion(validator.body.schema)\n\t\t\tlet hasNonUnionFileWithDefault = false\n\n\t\t\tif (validator.body.hasDefault) {\n\t\t\t\tlet value = Value.Default(\n\t\t\t\t\tvalidator.body.schema,\n\t\t\t\t\tvalidator.body.schema.type === 'object' ||\n\t\t\t\t\t\t(validator.body.schema[Kind] === 'Import' &&\n\t\t\t\t\t\t\tvalidator.body.schema.$defs[\n\t\t\t\t\t\t\t\tvalidator.body.schema.$ref\n\t\t\t\t\t\t\t][Kind] === 'Object')\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: undefined\n\t\t\t\t)\n\n\t\t\t\tconst schema = unwrapImportSchema(validator.body.schema)\n\n\t\t\t\tif (\n\t\t\t\t\t!hasUnion &&\n\t\t\t\t\tvalue &&\n\t\t\t\t\ttypeof value === 'object' &&\n\t\t\t\t\t(hasType('File', schema) || hasType('Files', schema))\n\t\t\t\t) {\n\t\t\t\t\thasNonUnionFileWithDefault = true\n\n\t\t\t\t\tfor (const [k, v] of Object.entries(value))\n\t\t\t\t\t\tif (v === 'File' || v === 'Files')\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tdelete value[k]\n\n\t\t\t\t\tif (!isNotEmpty(value)) value = undefined\n\t\t\t\t}\n\n\t\t\t\tconst parsed =\n\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t: value\n\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\tif (Array.isArray(value))\n\t\t\t\t\t\tfnLiteral += `if(!c.body)c.body=${parsed}\\n`\n\t\t\t\t\telse if (typeof value === 'object')\n\t\t\t\t\t\tfnLiteral += `c.body=Object.assign(${parsed},c.body)\\n`\n\t\t\t\t\telse fnLiteral += `c.body=${parsed}\\n`\n\t\t\t\t}\n\n\t\t\t\tfnLiteral += composeCleaner({\n\t\t\t\t\tname: 'c.body',\n\t\t\t\t\tschema: validator.body,\n\t\t\t\t\ttype: 'body',\n\t\t\t\t\tnormalize\n\t\t\t\t})\n\n\t\t\t\tif (validator.body?.schema?.noValidate !== true) {\n\t\t\t\t\tif (validator.body.isOptional)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(isNotEmptyObject&&validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t'}'\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfnLiteral += composeCleaner({\n\t\t\t\t\tname: 'c.body',\n\t\t\t\t\tschema: validator.body,\n\t\t\t\t\ttype: 'body',\n\t\t\t\t\tnormalize\n\t\t\t\t})\n\n\t\t\t\tif (validator.body?.schema?.noValidate !== true) {\n\t\t\t\t\tif (validator.body.isOptional)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(isNotEmptyObject&&validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t'}'\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t'}'\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (validator.body.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)\\n`,\n\t\t\t\t\t'body'\n\t\t\t\t)\n\n\t\t\tif (hasUnion && validator.body.schema.anyOf?.length) {\n\t\t\t\tconst iterator = Object.values(\n\t\t\t\t\tvalidator.body.schema.anyOf\n\t\t\t\t) as TAnySchema[]\n\n\t\t\t\tfor (let i = 0; i < iterator.length; i++) {\n\t\t\t\t\tconst type = iterator[i]\n\n\t\t\t\t\tif (hasType('File', type) || hasType('Files', type)) {\n\t\t\t\t\t\tconst candidate = getSchemaValidator(type, {\n\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\tmodules: app.definitions.typebox,\n\t\t\t\t\t\t\tdynamic: !app.config.aot,\n\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\tmodels: app.definitions.type,\n\t\t\t\t\t\t\tnormalize: app.config.normalize,\n\t\t\t\t\t\t\tadditionalCoerce: coercePrimitiveRoot(),\n\t\t\t\t\t\t\tsanitize: () => app.config.sanitize\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif (candidate) {\n\t\t\t\t\t\t\tconst isFirst = fileUnions.length === 0\n\n\t\t\t\t\t\t\tconst iterator = Object.entries(\n\t\t\t\t\t\t\t\ttype.properties\n\t\t\t\t\t\t\t) as [string, TSchema][]\n\n\t\t\t\t\t\t\tlet validator = isFirst ? '\\n' : ' else '\n\t\t\t\t\t\t\tvalidator += `if(fileUnions[${fileUnions.length}].Check(c.body)){`\n\n\t\t\t\t\t\t\tlet validateFile = ''\n\t\t\t\t\t\t\tlet validatorLength = 0\n\t\t\t\t\t\t\tfor (let i = 0; i < iterator.length; i++) {\n\t\t\t\t\t\t\t\tconst [k, v] = iterator[i]\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!v.extension ||\n\t\t\t\t\t\t\t\t\t(v[Kind] !== 'File' && v[Kind] !== 'Files')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\t\tif (validatorLength) validateFile += ','\n\t\t\t\t\t\t\t\tvalidateFile += `validateFileExtension(c.body.${k},${JSON.stringify(v.extension)},'body.${k}')`\n\n\t\t\t\t\t\t\t\tvalidatorLength++\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (validateFile) {\n\t\t\t\t\t\t\t\tif (validatorLength === 1)\n\t\t\t\t\t\t\t\t\tvalidator += `await ${validateFile}\\n`\n\t\t\t\t\t\t\t\telse if (validatorLength > 1)\n\t\t\t\t\t\t\t\t\tvalidator += `await Promise.all([${validateFile}])\\n`\n\n\t\t\t\t\t\t\t\tvalidator += '}'\n\n\t\t\t\t\t\t\t\tfnLiteral += validator\n\t\t\t\t\t\t\t\tfileUnions.push(candidate)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\thasNonUnionFileWithDefault ||\n\t\t\t\t(!hasUnion &&\n\t\t\t\t\t(hasType(\n\t\t\t\t\t\t'File',\n\t\t\t\t\t\tunwrapImportSchema(validator.body.schema)\n\t\t\t\t\t) ||\n\t\t\t\t\t\thasType(\n\t\t\t\t\t\t\t'Files',\n\t\t\t\t\t\t\tunwrapImportSchema(validator.body.schema)\n\t\t\t\t\t\t)))\n\t\t\t) {\n\t\t\t\tlet validateFile = ''\n\n\t\t\t\tlet i = 0\n\t\t\t\tfor (const [k, v] of Object.entries(\n\t\t\t\t\tunwrapImportSchema(validator.body.schema).properties\n\t\t\t\t) as [string, TSchema][]) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!v.extension ||\n\t\t\t\t\t\t(v[Kind] !== 'File' && v[Kind] !== 'Files')\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif (i) validateFile += ','\n\t\t\t\t\tvalidateFile += `validateFileExtension(c.body.${k},${JSON.stringify(v.extension)},'body.${k}')`\n\n\t\t\t\t\ti++\n\t\t\t\t}\n\n\t\t\t\tif (i) fnLiteral += '\\n'\n\n\t\t\t\tif (i === 1) fnLiteral += `await ${validateFile}\\n`\n\t\t\t\telse if (i > 1)\n\t\t\t\t\tfnLiteral += `await Promise.all([${validateFile}])\\n`\n\t\t\t}\n\t\t}\n\n\t\tif (validator.cookie) {\n\t\t\t// ! Get latest app.config.cookie\n\t\t\tconst cookieValidator = getCookieValidator({\n\t\t\t\t// @ts-expect-error private property\n\t\t\t\tmodules: app.definitions.typebox,\n\t\t\t\tvalidator: validator.cookie as any,\n\t\t\t\tdefaultConfig: app.config.cookie,\n\t\t\t\tdynamic: !!app.config.aot,\n\t\t\t\tconfig: validator.cookie?.config ?? {},\n\t\t\t\tnormalize: app.config.normalize,\n\t\t\t\t// @ts-expect-error\n\t\t\t\tmodels: app.definitions.type\n\t\t\t})!\n\n\t\t\tfnLiteral +=\n\t\t\t\t`const cookieValue={}\\n` +\n\t\t\t\t`for(const [key,value] of Object.entries(c.cookie))` +\n\t\t\t\t`cookieValue[key]=value.value\\n`\n\n\t\t\tif (cookieValidator.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(cookieValidator.schema, {}) as Object\n\t\t\t\t)) {\n\t\t\t\t\tfnLiteral += `cookieValue['${key}'] = ${\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: value\n\t\t\t\t\t}\\n`\n\t\t\t\t}\n\n\t\t\tif (cookieValidator.isOptional)\n\t\t\t\tfnLiteral += `if(isNotEmpty(c.cookie)){`\n\n\t\t\tif (validator.body?.schema?.noValidate !== true) {\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.cookie.Check(cookieValue)===false){` +\n\t\t\t\t\tvalidation.validate('cookie', 'cookieValue') +\n\t\t\t\t\t'}'\n\t\t\t}\n\n\t\t\tif (cookieValidator.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))` +\n\t\t\t\t\t\t`c.cookie[key].value=value\\n`,\n\t\t\t\t\t'cookie'\n\t\t\t\t)\n\n\t\t\tif (cookieValidator.isOptional) fnLiteral += `}`\n\t\t}\n\t}\n\n\tif (hooks?.beforeHandle) {\n\t\tconst reporter = report('beforeHandle', {\n\t\t\ttotal: hooks.beforeHandle.length\n\t\t})\n\n\t\tlet hasResolve = false\n\n\t\tfor (let i = 0; i < hooks.beforeHandle.length; i++) {\n\t\t\tconst beforeHandle = hooks.beforeHandle[i]\n\n\t\t\tconst endUnit = reporter.resolveChild(beforeHandle.fn.name)\n\n\t\t\tconst returning = hasReturn(beforeHandle)\n\t\t\tconst isResolver =\n\t\t\t\tbeforeHandle.subType === 'resolve' ||\n\t\t\t\tbeforeHandle.subType === 'mapResolve'\n\n\t\t\tif (isResolver) {\n\t\t\t\tif (!hasResolve) {\n\t\t\t\t\thasResolve = true\n\t\t\t\t\tfnLiteral += '\\nlet resolved\\n'\n\t\t\t\t}\n\n\t\t\t\tfnLiteral += isAsync(beforeHandle)\n\t\t\t\t\t? `resolved=await e.beforeHandle[${i}](c);\\n`\n\t\t\t\t\t: `resolved=e.beforeHandle[${i}](c);\\n`\n\n\t\t\t\tif (beforeHandle.subType === 'mapResolve')\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`if(resolved instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\tmapResponse('resolved') +\n\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t`resolved.request=c.request\\n` +\n\t\t\t\t\t\t`resolved.store=c.store\\n` +\n\t\t\t\t\t\t`resolved.qi=c.qi\\n` +\n\t\t\t\t\t\t`resolved.path=c.path\\n` +\n\t\t\t\t\t\t`resolved.url=c.url\\n` +\n\t\t\t\t\t\t`resolved.redirect=c.redirect\\n` +\n\t\t\t\t\t\t`resolved.set=c.set\\n` +\n\t\t\t\t\t\t`resolved.error=c.error\\n` +\n\t\t\t\t\t\t`c=resolved` +\n\t\t\t\t\t\t`}`\n\t\t\t\telse\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`if(resolved instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\tmapResponse('resolved') +\n\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t`else Object.assign(c, resolved)\\n`\n\t\t\t} else if (!returning) {\n\t\t\t\tfnLiteral += isAsync(beforeHandle)\n\t\t\t\t\t? `await e.beforeHandle[${i}](c)\\n`\n\t\t\t\t\t: `e.beforeHandle[${i}](c)\\n`\n\n\t\t\t\tendUnit()\n\t\t\t} else {\n\t\t\t\tfnLiteral += isAsync(beforeHandle)\n\t\t\t\t\t? `be=await e.beforeHandle[${i}](c)\\n`\n\t\t\t\t\t: `be=e.beforeHandle[${i}](c)\\n`\n\n\t\t\t\tendUnit('be')\n\n\t\t\t\tfnLiteral += `if(be!==undefined){`\n\t\t\t\treporter.resolve()\n\n\t\t\t\tif (hooks.afterHandle?.length) {\n\t\t\t\t\treport('handle', {\n\t\t\t\t\t\tname: isHandleFn\n\t\t\t\t\t\t\t? (handler as Function).name\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}).resolve()\n\n\t\t\t\t\tconst reporter = report('afterHandle', {\n\t\t\t\t\t\ttotal: hooks.afterHandle.length\n\t\t\t\t\t})\n\n\t\t\t\t\tfor (let i = 0; i < hooks.afterHandle.length; i++) {\n\t\t\t\t\t\tconst hook = hooks.afterHandle[i]\n\t\t\t\t\t\tconst returning = hasReturn(hook)\n\t\t\t\t\t\tconst endUnit = reporter.resolveChild(hook.fn.name)\n\n\t\t\t\t\t\tfnLiteral += `c.response = be\\n`\n\n\t\t\t\t\t\tif (!returning) {\n\t\t\t\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t\t\t\t? `await e.afterHandle[${i}](c, be)\\n`\n\t\t\t\t\t\t\t\t: `e.afterHandle[${i}](c, be)\\n`\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t\t\t\t? `af=await e.afterHandle[${i}](c)\\n`\n\t\t\t\t\t\t\t\t: `af=e.afterHandle[${i}](c)\\n`\n\n\t\t\t\t\t\t\tfnLiteral += `if(af!==undefined) c.response=be=af\\n`\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tendUnit('af')\n\t\t\t\t\t}\n\t\t\t\t\treporter.resolve()\n\t\t\t\t}\n\n\t\t\t\tif (validator.response) fnLiteral += validation.response('be')\n\n\t\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t\t})\n\n\t\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\t\tfnLiteral += `c.response=be\\n`\n\n\t\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(mr===undefined){` +\n\t\t\t\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t\t`if(mr!==undefined)be=c.response=mr` +\n\t\t\t\t\t\t\t'}'\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmapResponseReporter.resolve()\n\n\t\t\t\tfnLiteral += encodeCookie()\n\t\t\t\tfnLiteral += `return mapEarlyResponse(${saveResponse}be,c.set${\n\t\t\t\t\tmapResponseContext\n\t\t\t\t})}\\n`\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\t}\n\n\tif (hooks.afterHandle?.length) {\n\t\tconst handleReporter = report('handle', {\n\t\t\tname: isHandleFn ? (handler as Function).name : undefined\n\t\t})\n\n\t\tif (hooks.afterHandle.length)\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=c.response=await ${handle}\\n`\n\t\t\t\t: `let r=c.response=${handle}\\n`\n\t\telse\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=await ${handle}\\n`\n\t\t\t\t: `let r=${handle}\\n`\n\n\t\thandleReporter.resolve()\n\n\t\tconst reporter = report('afterHandle', {\n\t\t\ttotal: hooks.afterHandle.length\n\t\t})\n\n\t\tfor (let i = 0; i < hooks.afterHandle.length; i++) {\n\t\t\tconst hook = hooks.afterHandle[i]\n\t\t\tconst returning = hasReturn(hook)\n\t\t\tconst endUnit = reporter.resolveChild(hook.fn.name)\n\n\t\t\tif (!returning) {\n\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t? `await e.afterHandle[${i}](c)\\n`\n\t\t\t\t\t: `e.afterHandle[${i}](c)\\n`\n\n\t\t\t\tendUnit()\n\t\t\t} else {\n\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t? `af=await e.afterHandle[${i}](c)\\n`\n\t\t\t\t\t: `af=e.afterHandle[${i}](c)\\n`\n\n\t\t\t\tendUnit('af')\n\n\t\t\t\tif (validator.response) {\n\t\t\t\t\tfnLiteral += `if(af!==undefined){`\n\t\t\t\t\treporter.resolve()\n\n\t\t\t\t\tfnLiteral += validation.response('af')\n\n\t\t\t\t\tfnLiteral += `c.response=af}`\n\t\t\t\t} else {\n\t\t\t\t\tfnLiteral += `if(af!==undefined){`\n\t\t\t\t\treporter.resolve()\n\n\t\t\t\t\tfnLiteral += `c.response=af}`\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\n\t\tfnLiteral += `r=c.response\\n`\n\n\t\tif (validator.response) fnLiteral += validation.response()\n\n\t\tfnLiteral += encodeCookie()\n\n\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\ttotal: hooks.mapResponse?.length\n\t\t})\n\t\tif (hooks.mapResponse?.length) {\n\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t)\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`mr=${\n\t\t\t\t\t\tisAsyncName(mapResponse) ? 'await ' : ''\n\t\t\t\t\t}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t`if(mr!==undefined)r=c.response=mr\\n`\n\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\t\tmapResponseReporter.resolve()\n\n\t\tfnLiteral += mapResponse()\n\t} else {\n\t\tconst handleReporter = report('handle', {\n\t\t\tname: isHandleFn ? (handler as Function).name : undefined\n\t\t})\n\n\t\tif (validator.response || hooks.mapResponse?.length) {\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=await ${handle}\\n`\n\t\t\t\t: `let r=${handle}\\n`\n\n\t\t\thandleReporter.resolve()\n\n\t\t\tif (validator.response) fnLiteral += validation.response()\n\n\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t})\n\n\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\tfnLiteral += '\\nc.response=r\\n'\n\n\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t)\n\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`\\nif(mr===undefined){` +\n\t\t\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t`if(mr!==undefined)r=c.response=mr` +\n\t\t\t\t\t\t`}\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapResponseReporter.resolve()\n\n\t\t\tfnLiteral += encodeCookie()\n\n\t\t\tif (handler instanceof Response) {\n\t\t\t\tfnLiteral += afterResponse()\n\n\t\t\t\tfnLiteral += inference.set\n\t\t\t\t\t? `if(` +\n\t\t\t\t\t\t`isNotEmpty(c.set.headers)||` +\n\t\t\t\t\t\t`c.set.status!==200||` +\n\t\t\t\t\t\t`c.set.redirect||` +\n\t\t\t\t\t\t`c.set.cookie)return mapResponse(${saveResponse}${handle}.clone(),c.set${\n\t\t\t\t\t\t\tmapResponseContext\n\t\t\t\t\t\t})\\n` +\n\t\t\t\t\t\t`else return ${handle}.clone()`\n\t\t\t\t\t: `return ${handle}.clone()`\n\n\t\t\t\tfnLiteral += '\\n'\n\t\t\t} else fnLiteral += mapResponse()\n\t\t} else if (hasCookie || hasTrace) {\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=await ${handle}\\n`\n\t\t\t\t: `let r=${handle}\\n`\n\n\t\t\thandleReporter.resolve()\n\n\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t})\n\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\tfnLiteral += 'c.response= r\\n'\n\n\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t)\n\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`if(mr===undefined){` +\n\t\t\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t`if(mr!==undefined)r=c.response=mr` +\n\t\t\t\t\t\t`}`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapResponseReporter.resolve()\n\n\t\t\tfnLiteral += encodeCookie() + mapResponse()\n\t\t} else {\n\t\t\thandleReporter.resolve()\n\n\t\t\tconst handled = isAsyncHandler ? `await ${handle}` : handle\n\n\t\t\tif (handler instanceof Response) {\n\t\t\t\tfnLiteral += afterResponse()\n\n\t\t\t\tfnLiteral += inference.set\n\t\t\t\t\t? `if(isNotEmpty(c.set.headers)||` +\n\t\t\t\t\t\t`c.set.status!==200||` +\n\t\t\t\t\t\t`c.set.redirect||` +\n\t\t\t\t\t\t`c.set.cookie)` +\n\t\t\t\t\t\t`return mapResponse(${saveResponse}${handle}.clone(),c.set${\n\t\t\t\t\t\t\tmapResponseContext\n\t\t\t\t\t\t})\\n` +\n\t\t\t\t\t\t`else return ${handle}.clone()\\n`\n\t\t\t\t\t: `return ${handle}.clone()\\n`\n\t\t\t} else fnLiteral += mapResponse(handled)\n\t\t}\n\t}\n\n\tfnLiteral += `\\n}catch(error){`\n\n\tif (!maybeAsync && hooks.error?.length) fnLiteral += `return(async()=>{`\n\tfnLiteral +=\n\t\t`const set=c.set\\n` +\n\t\t`if(!set.status||set.status<300)set.status=error?.status||500\\n`\n\n\tif (hasCookie) fnLiteral += encodeCookie()\n\n\tif (hasTrace && hooks.trace)\n\t\tfor (let i = 0; i < hooks.trace.length; i++)\n\t\t\t// There's a case where the error is thrown before any trace is called\n\t\t\tfnLiteral += `report${i}?.resolve(error);reportChild${i}?.(error)\\n`\n\n\tconst errorReporter = report('error', {\n\t\ttotal: hooks.error?.length\n\t})\n\n\tif (hooks.error?.length) {\n\t\tfnLiteral += `c.error=error\\n`\n\n\t\tif (hasValidation)\n\t\t\tfnLiteral +=\n\t\t\t\t`if(error instanceof TypeBoxError){` +\n\t\t\t\t'c.code=\"VALIDATION\"\\n' +\n\t\t\t\t'c.set.status=422' +\n\t\t\t\t'}else{' +\n\t\t\t\t`c.code=error.code??error[ERROR_CODE]??\"UNKNOWN\"}`\n\t\telse fnLiteral += `c.code=error.code??error[ERROR_CODE]??\"UNKNOWN\"\\n`\n\n\t\tfnLiteral += `let er\\n`\n\t\t// Mapped error Response\n\t\tif (hooks.mapResponse?.length) fnLiteral += 'let mep\\n'\n\n\t\tfor (let i = 0; i < hooks.error.length; i++) {\n\t\t\tconst endUnit = errorReporter.resolveChild(hooks.error[i].fn.name)\n\n\t\t\tif (isAsync(hooks.error[i]))\n\t\t\t\tfnLiteral += `er=await e.error[${i}](c)\\n`\n\t\t\telse\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`er=e.error[${i}](c)\\n` +\n\t\t\t\t\t`if(er instanceof Promise)er=await er\\n`\n\n\t\t\tendUnit()\n\n\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t\t})\n\n\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t)\n\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`c.response=er\\n` +\n\t\t\t\t\t\t`mep=e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t`if(mep instanceof Promise)er=await er\\n` +\n\t\t\t\t\t\t`if(mep!==undefined)er=mep\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t}\n\t\t\t\tmapResponseReporter.resolve()\n\t\t\t}\n\n\t\t\tfnLiteral += `er=mapEarlyResponse(er,set${mapResponseContext})\\n`\n\t\t\tfnLiteral += `if(er){`\n\n\t\t\tif (hasTrace && hooks.trace) {\n\t\t\t\tfor (let i = 0; i < hooks.trace.length; i++)\n\t\t\t\t\tfnLiteral += `report${i}.resolve()\\n`\n\n\t\t\t\terrorReporter.resolve()\n\t\t\t}\n\n\t\t\tfnLiteral += `return er}`\n\t\t}\n\t}\n\n\terrorReporter.resolve()\n\n\tfnLiteral += `return handleError(c,error,true)`\n\tif (!maybeAsync && hooks.error?.length) fnLiteral += '})()'\n\tfnLiteral += '}'\n\n\tconst adapterVariables = adapter.inject\n\t\t? Object.keys(adapter.inject).join(',') + ','\n\t\t: ''\n\n\tlet init =\n\t\t`const {` +\n\t\t`handler,` +\n\t\t`handleError,` +\n\t\t`hooks:e, ` +\n\t\tallocateIf(`validator,`, hasValidation) +\n\t\t`mapResponse,` +\n\t\t`mapCompactResponse,` +\n\t\t`mapEarlyResponse,` +\n\t\t`isNotEmpty,` +\n\t\t`utils:{` +\n\t\tallocateIf(`parseQuery,`, hasBody) +\n\t\tallocateIf(`parseQueryFromURL,`, hasQuery) +\n\t\t`},` +\n\t\t`error:{` +\n\t\tallocateIf(`ValidationError,`, hasValidation) +\n\t\tallocateIf(`ParseError`, hasBody) +\n\t\t`},` +\n\t\t`validateFileExtension,` +\n\t\t`schema,` +\n\t\t`definitions,` +\n\t\t`ERROR_CODE,` +\n\t\tallocateIf(`parseCookie,`, hasCookie) +\n\t\tallocateIf(`signCookie,`, hasCookie) +\n\t\tallocateIf(`decodeURIComponent,`, hasQuery) +\n\t\t`ElysiaCustomStatusResponse,` +\n\t\tallocateIf(`ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tallocateIf('parser,', hooks.parse?.length) +\n\t\tallocateIf(`getServer,`, inference.server) +\n\t\tallocateIf(`fileUnions,`, fileUnions.length) +\n\t\tadapterVariables +\n\t\tallocateIf('TypeBoxError', hasValidation) +\n\t\t`}=hooks\\n` +\n\t\t`const trace=e.trace\\n` +\n\t\t`return ${maybeAsync ? 'async ' : ''}function handle(c){`\n\n\tif (hooks.beforeHandle?.length) init += 'let be\\n'\n\tif (hooks.afterHandle?.length) init += 'let af\\n'\n\tif (hooks.mapResponse?.length) init += 'let mr\\n'\n\tif (allowMeta) init += 'c.schema=schema\\nc.defs=definitions\\n'\n\n\tfnLiteral = init + fnLiteral + '}'\n\tinit = ''\n\n\ttry {\n\t\treturn Function(\n\t\t\t'hooks',\n\t\t\t'\"use strict\";\\n' + fnLiteral\n\t\t)({\n\t\t\thandler,\n\t\t\thooks: lifeCycleToFn(hooks),\n\t\t\tvalidator: hasValidation ? validator : undefined,\n\t\t\t// @ts-expect-error\n\t\t\thandleError: app.handleError,\n\t\t\tmapResponse: adapterHandler.mapResponse,\n\t\t\tmapCompactResponse: adapterHandler.mapCompactResponse,\n\t\t\tmapEarlyResponse: adapterHandler.mapEarlyResponse,\n\t\t\tisNotEmpty,\n\t\t\tutils: {\n\t\t\t\tparseQuery: hasBody ? parseQuery : undefined,\n\t\t\t\tparseQueryFromURL: hasQuery ? parseQueryFromURL : undefined\n\t\t\t},\n\t\t\terror: {\n\t\t\t\tValidationError: hasValidation ? ValidationError : undefined,\n\t\t\t\tParseError: hasBody ? ParseError : undefined\n\t\t\t},\n\t\t\tvalidateFileExtension,\n\t\t\tschema: app.router.history,\n\t\t\t// @ts-expect-error\n\t\t\tdefinitions: app.definitions.type,\n\t\t\tERROR_CODE,\n\t\t\tparseCookie: hasCookie ? parseCookie : undefined,\n\t\t\tsignCookie: hasCookie ? signCookie : undefined,\n\t\t\tdecodeURIComponent: hasQuery ? decode : undefined,\n\t\t\tElysiaCustomStatusResponse,\n\t\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\t\t// @ts-expect-error private property\n\t\t\tgetServer: inference.server ? () => app.getServer() : undefined,\n\t\t\tfileUnions: fileUnions.length ? fileUnions : undefined,\n\t\t\tTypeBoxError: hasValidation ? TypeBoxError : undefined,\n\t\t\tparser: app['~parser'],\n\t\t\t...adapter.inject\n\t\t})\n\t} catch (error) {\n\t\tconst debugHooks = lifeCycleToFn(hooks)\n\n\t\tconsole.log('[Composer] failed to generate optimized handler')\n\t\tconsole.log('---')\n\t\tconsole.log({\n\t\t\thandler:\n\t\t\t\ttypeof handler === 'function' ? handler.toString() : handler,\n\t\t\tinstruction: fnLiteral,\n\t\t\thooks: {\n\t\t\t\t...debugHooks,\n\t\t\t\t// @ts-ignore\n\t\t\t\ttransform: debugHooks?.transform?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\tresolve: debugHooks?.resolve?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\tbeforeHandle: debugHooks?.beforeHandle?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tafterHandle: debugHooks?.afterHandle?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tmapResponse: debugHooks?.mapResponse?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tparse: debugHooks?.parse?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\terror: debugHooks?.error?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\tafterResponse: debugHooks?.afterResponse?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tstop: debugHooks?.stop?.map?.((x) => x.toString())\n\t\t\t},\n\t\t\tvalidator,\n\t\t\t// @ts-expect-error\n\t\t\tdefinitions: app.definitions.type,\n\t\t\terror\n\t\t})\n\t\tconsole.log('---')\n\n\t\tprocess.exit(1)\n\t}\n}\n\nexport interface ComposerGeneralHandlerOptions {\n\t/**\n\t * optimization for standard internet hostname\n\t * this will assume hostname is always use a standard internet hostname\n\t * assuming hostname is at minimum of 11 length of string (http://a.bc)\n\t *\n\t * setting this to true will skip the first 11 character of the hostname\n\t *\n\t * @default true\n\t */\n\tstandardHostname?: boolean\n}\n\nexport const createOnRequestHandler = (\n\tapp: AnyElysia,\n\taddFn?: (word: string) => void\n) => {\n\tlet fnLiteral = ''\n\n\tconst report = createReport({\n\t\ttrace: app.event.trace,\n\t\taddFn:\n\t\t\taddFn ??\n\t\t\t((word) => {\n\t\t\t\tfnLiteral += word\n\t\t\t})\n\t})\n\n\tconst reporter = report('request', {\n\t\ttotal: app.event.request?.length\n\t})\n\n\tif (app.event.request?.length) {\n\t\tfnLiteral += `try{`\n\n\t\tfor (let i = 0; i < app.event.request.length; i++) {\n\t\t\tconst hook = app.event.request[i]\n\t\t\tconst withReturn = hasReturn(hook)\n\t\t\tconst maybeAsync = isAsync(hook)\n\n\t\t\tconst endUnit = reporter.resolveChild(app.event.request[i].fn.name)\n\n\t\t\tif (withReturn) {\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`re=mapEarlyResponse(` +\n\t\t\t\t\t`${maybeAsync ? 'await ' : ''}onRequest[${i}](c),` +\n\t\t\t\t\t`c.set)\\n`\n\n\t\t\t\tendUnit('re')\n\t\t\t\tfnLiteral += `if(re!==undefined)return re\\n`\n\t\t\t} else {\n\t\t\t\tfnLiteral += `${maybeAsync ? 'await ' : ''}onRequest[${i}](c)\\n`\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\n\t\tfnLiteral += `}catch(error){return app.handleError(c,error,false)}`\n\t}\n\n\treporter.resolve()\n\n\treturn fnLiteral\n}\n\nexport const createHoc = (app: AnyElysia, fnName = 'map') => {\n\t// @ts-expect-error private property\n\tconst hoc = app.extender.higherOrderFunctions\n\n\tif (!hoc.length) return 'return ' + fnName\n\n\tconst adapter = app['~adapter'].composeGeneralHandler\n\n\tlet handler = fnName\n\n\tfor (let i = 0; i < hoc.length; i++)\n\t\thandler = `hoc[${i}](${handler},${adapter.parameters})`\n\n\treturn `return function hocMap(${adapter.parameters}){return ${handler}(${adapter.parameters})}`\n}\n\nexport const composeGeneralHandler = (app: AnyElysia) => {\n\tconst adapter = app['~adapter'].composeGeneralHandler\n\tapp.router.http.build()\n\n\tconst hasTrace = app.event.trace?.length\n\n\tlet fnLiteral = ''\n\n\tconst router = app.router\n\n\tlet findDynamicRoute = router.http.root.WS\n\t\t? `const route=router.find(r.method === \"GET\" && r.headers.get('upgrade')==='websocket'?'WS':r.method,p)`\n\t\t: `const route=router.find(r.method,p)`\n\n\tfindDynamicRoute += router.http.root.ALL ? '??router.find(\"ALL\",p)\\n' : '\\n'\n\n\tlet afterResponse = `c.error=notFound\\n`\n\tif (app.event.afterResponse?.length && !app.event.error) {\n\t\tconst prefix = app.event.afterResponse.some(isAsync) ? 'async' : ''\n\t\tafterResponse += `\\nsetImmediate(${prefix}()=>{`\n\n\t\tfor (let i = 0; i < app.event.afterResponse.length; i++) {\n\t\t\tconst fn = app.event.afterResponse[i].fn\n\n\t\t\tafterResponse += `\\n${isAsyncName(fn) ? 'await ' : ''}afterResponse[${i}](c)\\n`\n\t\t}\n\n\t\tafterResponse += `})\\n`\n\t}\n\n\t// @ts-ignore\n\tif (app.inference.query)\n\t\tafterResponse +=\n\t\t\t'if(c.qi===-1){' +\n\t\t\t'c.query={}' +\n\t\t\t'}else{' +\n\t\t\t'c.query=parseQueryFromURL(c.url,c.qi+1)' +\n\t\t\t'}'\n\n\tconst error404 = adapter.error404(\n\t\t!!app.event.request?.length,\n\t\t!!app.event.error?.length,\n\t\tafterResponse\n\t)\n\n\tfindDynamicRoute += error404.code\n\n\tfindDynamicRoute +=\n\t\t`\\nc.params=route.params\\n` +\n\t\t`if(route.store.handler)return route.store.handler(c)\\n` +\n\t\t`return route.store.compile()(c)\\n`\n\n\tlet switchMap = ''\n\tfor (const [path, methods] of Object.entries(router.static)) {\n\t\tswitchMap += `case'${path}':`\n\n\t\tif (app.config.strictPath !== true)\n\t\t\tswitchMap += `case'${getLoosePath(path)}':`\n\n\t\tconst encoded = encodePath(path)\n\t\tif (path !== encoded) switchMap += `case'${encoded}':`\n\n\t\tswitchMap += 'switch(r.method){'\n\n\t\tif ('GET' in methods || 'WS' in methods) {\n\t\t\tswitchMap += `case 'GET':`\n\n\t\t\tif ('WS' in methods)\n\t\t\t\tswitchMap +=\n\t\t\t\t\t`if(r.headers.get('upgrade')==='websocket')` +\n\t\t\t\t\t`return ht[${methods.WS}].composed(c)\\n`\n\n\t\t\tif ('GET' in methods)\n\t\t\t\tswitchMap += `return ht[${methods.GET}].composed(c)\\n`\n\t\t}\n\n\t\tfor (const [method, index] of Object.entries(methods)) {\n\t\t\tif (method === 'ALL' || method === 'GET' || method === 'WS')\n\t\t\t\tcontinue\n\n\t\t\tswitchMap += `case '${method}':return ht[${index}].composed(c)\\n`\n\t\t}\n\n\t\tif ('ALL' in methods)\n\t\t\tswitchMap += `default:return ht[${methods.ALL}].composed(c)\\n`\n\t\telse switchMap += `default:break map\\n`\n\n\t\tswitchMap += '}'\n\t}\n\n\tconst maybeAsync = !!app.event.request?.some(isAsync)\n\n\tconst adapterVariables = adapter.inject\n\t\t? Object.keys(adapter.inject).join(',') + ','\n\t\t: ''\n\n\tfnLiteral +=\n\t\t`\\nconst {` +\n\t\t`app,` +\n\t\t`mapEarlyResponse,` +\n\t\t`NotFoundError,` +\n\t\t`randomId,` +\n\t\t`handleError,` +\n\t\t`status,` +\n\t\t`redirect,` +\n\t\t// @ts-ignore\n\t\tallocateIf(`parseQueryFromURL,`, app.inference.query) +\n\t\tallocateIf(`ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tadapterVariables +\n\t\t`}=data\\n` +\n\t\t`const store=app.singleton.store\\n` +\n\t\t`const decorator=app.singleton.decorator\\n` +\n\t\t`const staticRouter=app.router.static.http\\n` +\n\t\t`const ht=app.router.history\\n` +\n\t\t`const router=app.router.http\\n` +\n\t\t`const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[]\\n` +\n\t\t`const notFound=new NotFoundError()\\n` +\n\t\t`const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)\\n`\n\n\tif (app.event.request?.length)\n\t\tfnLiteral += `const onRequest=app.event.request.map(x=>x.fn)\\n`\n\n\tif (app.event.afterResponse?.length)\n\t\tfnLiteral += `const afterResponse=app.event.afterResponse.map(x=>x.fn)\\n`\n\n\tfnLiteral += error404.declare\n\n\tif (app.event.trace?.length)\n\t\tfnLiteral +=\n\t\t\t`const ` +\n\t\t\tapp.event.trace\n\t\t\t\t.map((_, i) => `tr${i}=app.event.trace[${i}].fn`)\n\t\t\t\t.join(',') +\n\t\t\t'\\n'\n\n\tfnLiteral += `${maybeAsync ? 'async ' : ''}function map(${adapter.parameters}){`\n\n\tif (app.event.request?.length) fnLiteral += `let re\\n`\n\n\tfnLiteral += adapter.createContext(app)\n\n\tif (app.event.trace?.length)\n\t\tfnLiteral +=\n\t\t\t`c[ELYSIA_TRACE]=[` +\n\t\t\tapp.event.trace.map((_, i) => `tr${i}(c)`).join(',') +\n\t\t\t`]\\n`\n\n\tfnLiteral += createOnRequestHandler(app)\n\n\tif (switchMap) fnLiteral += `\\nmap: switch(p){\\n` + switchMap + `}`\n\n\tfnLiteral += findDynamicRoute + `}\\n` + createHoc(app)\n\n\tconst handleError = composeErrorHandler(app)\n\n\t// @ts-expect-error private property\n\tapp.handleError = handleError\n\n\tconst fn = Function(\n\t\t'data',\n\t\t'\"use strict\";\\n' + fnLiteral\n\t)({\n\t\tapp,\n\t\tmapEarlyResponse: app['~adapter']['handler'].mapEarlyResponse,\n\t\tNotFoundError,\n\t\trandomId,\n\t\thandleError,\n\t\tstatus,\n\t\tredirect,\n\t\t// @ts-ignore\n\t\tparseQueryFromURL: app.inference.query ? parseQueryFromURL : undefined,\n\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\t...adapter.inject\n\t})\n\n\tif (isBun) Bun.gc(false)\n\n\treturn fn\n}\n\nexport const composeErrorHandler = (app: AnyElysia) => {\n\tconst hooks = app.event\n\tlet fnLiteral = ''\n\n\tconst adapter = app['~adapter'].composeError\n\tconst adapterVariables = adapter.inject\n\t\t? Object.keys(adapter.inject).join(',') + ','\n\t\t: ''\n\n\tconst hasTrace = !!app.event.trace?.length\n\n\tfnLiteral +=\n\t\t`const {` +\n\t\t`mapResponse,` +\n\t\t`ERROR_CODE,` +\n\t\t`ElysiaCustomStatusResponse,` +\n\t\tallocateIf(`onError,`, app.event.error) +\n\t\tallocateIf(`afterResponse,`, app.event.afterResponse) +\n\t\tallocateIf(`trace,`, app.event.trace) +\n\t\tallocateIf(`onMapResponse,`, app.event.mapResponse) +\n\t\tallocateIf(`ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tadapterVariables +\n\t\t`}=inject\\n`\n\n\tfnLiteral += `return ${\n\t\tapp.event.error?.find(isAsync) || app.event.mapResponse?.find(isAsync)\n\t\t\t? 'async '\n\t\t\t: ''\n\t}function(context,error,skipGlobal){`\n\n\tfnLiteral += ''\n\n\tif (hasTrace) fnLiteral += 'const id=context[ELYSIA_REQUEST_ID]\\n'\n\n\tconst report = createReport({\n\t\tcontext: 'context',\n\t\ttrace: hooks.trace,\n\t\taddFn: (word) => {\n\t\t\tfnLiteral += word\n\t\t}\n\t})\n\n\tconst afterResponse = () => {\n\t\tif (!hooks.afterResponse?.length) return ''\n\n\t\tlet afterResponse = ''\n\t\tconst prefix = hooks.afterResponse.some(isAsync) ? 'async' : ''\n\t\tafterResponse += `\\nsetImmediate(${prefix}()=>{`\n\n\t\tconst reporter = report('afterResponse', {\n\t\t\ttotal: hooks.afterResponse?.length,\n\t\t\tname: 'context'\n\t\t})\n\n\t\tfor (let i = 0; i < hooks.afterResponse.length; i++) {\n\t\t\tconst fn = hooks.afterResponse[i].fn\n\t\t\tconst endUnit = reporter.resolveChild(fn.name)\n\n\t\t\tafterResponse += `\\n${isAsyncName(fn) ? 'await ' : ''}afterResponse[${i}](context)\\n`\n\n\t\t\tendUnit()\n\t\t}\n\n\t\tafterResponse += `})\\n`\n\n\t\treporter.resolve()\n\n\t\treturn afterResponse\n\t}\n\n\tfnLiteral +=\n\t\t`const set=context.set\\n` +\n\t\t`let _r\\n` +\n\t\t`if(!context.code)context.code=error.code??error[ERROR_CODE]\\n` +\n\t\t`if(!(context.error instanceof Error))context.error=error\\n` +\n\t\t`if(error instanceof ElysiaCustomStatusResponse){` +\n\t\t`set.status=error.status=error.code\\n` +\n\t\t`error.message=error.response` +\n\t\t`}`\n\n\tif (adapter.declare) fnLiteral += adapter.declare\n\n\tconst saveResponse =\n\t\thasTrace ||\n\t\t!!hooks.afterResponse?.length ||\n\t\t!!hooks.afterResponse?.length\n\t\t\t? 'context.response = '\n\t\t\t: ''\n\n\tif (app.event.error)\n\t\tfor (let i = 0; i < app.event.error.length; i++) {\n\t\t\tconst handler = app.event.error[i]\n\n\t\t\tconst response = `${\n\t\t\t\tisAsync(handler) ? 'await ' : ''\n\t\t\t}onError[${i}](context)\\n`\n\n\t\t\tfnLiteral += 'if(skipGlobal!==true){'\n\n\t\t\tif (hasReturn(handler)) {\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`_r=${response}\\nif(_r!==undefined){` +\n\t\t\t\t\t`if(_r instanceof Response){` +\n\t\t\t\t\tafterResponse() +\n\t\t\t\t\t`return mapResponse(_r,set${adapter.mapResponseContext})}` +\n\t\t\t\t\t`if(_r instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t`error.status=error.code\\n` +\n\t\t\t\t\t`error.message = error.response` +\n\t\t\t\t\t`}` +\n\t\t\t\t\t`if(set.status===200||!set.status)set.status=error.status\\n`\n\n\t\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\t\ttotal: hooks.mapResponse?.length,\n\t\t\t\t\tname: 'context'\n\t\t\t\t})\n\n\t\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`context.response=_r` +\n\t\t\t\t\t\t\t`_r=${isAsyncName(mapResponse) ? 'await ' : ''}onMapResponse[${i}](context)\\n`\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmapResponseReporter.resolve()\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\tafterResponse() +\n\t\t\t\t\t`return mapResponse(${saveResponse}_r,set${adapter.mapResponseContext})}`\n\t\t\t} else fnLiteral += response\n\n\t\t\tfnLiteral += '}'\n\t\t}\n\n\tfnLiteral +=\n\t\t`if(error.constructor.name===\"ValidationError\"||error.constructor.name===\"TransformDecodeError\"){\\n` +\n\t\t`if(error.error)error=error.error\\n` +\n\t\t`set.status=error.status??422\\n` +\n\t\tafterResponse() +\n\t\tadapter.validationError +\n\t\t`\\n}\\n`\n\n\tfnLiteral +=\n\t\t`if(error instanceof Error){` +\n\t\tafterResponse() +\n\t\t`\\nif(typeof error.toResponse==='function')return context.response=error.toResponse()\\n` +\n\t\tadapter.unknownError +\n\t\t`\\n}`\n\n\tconst mapResponseReporter = report('mapResponse', {\n\t\ttotal: hooks.mapResponse?.length,\n\t\tname: 'context'\n\t})\n\n\tfnLiteral +=\n\t\t'\\nif(!context.response)context.response=error.message??error\\n'\n\n\tif (hooks.mapResponse?.length) {\n\t\tfnLiteral += 'let mr\\n'\n\n\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\tmapResponse.fn.name\n\t\t\t)\n\n\t\t\tfnLiteral +=\n\t\t\t\t`if(mr===undefined){` +\n\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}onMapResponse[${i}](context)\\n` +\n\t\t\t\t`if(mr!==undefined)error=context.response=mr` +\n\t\t\t\t'}'\n\n\t\t\tendUnit()\n\t\t}\n\t}\n\n\tmapResponseReporter.resolve()\n\n\tfnLiteral +=\n\t\tafterResponse() +\n\t\t`\\nreturn mapResponse(${saveResponse}error,set${adapter.mapResponseContext})}`\n\n\tconst mapFn = (x: Function | HookContainer) =>\n\t\ttypeof x === 'function' ? x : x.fn\n\n\treturn Function(\n\t\t'inject',\n\t\t'\"use strict\";\\n' + fnLiteral\n\t)({\n\t\tmapResponse: app['~adapter'].handler.mapResponse,\n\t\tERROR_CODE,\n\t\tElysiaCustomStatusResponse,\n\t\tonError: app.event.error?.map(mapFn),\n\t\tafterResponse: app.event.afterResponse?.map(mapFn),\n\t\ttrace: app.event.trace?.map(mapFn),\n\t\tonMapResponse: app.event.mapResponse?.map(mapFn),\n\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\t...adapter.inject\n\t})\n}\n",
|
|
22
|
+
"import type { AnyElysia } from '.'\n\nimport { Value } from '@sinclair/typebox/value'\nimport {\n\tKind,\n\tOptionalKind,\n\tTypeBoxError,\n\ttype TAnySchema,\n\ttype TSchema\n} from '@sinclair/typebox'\n\nimport decode from 'fast-decode-uri-component'\nimport { parseQuery, parseQueryFromURL } from './parse-query'\n\nimport {\n\tELYSIA_REQUEST_ID,\n\tgetLoosePath,\n\tlifeCycleToFn,\n\trandomId,\n\tredirect,\n\tsignCookie,\n\tisNotEmpty,\n\tencodePath,\n\tmergeCookie\n} from './utils'\nimport { isBun } from './universal/utils'\nimport { ParseError, status } from './error'\n\nimport {\n\tNotFoundError,\n\tValidationError,\n\tERROR_CODE,\n\tElysiaCustomStatusResponse\n} from './error'\nimport { ELYSIA_TRACE, type TraceHandler } from './trace'\n\nimport {\n\tcoercePrimitiveRoot,\n\tElysiaTypeCheck,\n\tgetCookieValidator,\n\tgetSchemaValidator,\n\thasType,\n\tisUnion,\n\tunwrapImportSchema\n} from './schema'\nimport { Sucrose, sucrose } from './sucrose'\nimport { parseCookie, type CookieOptions } from './cookies'\nimport { validateFileExtension } from './type-system/utils'\n\nimport type { TraceEvent } from './trace'\nimport type {\n\tComposedHandler,\n\tElysiaConfig,\n\tHandler,\n\tHookContainer,\n\tLifeCycleStore,\n\tSchemaValidator\n} from './types'\n\nconst allocateIf = (value: string, condition: unknown) =>\n\tcondition ? value : ''\n\nconst defaultParsers = [\n\t'json',\n\t'text',\n\t'urlencoded',\n\t'arrayBuffer',\n\t'formdata',\n\t'application/json',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'text/plain',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'application/x-www-form-urlencoded',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'application/octet-stream',\n\t// eslint-disable-next-line sonarjs/no-duplicate-string\n\t'multipart/form-data'\n]\n\nconst createReport = ({\n\tcontext = 'c',\n\ttrace = [],\n\taddFn\n}: {\n\tcontext?: string\n\ttrace?: (TraceHandler | HookContainer<TraceHandler>)[]\n\taddFn(string: string): void\n}) => {\n\tif (!trace.length)\n\t\treturn () => {\n\t\t\treturn {\n\t\t\t\tresolveChild() {\n\t\t\t\t\treturn () => {}\n\t\t\t\t},\n\t\t\t\tresolve() {}\n\t\t\t}\n\t\t}\n\n\tfor (let i = 0; i < trace.length; i++)\n\t\taddFn(\n\t\t\t`let report${i},reportChild${i},reportErr${i},reportErrChild${i};` +\n\t\t\t\t`let trace${i}=${context}[ELYSIA_TRACE]?.[${i}]??trace[${i}](${context});\\n`\n\t\t)\n\n\treturn (\n\t\tevent: TraceEvent,\n\t\t{\n\t\t\tname,\n\t\t\ttotal = 0\n\t\t}: {\n\t\t\tname?: string\n\t\t\tattribute?: string\n\t\t\ttotal?: number\n\t\t} = {}\n\t) => {\n\t\t// ? For debug specific event\n\t\t// if (event !== 'mapResponse')\n\t\t// \treturn {\n\t\t// \t\tresolveChild() {\n\t\t// \t\t\treturn () => {}\n\t\t// \t\t},\n\t\t// \t\tresolve() {}\n\t\t// \t}\n\n\t\tif (!name) name = 'anonymous'\n\n\t\tconst reporter = event === 'error' ? 'reportErr' : 'report'\n\n\t\tfor (let i = 0; i < trace.length; i++)\n\t\t\taddFn(\n\t\t\t\t`${reporter}${i} = trace${i}.${event}({` +\n\t\t\t\t\t`id,` +\n\t\t\t\t\t`event:'${event}',` +\n\t\t\t\t\t`name:'${name}',` +\n\t\t\t\t\t`begin:performance.now(),` +\n\t\t\t\t\t`total:${total}` +\n\t\t\t\t\t`})\\n`\n\t\t\t)\n\n\t\treturn {\n\t\t\tresolve() {\n\t\t\t\tfor (let i = 0; i < trace.length; i++)\n\t\t\t\t\taddFn(`${reporter}${i}.resolve()\\n`)\n\t\t\t},\n\t\t\tresolveChild(name: string) {\n\t\t\t\tfor (let i = 0; i < trace.length; i++)\n\t\t\t\t\taddFn(\n\t\t\t\t\t\t`${reporter}Child${i}=${reporter}${i}.resolveChild?.shift()?.({` +\n\t\t\t\t\t\t\t`id,` +\n\t\t\t\t\t\t\t`event:'${event}',` +\n\t\t\t\t\t\t\t`name:'${name}',` +\n\t\t\t\t\t\t\t`begin:performance.now()` +\n\t\t\t\t\t\t\t`})\\n`\n\t\t\t\t\t)\n\n\t\t\t\treturn (binding?: string) => {\n\t\t\t\t\tfor (let i = 0; i < trace.length; i++) {\n\t\t\t\t\t\tif (binding)\n\t\t\t\t\t\t\t// Don't report error because HTTP response is expected and not an actual error to look for\n\t\t\t\t\t\t\t// if (${binding} instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\t\t\t// ${reporter}Child${i}?.(${binding}.error)\n\t\t\t\t\t\t\t// ${reporter}Child${i}?.()\\n\n\t\t\t\t\t\t\t// } else\n\t\t\t\t\t\t\taddFn(\n\t\t\t\t\t\t\t\t`if(${binding} instanceof Error){` +\n\t\t\t\t\t\t\t\t\t`${reporter}Child${i}?.(${binding}) ` +\n\t\t\t\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t\t\t\t`${reporter}Child${i}?.()` +\n\t\t\t\t\t\t\t\t\t'}'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\telse addFn(`${reporter}Child${i}?.()\\n`)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst composeCleaner = ({\n\tschema,\n\tname,\n\ttype,\n\ttypeAlias = type,\n\tnormalize,\n\tignoreTryCatch = false\n}: {\n\tschema: ElysiaTypeCheck<any>\n\tname: string\n\ttype: keyof SchemaValidator\n\ttypeAlias?: string\n\tnormalize: ElysiaConfig<''>['normalize']\n\tignoreTryCatch?: boolean\n}) => {\n\tif (!normalize || !schema.Clean) return ''\n\n\tif (normalize === true || normalize === 'exactMirror') {\n\t\tif (ignoreTryCatch)\n\t\t\treturn `${name}=validator.${typeAlias}.Clean(${name})\\n`\n\n\t\treturn (\n\t\t\t`try{` +\n\t\t\t`${name}=validator.${typeAlias}.Clean(${name})\\n` +\n\t\t\t`}catch{}`\n\t\t)\n\t}\n\n\tif (normalize === 'typebox')\n\t\treturn `${name}=validator.${typeAlias}.Clean(${name})\\n`\n\n\treturn ''\n}\n\nconst composeValidationFactory = ({\n\tinjectResponse = '',\n\tnormalize = false,\n\tvalidator,\n\tencodeSchema = false,\n\tisStaticResponse = false,\n\thasSanitize = false\n}: {\n\tinjectResponse?: string\n\tnormalize?: ElysiaConfig<''>['normalize']\n\tvalidator: SchemaValidator\n\tencodeSchema?: boolean\n\tisStaticResponse?: boolean\n\thasSanitize?: boolean\n}) => ({\n\tvalidate: (type: string, value = `c.${type}`) =>\n\t\t`c.set.status=422;throw new ValidationError('${type}',validator.${type},${value})`,\n\tresponse: (name = 'r') => {\n\t\tif (isStaticResponse) return ''\n\n\t\tlet code = injectResponse + '\\n'\n\n\t\tcode +=\n\t\t\t`if(${name} instanceof ElysiaCustomStatusResponse){` +\n\t\t\t`c.set.status=${name}.code\\n` +\n\t\t\t`${name}=${name}.response` +\n\t\t\t`}` +\n\t\t\t`switch(c.set.status){`\n\n\t\tfor (const [status, value] of Object.entries(validator.response!)) {\n\t\t\tcode += `\\ncase ${status}:if(${name} instanceof Response)break\\n`\n\n\t\t\tconst noValidate = value.schema?.noValidate === true\n\n\t\t\tconst appliedCleaner = noValidate || hasSanitize\n\n\t\t\tconst clean = ({ ignoreTryCatch = false } = {}) =>\n\t\t\t\tcomposeCleaner({\n\t\t\t\t\tname,\n\t\t\t\t\tschema: value,\n\t\t\t\t\ttype: 'response',\n\t\t\t\t\ttypeAlias: `response[${status}]`,\n\t\t\t\t\tnormalize,\n\t\t\t\t\tignoreTryCatch\n\t\t\t\t})\n\n\t\t\tif (appliedCleaner) code += clean()\n\n\t\t\tconst applyErrorCleaner =\n\t\t\t\t!appliedCleaner && normalize && !noValidate\n\n\t\t\t// Encode call TypeCheck.Check internally\n\t\t\tif (encodeSchema && value.hasTransform) {\n\t\t\t\tcode +=\n\t\t\t\t\t`try{` +\n\t\t\t\t\t`${name}=validator.response[${status}].Encode(${name})\\n`\n\n\t\t\t\tif (!appliedCleaner) code += clean({ ignoreTryCatch: true })\n\n\t\t\t\tcode +=\n\t\t\t\t\t`c.set.status=${status}` +\n\t\t\t\t\t`}catch{` +\n\t\t\t\t\t(applyErrorCleaner\n\t\t\t\t\t\t? `try{\\n` +\n\t\t\t\t\t\t\tclean({ ignoreTryCatch: true }) +\n\t\t\t\t\t\t\t`${name}=validator.response[${status}].Encode(${name})\\n` +\n\t\t\t\t\t\t\t`}catch{` +\n\t\t\t\t\t\t\t`throw new ValidationError('response',validator.response[${status}],${name})` +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t\t\t: `throw new ValidationError('response',validator.response[${status}],${name})`) +\n\t\t\t\t\t`}`\n\t\t\t} else {\n\t\t\t\tif (!appliedCleaner) code += clean()\n\n\t\t\t\tif (!noValidate)\n\t\t\t\t\tcode +=\n\t\t\t\t\t\t`if(validator.response[${status}].Check(${name})===false)` +\n\t\t\t\t\t\t`throw new ValidationError('response',validator.response[${status}],${name})\\n` +\n\t\t\t\t\t\t`c.set.status=${status}\\n`\n\t\t\t}\n\n\t\t\tcode += 'break\\n'\n\t\t}\n\n\t\treturn code + '}'\n\t}\n})\n\nconst isAsyncName = (v: Function | HookContainer) => {\n\t// @ts-ignore\n\tconst fn = v?.fn ?? v\n\n\treturn fn.constructor.name === 'AsyncFunction'\n}\n\nconst matchResponseClone = /=>\\s?response\\.clone\\(/\nconst matchFnReturn = /(?:return|=>)\\s?\\S+\\(|a(?:sync|wait)/\n\nexport const isAsync = (v: Function | HookContainer) => {\n\tconst isObject = typeof v === 'object'\n\n\tif (isObject && v.isAsync !== undefined) return v.isAsync\n\n\tconst fn = isObject ? v.fn : v\n\n\tif (fn.constructor.name === 'AsyncFunction') return true\n\n\tconst literal: string = fn.toString()\n\n\tif (matchResponseClone.test(literal)) {\n\t\tif (isObject) v.isAsync = false\n\n\t\treturn false\n\t}\n\n\tconst result = matchFnReturn.test(literal)\n\n\tif (isObject) v.isAsync = result\n\n\treturn result\n}\n\nconst hasReturn = (v: string | HookContainer<any> | Function) => {\n\tconst isObject = typeof v === 'object'\n\n\tif (isObject && v.hasReturn !== undefined) return v.hasReturn\n\n\tconst fnLiteral = isObject\n\t\t? v.fn.toString()\n\t\t: typeof v === 'string'\n\t\t\t? v.toString()\n\t\t\t: v\n\n\tconst parenthesisEnd = fnLiteral.indexOf(')')\n\n\t// Is direct arrow function return eg. () => 1\n\tif (\n\t\tfnLiteral.charCodeAt(parenthesisEnd + 2) === 61 &&\n\t\tfnLiteral.charCodeAt(parenthesisEnd + 5) !== 123\n\t) {\n\t\tif (isObject) v.hasReturn = true\n\n\t\treturn true\n\t}\n\n\tconst result = fnLiteral.includes('return')\n\n\tif (isObject) v.hasReturn = result\n\n\treturn result\n}\n\nconst isGenerator = (v: Function | HookContainer) => {\n\t// @ts-ignore\n\tconst fn = v?.fn ?? v\n\n\treturn (\n\t\tfn.constructor.name === 'AsyncGeneratorFunction' ||\n\t\tfn.constructor.name === 'GeneratorFunction'\n\t)\n}\n\nconst coerceTransformDecodeError = (\n\tfnLiteral: string,\n\ttype: string,\n\tvalue = `c.${type}`\n) =>\n\t`try{${fnLiteral}}catch(error){` +\n\t`if(error.constructor.name === 'TransformDecodeError'){` +\n\t`c.set.status=422\\n` +\n\t`throw error.error ?? new ValidationError('${type}',validator.${type},${value})}` +\n\t`}`\n\nexport const composeHandler = ({\n\tapp,\n\tpath,\n\tmethod,\n\thooks,\n\tvalidator,\n\thandler,\n\tallowMeta = false,\n\tinference\n}: {\n\tapp: AnyElysia\n\tpath: string\n\tmethod: string\n\thooks: Partial<LifeCycleStore>\n\tvalidator: SchemaValidator\n\thandler: unknown | Handler<any, any>\n\tallowMeta?: boolean\n\tinference: Sucrose.Inference\n}): ComposedHandler => {\n\tconst adapter = app['~adapter'].composeHandler\n\tconst adapterHandler = app['~adapter'].handler\n\tconst isHandleFn = typeof handler === 'function'\n\n\tif (!isHandleFn) {\n\t\thandler = adapterHandler.mapResponse(handler, {\n\t\t\t// @ts-expect-error private property\n\t\t\theaders: app.setHeaders ?? {}\n\t\t})\n\n\t\tconst isResponse =\n\t\t\thandler instanceof Response ||\n\t\t\t// @ts-ignore If it's not instanceof Response, it might be a polyfill (only on Node)\n\t\t\t(handler?.constructor?.name === 'Response' &&\n\t\t\t\ttypeof (handler as Response)?.clone === 'function')\n\n\t\tif (\n\t\t\thooks.parse?.length &&\n\t\t\thooks.transform?.length &&\n\t\t\thooks.beforeHandle?.length &&\n\t\t\thooks.afterHandle?.length\n\t\t) {\n\t\t\tif (isResponse)\n\t\t\t\treturn Function(\n\t\t\t\t\t'a',\n\t\t\t\t\t'\"use strict\";\\n' + `return function(){return a.clone()}`\n\t\t\t\t)(handler)\n\n\t\t\treturn Function(\n\t\t\t\t'a',\n\t\t\t\t'\"use strict\";\\n' + 'return function(){return a}'\n\t\t\t)(handler)\n\t\t}\n\n\t\tif (isResponse) {\n\t\t\tconst response = handler as Response\n\n\t\t\thandler = () => response.clone()\n\t\t}\n\t}\n\n\tconst handle = isHandleFn ? `handler(c)` : `handler`\n\n\tconst hasTrace = !!hooks.trace?.length\n\tlet fnLiteral = ''\n\n\tinference = sucrose(hooks, inference)\n\tinference = sucrose(\n\t\t{\n\t\t\thandler: handler as any\n\t\t},\n\t\tinference\n\t)\n\n\tif (adapter.declare) {\n\t\tconst literal = adapter.declare(inference)\n\n\t\tif (literal) fnLiteral += literal\n\t}\n\n\tif (inference.server)\n\t\tfnLiteral +=\n\t\t\t\"Object.defineProperty(c,'server',{\" +\n\t\t\t'get:function(){return getServer()}' +\n\t\t\t'})\\n'\n\n\tvalidator.createBody?.()\n\tvalidator.createQuery?.()\n\tvalidator.createHeaders?.()\n\tvalidator.createParams?.()\n\tvalidator.createCookie?.()\n\tvalidator.createResponse?.()\n\n\tconst hasValidation =\n\t\t!!validator.body ||\n\t\t!!validator.headers ||\n\t\t!!validator.params ||\n\t\t!!validator.query ||\n\t\t!!validator.cookie ||\n\t\t!!validator.response\n\n\tconst hasQuery = inference.query || !!validator.query\n\n\tconst requestNoBody =\n\t\thooks.parse?.length === 1 &&\n\t\t// @ts-expect-error\n\t\thooks.parse[0].fn === 'none'\n\n\tconst hasBody =\n\t\tmethod !== '' &&\n\t\tmethod !== 'GET' &&\n\t\tmethod !== 'HEAD' &&\n\t\t(inference.body || !!validator.body || !!hooks.parse?.length) &&\n\t\t!requestNoBody\n\n\t// @ts-expect-error private\n\tconst defaultHeaders = app.setHeaders\n\tconst hasDefaultHeaders =\n\t\tdefaultHeaders && !!Object.keys(defaultHeaders).length\n\n\t// ? defaultHeaders doesn't imply that user will use headers in handler\n\tconst hasHeaders =\n\t\tinference.headers ||\n\t\t!!validator.headers ||\n\t\t(adapter.preferWebstandardHeaders !== true && inference.body)\n\n\tconst hasCookie = inference.cookie || !!validator.cookie\n\n\tconst cookieMeta: {\n\t\tsecrets?: string | string[]\n\t\tsign: string[] | true\n\t\tproperties: { [x: string]: Object }\n\t} = validator.cookie?.config\n\t\t? mergeCookie(validator?.cookie?.config, app.config.cookie as any)\n\t\t: app.config.cookie\n\n\tlet _encodeCookie = ''\n\tconst encodeCookie = () => {\n\t\tif (_encodeCookie) return _encodeCookie\n\n\t\tif (cookieMeta?.sign) {\n\t\t\tif (!cookieMeta.secrets)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`t.Cookie required secret which is not set in (${method}) ${path}.`\n\t\t\t\t)\n\n\t\t\tconst secret = !cookieMeta.secrets\n\t\t\t\t? undefined\n\t\t\t\t: typeof cookieMeta.secrets === 'string'\n\t\t\t\t\t? cookieMeta.secrets\n\t\t\t\t\t: cookieMeta.secrets[0]\n\n\t\t\t_encodeCookie +=\n\t\t\t\t'const _setCookie = c.set.cookie\\n' + 'if(_setCookie){'\n\n\t\t\tif (cookieMeta.sign === true)\n\t\t\t\t_encodeCookie +=\n\t\t\t\t\t'for(const [key, cookie] of Object.entries(_setCookie)){' +\n\t\t\t\t\t`c.set.cookie[key].value=await signCookie(cookie.value,'${secret}')` +\n\t\t\t\t\t'}'\n\t\t\telse\n\t\t\t\tfor (const name of cookieMeta.sign)\n\t\t\t\t\t_encodeCookie +=\n\t\t\t\t\t\t`if(_setCookie['${name}']?.value)` +\n\t\t\t\t\t\t`c.set.cookie['${name}'].value=await signCookie(_setCookie['${name}'].value,'${secret}')\\n`\n\n\t\t\t_encodeCookie += '}\\n'\n\t\t}\n\n\t\treturn _encodeCookie\n\t}\n\n\tconst normalize = app.config.normalize\n\tconst encodeSchema = app.config.encodeSchema\n\n\tconst validation = composeValidationFactory({\n\t\tnormalize,\n\t\tvalidator,\n\t\tencodeSchema,\n\t\tisStaticResponse: handler instanceof Response,\n\t\thasSanitize: !!app.config.sanitize\n\t})\n\n\tif (hasHeaders) fnLiteral += adapter.headers\n\n\tif (hasTrace) fnLiteral += 'const id=c[ELYSIA_REQUEST_ID]\\n'\n\n\tconst report = createReport({\n\t\ttrace: hooks.trace,\n\t\taddFn: (word) => {\n\t\t\tfnLiteral += word\n\t\t}\n\t})\n\n\tfnLiteral += 'try{'\n\n\tif (hasCookie) {\n\t\tconst get = (name: keyof CookieOptions, defaultValue?: unknown) => {\n\t\t\t// @ts-ignore\n\t\t\tconst value = cookieMeta?.[name] ?? defaultValue\n\t\t\tif (!value)\n\t\t\t\treturn typeof defaultValue === 'string'\n\t\t\t\t\t? `${name}:\"${defaultValue}\",`\n\t\t\t\t\t: `${name}:${defaultValue},`\n\n\t\t\tif (typeof value === 'string') return `${name}:'${value}',`\n\t\t\tif (value instanceof Date)\n\t\t\t\treturn `${name}: new Date(${value.getTime()}),`\n\n\t\t\treturn `${name}:${value},`\n\t\t}\n\n\t\tconst options = cookieMeta\n\t\t\t? `{secrets:${\n\t\t\t\t\tcookieMeta.secrets !== undefined\n\t\t\t\t\t\t? typeof cookieMeta.secrets === 'string'\n\t\t\t\t\t\t\t? `'${cookieMeta.secrets}'`\n\t\t\t\t\t\t\t: '[' +\n\t\t\t\t\t\t\t\tcookieMeta.secrets.reduce(\n\t\t\t\t\t\t\t\t\t(a, b) => a + `'${b}',`,\n\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t) +\n\t\t\t\t\t\t\t\t']'\n\t\t\t\t\t\t: 'undefined'\n\t\t\t\t},` +\n\t\t\t\t`sign:${\n\t\t\t\t\tcookieMeta.sign === true\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: cookieMeta.sign !== undefined\n\t\t\t\t\t\t\t? '[' +\n\t\t\t\t\t\t\t\tcookieMeta.sign.reduce(\n\t\t\t\t\t\t\t\t\t(a, b) => a + `'${b}',`,\n\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t) +\n\t\t\t\t\t\t\t\t']'\n\t\t\t\t\t\t\t: 'undefined'\n\t\t\t\t},` +\n\t\t\t\tget('domain') +\n\t\t\t\tget('expires') +\n\t\t\t\tget('httpOnly') +\n\t\t\t\tget('maxAge') +\n\t\t\t\tget('path', '/') +\n\t\t\t\tget('priority') +\n\t\t\t\tget('sameSite') +\n\t\t\t\tget('secure') +\n\t\t\t\t'}'\n\t\t\t: 'undefined'\n\n\t\tif (hasHeaders)\n\t\t\tfnLiteral += `\\nc.cookie=await parseCookie(c.set,c.headers.cookie,${options})\\n`\n\t\telse\n\t\t\tfnLiteral += `\\nc.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${options})\\n`\n\t}\n\n\tif (hasQuery) {\n\t\tconst destructured = <\n\t\t\t{\n\t\t\t\tkey: string\n\t\t\t\tisArray: boolean\n\t\t\t\tisNestedObjectArray: boolean\n\t\t\t\tisObject: boolean\n\t\t\t\tanyOf: boolean\n\t\t\t}[]\n\t\t>[]\n\n\t\tconst schema = validator.query?.schema\n\t\tif (\n\t\t\tschema &&\n\t\t\t(schema.type === 'object' ||\n\t\t\t\t(schema[Kind] === 'Import' && schema.$defs[schema.$ref]))\n\t\t) {\n\t\t\tconst properties =\n\t\t\t\tschema.properties ?? schema.$defs[schema.$ref].properties\n\n\t\t\tif (!validator.query!.hasAdditionalProperties)\n\t\t\t\tfor (const [key, _value] of Object.entries(properties)) {\n\t\t\t\t\tlet value = _value as TAnySchema\n\n\t\t\t\t\tconst isArray =\n\t\t\t\t\t\tvalue.type === 'array' ||\n\t\t\t\t\t\t!!value.anyOf?.some(\n\t\t\t\t\t\t\t(v: TSchema) =>\n\t\t\t\t\t\t\t\tv.type === 'string' &&\n\t\t\t\t\t\t\t\tv.format === 'ArrayString'\n\t\t\t\t\t\t)\n\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (\n\t\t\t\t\t\tvalue &&\n\t\t\t\t\t\tOptionalKind in value &&\n\t\t\t\t\t\tvalue.type === 'array' &&\n\t\t\t\t\t\tvalue.items\n\t\t\t\t\t)\n\t\t\t\t\t\tvalue = value.items\n\n\t\t\t\t\tconst { type, anyOf } = value\n\n\t\t\t\t\tdestructured.push({\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tisArray,\n\t\t\t\t\t\tisNestedObjectArray:\n\t\t\t\t\t\t\t(isArray && value.items?.type === 'object') ||\n\t\t\t\t\t\t\t!!value.items?.anyOf?.some(\n\t\t\t\t\t\t\t\t(x: TSchema) =>\n\t\t\t\t\t\t\t\t\tx.type === 'object' || x.type === 'array'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tisObject:\n\t\t\t\t\t\t\ttype === 'object' ||\n\t\t\t\t\t\t\tanyOf?.some(\n\t\t\t\t\t\t\t\t(v: TSchema) =>\n\t\t\t\t\t\t\t\t\tv.type === 'string' &&\n\t\t\t\t\t\t\t\t\tv.format === 'ArrayString'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tanyOf: !!anyOf\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t}\n\n\t\tif (!destructured.length) {\n\t\t\tfnLiteral +=\n\t\t\t\t'if(c.qi===-1){' +\n\t\t\t\t'c.query={}' +\n\t\t\t\t'}else{' +\n\t\t\t\t'c.query=parseQueryFromURL(c.url,c.qi+1)' +\n\t\t\t\t'}'\n\t\t} else {\n\t\t\tfnLiteral += 'if(c.qi!==-1){' + `let url='&'+c.url.slice(c.qi+1)\\n`\n\n\t\t\tlet index = 0\n\t\t\tfor (const {\n\t\t\t\tkey,\n\t\t\t\tisArray,\n\t\t\t\tisObject,\n\t\t\t\tisNestedObjectArray,\n\t\t\t\tanyOf\n\t\t\t} of destructured) {\n\t\t\t\tconst encoded = encodeURIComponent(key)\n\n\t\t\t\tconst init =\n\t\t\t\t\t(index === 0 ? 'let ' : '') +\n\t\t\t\t\t`memory=url.indexOf('&${encoded}=')` +\n\t\t\t\t\t`\\nlet a${index}\\n`\n\n\t\t\t\tif (isArray) {\n\t\t\t\t\tfnLiteral += init\n\n\t\t\t\t\tif (isNestedObjectArray)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`while(memory!==-1){` +\n\t\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t\t`if(a${index}===undefined)\\n` +\n\t\t\t\t\t\t\t`a${index}=''\\n` +\n\t\t\t\t\t\t\t`else\\n` +\n\t\t\t\t\t\t\t`a${index}+=','\\n` +\n\t\t\t\t\t\t\t`let temp\\n` +\n\t\t\t\t\t\t\t`if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`else temp=decodeURIComponent(url.slice(start, memory).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`const charCode=temp.charCodeAt(0)\\n` +\n\t\t\t\t\t\t\t`if(charCode!==91&&charCode !== 123)\\n` +\n\t\t\t\t\t\t\t`temp='\"'+temp+'\"'\\n` +\n\t\t\t\t\t\t\t`a${index}+=temp\\n` +\n\t\t\t\t\t\t\t`if(memory===-1)break\\n` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&${encoded}=',memory)\\n` +\n\t\t\t\t\t\t\t`if(memory===-1)break` +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`try{` +\n\t\t\t\t\t\t\t`if(a${index}.charCodeAt(0)===91)` +\n\t\t\t\t\t\t\t`a${index} = JSON.parse(a${index})\\n` +\n\t\t\t\t\t\t\t`else\\n` +\n\t\t\t\t\t\t\t`a${index}=JSON.parse('['+a${index}+']')` +\n\t\t\t\t\t\t\t`}catch{}\\n`\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`while(memory!==-1){` +\n\t\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t\t`if(a${index}===undefined)` +\n\t\t\t\t\t\t\t`a${index}=[]\\n` +\n\t\t\t\t\t\t\t`if(memory===-1){` +\n\t\t\t\t\t\t\t`const temp=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`if(temp.includes(',')){a${index}=a${index}.concat(temp.split(','))}` +\n\t\t\t\t\t\t\t`else{a${index}.push(decodeURIComponent(url.slice(start).replace(/\\\\+/g,' ')))}\\n` +\n\t\t\t\t\t\t\t`break` +\n\t\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t\t`const temp=decodeURIComponent(url.slice(start, memory).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t\t`if(temp.includes(',')){a${index}=a${index}.concat(temp.split(','))}` +\n\t\t\t\t\t\t\t`else{a${index}.push(temp)}\\n` +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`memory=url.indexOf('&${encoded}=',memory)\\n` +\n\t\t\t\t\t\t\t`if(memory===-1) break\\n` +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t} else if (isObject)\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\tinit +\n\t\t\t\t\t\t`if(memory!==-1){` +\n\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t`if(memory===-1)a${index}=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))` +\n\t\t\t\t\t\t`else a${index}=decodeURIComponent(url.slice(start,memory).replace(/\\\\+/g,' '))` +\n\t\t\t\t\t\t`if(a${index}!==undefined)` +\n\t\t\t\t\t\t`try{` +\n\t\t\t\t\t\t`a${index}=JSON.parse(a${index})` +\n\t\t\t\t\t\t`}catch{}` +\n\t\t\t\t\t\t'}'\n\t\t\t\t// Might be union primitive and array\n\t\t\t\telse {\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\tinit +\n\t\t\t\t\t\t`if(memory!==-1){` +\n\t\t\t\t\t\t`const start=memory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t`memory=url.indexOf('&',start)\\n` +\n\t\t\t\t\t\t`if(memory===-1)a${index}=decodeURIComponent(url.slice(start).replace(/\\\\+/g,' '))\\n` +\n\t\t\t\t\t\t`else{` +\n\t\t\t\t\t\t`a${index}=decodeURIComponent(url.slice(start,memory).replace(/\\\\+/g,' '))`\n\n\t\t\t\t\tif (anyOf)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`\\nlet deepMemory=url.indexOf('&${encoded}=',memory)\\n` +\n\t\t\t\t\t\t\t`if(deepMemory!==-1){` +\n\t\t\t\t\t\t\t`a${index}=[a${index}]\\n` +\n\t\t\t\t\t\t\t`let first=true\\n` +\n\t\t\t\t\t\t\t`while(true){` +\n\t\t\t\t\t\t\t`const start=deepMemory+${encoded.length + 2}\\n` +\n\t\t\t\t\t\t\t`if(first)first=false\\n` +\n\t\t\t\t\t\t\t`else deepMemory = url.indexOf('&', start)\\n` +\n\t\t\t\t\t\t\t`let value\\n` +\n\t\t\t\t\t\t\t`if(deepMemory===-1)value=url.slice(start).replace(/\\\\+/g,' ')\\n` +\n\t\t\t\t\t\t\t`else value=url.slice(start, deepMemory).replace(/\\\\+/g,' ')\\n` +\n\t\t\t\t\t\t\t`value=decodeURIComponent(value)\\n` +\n\t\t\t\t\t\t\t`if(value===null){if(deepMemory===-1){break}else{continue}}\\n` +\n\t\t\t\t\t\t\t`const vStart=value.charCodeAt(0)\\n` +\n\t\t\t\t\t\t\t`const vEnd=value.charCodeAt(value.length - 1)\\n` +\n\t\t\t\t\t\t\t`if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))\\n` +\n\t\t\t\t\t\t\t`try{` +\n\t\t\t\t\t\t\t`a${index}.push(JSON.parse(value))` +\n\t\t\t\t\t\t\t`}catch{` +\n\t\t\t\t\t\t\t`a${index}.push(value)` +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`if(deepMemory===-1)break` +\n\t\t\t\t\t\t\t`}}`\n\n\t\t\t\t\tfnLiteral += '}}'\n\t\t\t\t}\n\n\t\t\t\tindex++\n\t\t\t\tfnLiteral += '\\n'\n\t\t\t}\n\n\t\t\tfnLiteral +=\n\t\t\t\t`c.query={` +\n\t\t\t\tdestructured\n\t\t\t\t\t.map(({ key }, index) => `'${key}':a${index}`)\n\t\t\t\t\t.join(',') +\n\t\t\t\t`}`\n\n\t\t\t// If there are no query parameters, set it to an empty object\n\t\t\tfnLiteral += `} else c.query = {}\\n`\n\t\t}\n\t}\n\n\tconst isAsyncHandler = typeof handler === 'function' && isAsync(handler)\n\n\tconst saveResponse =\n\t\thasTrace || hooks.afterResponse?.length ? 'c.response= ' : ''\n\n\tconst maybeAsync =\n\t\thasCookie ||\n\t\thasBody ||\n\t\tisAsyncHandler ||\n\t\t!!hooks.parse?.length ||\n\t\t!!hooks.afterHandle?.some(isAsync) ||\n\t\t!!hooks.beforeHandle?.some(isAsync) ||\n\t\t!!hooks.transform?.some(isAsync) ||\n\t\t!!hooks.mapResponse?.some(isAsync)\n\n\tconst maybeStream =\n\t\t(typeof handler === 'function' ? isGenerator(handler as any) : false) ||\n\t\t!!hooks.beforeHandle?.some(isGenerator) ||\n\t\t!!hooks.afterHandle?.some(isGenerator) ||\n\t\t!!hooks.transform?.some(isGenerator)\n\n\tconst responseKeys = Object.keys(validator.response ?? {})\n\tconst hasMultipleResponses = responseKeys.length > 1\n\tconst hasSingle200 =\n\t\tresponseKeys.length === 0 ||\n\t\t(responseKeys.length === 1 && responseKeys[0] === '200')\n\n\tconst hasSet =\n\t\tinference.cookie ||\n\t\tinference.set ||\n\t\thasHeaders ||\n\t\thasTrace ||\n\t\thasMultipleResponses ||\n\t\t!hasSingle200 ||\n\t\t(isHandleFn && hasDefaultHeaders) ||\n\t\tmaybeStream\n\n\tconst afterResponse = () => {\n\t\tif (!hooks.afterResponse?.length && !hasTrace) return ''\n\n\t\tlet afterResponse = ''\n\t\tconst prefix = hooks.afterResponse?.some(isAsync) ? 'async ' : ''\n\n\t\tafterResponse += `\\nsetImmediate(${prefix}()=>{`\n\n\t\tconst reporter = createReport({\n\t\t\ttrace: hooks.trace,\n\t\t\taddFn: (word) => {\n\t\t\t\tafterResponse += word\n\t\t\t}\n\t\t})('afterResponse', {\n\t\t\ttotal: hooks.afterResponse?.length\n\t\t})\n\n\t\tif (hooks.afterResponse?.length && hooks.afterResponse) {\n\t\t\tfor (let i = 0; i < hooks.afterResponse.length; i++) {\n\t\t\t\tconst endUnit = reporter.resolveChild(\n\t\t\t\t\thooks.afterResponse[i].fn.name\n\t\t\t\t)\n\t\t\t\tconst prefix = isAsync(hooks.afterResponse[i]) ? 'await ' : ''\n\t\t\t\tafterResponse += `\\n${prefix}e.afterResponse[${i}](c)\\n`\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\n\t\tafterResponse += '})\\n'\n\n\t\treturn afterResponse\n\t}\n\n\tconst mapResponse = (r = 'r') => {\n\t\tconst after = afterResponse()\n\t\tconst response = `${hasSet ? 'mapResponse' : 'mapCompactResponse'}(${saveResponse}${r}${hasSet ? ',c.set' : ''}${mapResponseContext})\\n`\n\n\t\tif (!after) return `return ${response}`\n\n\t\treturn `const _res=${response}` + after + `return _res`\n\t}\n\n\tconst mapResponseContext =\n\t\tmaybeStream || adapter.mapResponseContext\n\t\t\t? `,${adapter.mapResponseContext}`\n\t\t\t: ''\n\n\tif (hasTrace || inference.route) fnLiteral += `c.route=\\`${path}\\`\\n`\n\n\tconst parseReporter = report('parse', {\n\t\ttotal: hooks.parse?.length\n\t})\n\n\tif (hasBody) {\n\t\tconst hasBodyInference =\n\t\t\t!!hooks.parse?.length || inference.body || validator.body\n\n\t\tif (adapter.parser.declare) fnLiteral += adapter.parser.declare\n\n\t\tfnLiteral += '\\ntry{'\n\n\t\tlet parser: string | undefined =\n\t\t\ttypeof hooks.parse === 'string'\n\t\t\t\t? hooks.parse\n\t\t\t\t: Array.isArray(hooks.parse) && hooks.parse.length === 1\n\t\t\t\t\t? typeof hooks.parse[0] === 'string'\n\t\t\t\t\t\t? hooks.parse[0]\n\t\t\t\t\t\t: typeof hooks.parse[0].fn === 'string'\n\t\t\t\t\t\t\t? hooks.parse[0].fn\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t: undefined\n\n\t\tif (!parser && validator.body && !hooks.parse?.length) {\n\t\t\tconst schema = validator.body.schema\n\t\t\tif (\n\t\t\t\tschema &&\n\t\t\t\tschema.anyOf &&\n\t\t\t\tschema[Kind] === 'Union' &&\n\t\t\t\tschema.anyOf?.length === 2 &&\n\t\t\t\tschema.anyOf?.find((x: TAnySchema) => x[Kind] === 'ElysiaForm')\n\t\t\t)\n\t\t\t\tparser = 'formdata'\n\t\t}\n\n\t\tif (parser && defaultParsers.includes(parser)) {\n\t\t\tconst reporter = report('parse', {\n\t\t\t\ttotal: hooks.parse?.length\n\t\t\t})\n\n\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\tswitch (parser) {\n\t\t\t\tcase 'json':\n\t\t\t\tcase 'application/json':\n\t\t\t\t\tfnLiteral += adapter.parser.json(isOptionalBody)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'text':\n\t\t\t\tcase 'text/plain':\n\t\t\t\t\tfnLiteral += adapter.parser.text(isOptionalBody)\n\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'urlencoded':\n\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\tfnLiteral += adapter.parser.urlencoded(isOptionalBody)\n\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'arrayBuffer':\n\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\tfnLiteral += adapter.parser.arrayBuffer(isOptionalBody)\n\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'formdata':\n\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\tfnLiteral += adapter.parser.formData(isOptionalBody)\n\t\t\t\t\tbreak\n\n\t\t\t\tdefault:\n\t\t\t\t\tif ((parser[0] as string) in app['~parser']) {\n\t\t\t\t\t\tfnLiteral += hasHeaders\n\t\t\t\t\t\t\t? `let contentType = c.headers['content-type']`\n\t\t\t\t\t\t\t: `let contentType = c.request.headers.get('content-type')`\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`\\nif(contentType){` +\n\t\t\t\t\t\t\t`const index=contentType.indexOf(';')\\n` +\n\t\t\t\t\t\t\t`if(index!==-1)contentType=contentType.substring(0,index)}\\n` +\n\t\t\t\t\t\t\t`else{contentType=''}` +\n\t\t\t\t\t\t\t`c.contentType=contentType\\n` +\n\t\t\t\t\t\t\t`let result=parser['${parser}'](c, contentType)\\n` +\n\t\t\t\t\t\t\t`if(result instanceof Promise)result=await result\\n` +\n\t\t\t\t\t\t\t`if(result instanceof ElysiaCustomStatusResponse)throw result\\n` +\n\t\t\t\t\t\t\t`if(result!==undefined)c.body=result\\n` +\n\t\t\t\t\t\t\t'delete c.contentType\\n'\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak\n\t\t\t}\n\n\t\t\treporter.resolve()\n\t\t} else if (hasBodyInference) {\n\t\t\tfnLiteral += '\\n'\n\n\t\t\tfnLiteral += 'let contentType\\n' + 'if(c.request.body)'\n\t\t\tfnLiteral += hasHeaders\n\t\t\t\t? `contentType=c.headers['content-type']\\n`\n\t\t\t\t: `contentType=c.request.headers.get('content-type')\\n`\n\n\t\t\tlet hasDefaultParser = false\n\t\t\tif (hooks.parse?.length)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(contentType){\\n` +\n\t\t\t\t\t`const index=contentType.indexOf(';')\\n` +\n\t\t\t\t\t`\\nif(index!==-1)contentType=contentType.substring(0,index)` +\n\t\t\t\t\t`}else{contentType=''}` +\n\t\t\t\t\t`let used=false\\n` +\n\t\t\t\t\t`c.contentType=contentType\\n`\n\t\t\telse {\n\t\t\t\thasDefaultParser = true\n\t\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(contentType)` +\n\t\t\t\t\t`switch(contentType.charCodeAt(12)){` +\n\t\t\t\t\t`\\ncase 106:` +\n\t\t\t\t\tadapter.parser.json(isOptionalBody) +\n\t\t\t\t\t'break' +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`case 120:` +\n\t\t\t\t\tadapter.parser.urlencoded(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`case 111:` +\n\t\t\t\t\tadapter.parser.arrayBuffer(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`case 114:` +\n\t\t\t\t\tadapter.parser.formData(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t`\\n` +\n\t\t\t\t\t`default:` +\n\t\t\t\t\t`if(contentType.charCodeAt(0)===116){` +\n\t\t\t\t\tadapter.parser.text(isOptionalBody) +\n\t\t\t\t\t`}` +\n\t\t\t\t\t`break\\n` +\n\t\t\t\t\t`}`\n\t\t\t}\n\n\t\t\tconst reporter = report('parse', {\n\t\t\t\ttotal: hooks.parse?.length\n\t\t\t})\n\n\t\t\tif (hooks.parse)\n\t\t\t\tfor (let i = 0; i < hooks.parse.length; i++) {\n\t\t\t\t\tconst name = `bo${i}`\n\t\t\t\t\tif (i !== 0) fnLiteral += `\\nif(!used){`\n\n\t\t\t\t\tif (typeof hooks.parse[i].fn === 'string') {\n\t\t\t\t\t\tconst endUnit = reporter.resolveChild(\n\t\t\t\t\t\t\thooks.parse[i].fn as unknown as string\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\t\t\t\tswitch (hooks.parse[i].fn as unknown as string) {\n\t\t\t\t\t\t\tcase 'json':\n\t\t\t\t\t\t\tcase 'application/json':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral += adapter.parser.json(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'text':\n\t\t\t\t\t\t\tcase 'text/plain':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral += adapter.parser.text(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'urlencoded':\n\t\t\t\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\tadapter.parser.urlencoded(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'arrayBuffer':\n\t\t\t\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\tadapter.parser.arrayBuffer(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tcase 'formdata':\n\t\t\t\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\t\t\t\thasDefaultParser = true\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\tadapter.parser.formData(isOptionalBody)\n\n\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t\t`let ${name}=parser['${hooks.parse[i].fn}'](c,contentType)\\n` +\n\t\t\t\t\t\t\t\t\t`if(${name} instanceof Promise)${name}=await ${name}\\n` +\n\t\t\t\t\t\t\t\t\t`if(${name}!==undefined){c.body=${name};used=true;}\\n`\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst endUnit = reporter.resolveChild(\n\t\t\t\t\t\t\thooks.parse[i].fn.name\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`let ${name}=e.parse[${i}]\\n` +\n\t\t\t\t\t\t\t`${name}=${name}(c,contentType)\\n` +\n\t\t\t\t\t\t\t`if(${name} instanceof Promise)${name}=await ${name}\\n` +\n\t\t\t\t\t\t\t`if(${name}!==undefined){c.body=${name};used=true}`\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (i !== 0) fnLiteral += `}`\n\n\t\t\t\t\tif (hasDefaultParser) break\n\t\t\t\t}\n\n\t\t\treporter.resolve()\n\n\t\t\tif (!hasDefaultParser) {\n\t\t\t\tconst isOptionalBody = !!validator.body?.isOptional\n\n\t\t\t\tif (hooks.parse?.length) fnLiteral += `\\nif(!used){\\n`\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`switch(contentType){` +\n\t\t\t\t\t`case 'application/json':\\n` +\n\t\t\t\t\tadapter.parser.json(isOptionalBody) +\n\t\t\t\t\t`break\\n` +\n\t\t\t\t\t`case 'text/plain':` +\n\t\t\t\t\tadapter.parser.text(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t`case 'application/x-www-form-urlencoded':` +\n\t\t\t\t\tadapter.parser.urlencoded(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t`case 'application/octet-stream':` +\n\t\t\t\t\tadapter.parser.arrayBuffer(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t`case 'multipart/form-data':` +\n\t\t\t\t\tadapter.parser.formData(isOptionalBody) +\n\t\t\t\t\t`break` +\n\t\t\t\t\t'\\n'\n\n\t\t\t\tfor (const key of Object.keys(app['~parser']))\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`case '${key}':` +\n\t\t\t\t\t\t`let bo${key}=parser['${key}'](c,contentType)\\n` +\n\t\t\t\t\t\t`if(bo${key} instanceof Promise)bo${key}=await bo${key}\\n` +\n\t\t\t\t\t\t`if(bo${key} instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\tmapResponse(`bo${key}`) +\n\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t`if(bo${key}!==undefined)c.body=bo${key}\\n` +\n\t\t\t\t\t\t`break` +\n\t\t\t\t\t\t'\\n'\n\n\t\t\t\tif (hooks.parse?.length) fnLiteral += '}'\n\n\t\t\t\tfnLiteral += '}'\n\t\t\t}\n\n\t\t\tif (hooks.parse?.length) fnLiteral += '\\ndelete c.contentType'\n\t\t}\n\n\t\tfnLiteral += '}catch(error){throw new ParseError(error)}'\n\t}\n\n\tparseReporter.resolve()\n\n\tif (hooks?.transform || hasTrace) {\n\t\tconst reporter = report('transform', {\n\t\t\ttotal: hooks.transform?.length\n\t\t})\n\n\t\tif (hooks.transform?.length) {\n\t\t\tfnLiteral += 'let transformed\\n'\n\n\t\t\tfor (let i = 0; i < hooks.transform.length; i++) {\n\t\t\t\tconst transform = hooks.transform[i]\n\n\t\t\t\tconst endUnit = reporter.resolveChild(transform.fn.name)\n\n\t\t\t\tfnLiteral += isAsync(transform)\n\t\t\t\t\t? `transformed=await e.transform[${i}](c)\\n`\n\t\t\t\t\t: `transformed=e.transform[${i}](c)\\n`\n\n\t\t\t\tif (transform.subType === 'mapDerive')\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`if(transformed instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\tmapResponse('transformed') +\n\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t`transformed.request=c.request\\n` +\n\t\t\t\t\t\t`transformed.store=c.store\\n` +\n\t\t\t\t\t\t`transformed.qi=c.qi\\n` +\n\t\t\t\t\t\t`transformed.path=c.path\\n` +\n\t\t\t\t\t\t`transformed.url=c.url\\n` +\n\t\t\t\t\t\t`transformed.redirect=c.redirect\\n` +\n\t\t\t\t\t\t`transformed.set=c.set\\n` +\n\t\t\t\t\t\t`transformed.error=c.error\\n` +\n\t\t\t\t\t\t`c=transformed` +\n\t\t\t\t\t\t'}'\n\t\t\t\telse\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`if(transformed instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\tmapResponse('transformed') +\n\t\t\t\t\t\t`}else Object.assign(c,transformed)\\n`\n\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\t}\n\n\tconst fileUnions = <ElysiaTypeCheck<any>[]>[]\n\n\tif (validator) {\n\t\tif (validator.headers) {\n\t\t\tif (validator.headers.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tvalidator.headers.schema,\n\t\t\t\t\t\t{}\n\t\t\t\t\t) as Object\n\t\t\t\t)) {\n\t\t\t\t\tconst parsed =\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t\t: value\n\n\t\t\t\t\tif (parsed !== undefined)\n\t\t\t\t\t\tfnLiteral += `c.headers['${key}']??=${parsed}\\n`\n\t\t\t\t}\n\n\t\t\tfnLiteral += composeCleaner({\n\t\t\t\tname: 'c.headers',\n\t\t\t\tschema: validator.headers,\n\t\t\t\ttype: 'headers',\n\t\t\t\tnormalize\n\t\t\t})\n\n\t\t\tif (validator.headers.isOptional)\n\t\t\t\tfnLiteral += `if(isNotEmpty(c.headers)){`\n\n\t\t\tif (validator.body?.schema?.noValidate !== true)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.headers.Check(c.headers) === false){` +\n\t\t\t\t\tvalidation.validate('headers') +\n\t\t\t\t\t'}'\n\n\t\t\tif (validator.headers.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`c.headers=validator.headers.Decode(c.headers)\\n`,\n\t\t\t\t\t'headers'\n\t\t\t\t)\n\n\t\t\tif (validator.headers.isOptional) fnLiteral += '}'\n\t\t}\n\n\t\tif (validator.params) {\n\t\t\tif (validator.params.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tvalidator.params.schema,\n\t\t\t\t\t\t{}\n\t\t\t\t\t) as Object\n\t\t\t\t)) {\n\t\t\t\t\tconst parsed =\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t\t: value\n\n\t\t\t\t\tif (parsed !== undefined)\n\t\t\t\t\t\tfnLiteral += `c.params['${key}']??=${parsed}\\n`\n\t\t\t\t}\n\n\t\t\tif (validator.params?.schema?.noValidate !== true)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.params.Check(c.params)===false){` +\n\t\t\t\t\tvalidation.validate('params') +\n\t\t\t\t\t'}'\n\n\t\t\tif (validator.params.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`c.params=validator.params.Decode(c.params)\\n`,\n\t\t\t\t\t'params'\n\t\t\t\t)\n\t\t}\n\n\t\tif (validator.query) {\n\t\t\tif (validator.query.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tvalidator.query.schema,\n\t\t\t\t\t\t{}\n\t\t\t\t\t) as Object\n\t\t\t\t)) {\n\t\t\t\t\tconst parsed =\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t\t: value\n\n\t\t\t\t\tif (parsed !== undefined)\n\t\t\t\t\t\tfnLiteral += `if(c.query['${key}']===undefined)c.query['${key}']=${parsed}\\n`\n\n\t\t\t\t\tfnLiteral += composeCleaner({\n\t\t\t\t\t\tname: 'c.query',\n\t\t\t\t\t\tschema: validator.query,\n\t\t\t\t\t\ttype: 'query',\n\t\t\t\t\t\tnormalize\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\tif (validator.query.isOptional)\n\t\t\t\tfnLiteral += `if(isNotEmpty(c.query)){`\n\n\t\t\tif (validator.query?.schema?.noValidate !== true)\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.query.Check(c.query)===false){` +\n\t\t\t\t\tvalidation.validate('query') +\n\t\t\t\t\t`}`\n\n\t\t\tif (validator.query.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`c.query=validator.query.Decode(Object.assign({},c.query))\\n`,\n\t\t\t\t\t'query'\n\t\t\t\t)\n\n\t\t\tif (validator.query.isOptional) fnLiteral += `}`\n\t\t}\n\n\t\tif (hasBody && validator.body) {\n\t\t\tif (validator.body.hasTransform || validator.body.isOptional)\n\t\t\t\tfnLiteral += `const isNotEmptyObject=c.body&&(typeof c.body===\"object\"&&(isNotEmpty(c.body)||c.body instanceof ArrayBuffer))\\n`\n\n\t\t\tconst hasUnion = isUnion(validator.body.schema)\n\t\t\tlet hasNonUnionFileWithDefault = false\n\n\t\t\tif (validator.body.hasDefault) {\n\t\t\t\tlet value = Value.Default(\n\t\t\t\t\tvalidator.body.schema,\n\t\t\t\t\tvalidator.body.schema.type === 'object' ||\n\t\t\t\t\t\t(validator.body.schema[Kind] === 'Import' &&\n\t\t\t\t\t\t\tvalidator.body.schema.$defs[\n\t\t\t\t\t\t\t\tvalidator.body.schema.$ref\n\t\t\t\t\t\t\t][Kind] === 'Object')\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: undefined\n\t\t\t\t)\n\n\t\t\t\tconst schema = unwrapImportSchema(validator.body.schema)\n\n\t\t\t\tif (\n\t\t\t\t\t!hasUnion &&\n\t\t\t\t\tvalue &&\n\t\t\t\t\ttypeof value === 'object' &&\n\t\t\t\t\t(hasType('File', schema) || hasType('Files', schema))\n\t\t\t\t) {\n\t\t\t\t\thasNonUnionFileWithDefault = true\n\n\t\t\t\t\tfor (const [k, v] of Object.entries(value))\n\t\t\t\t\t\tif (v === 'File' || v === 'Files')\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tdelete value[k]\n\n\t\t\t\t\tif (!isNotEmpty(value)) value = undefined\n\t\t\t\t}\n\n\t\t\t\tconst parsed =\n\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t: typeof value === 'string'\n\t\t\t\t\t\t\t? `'${value}'`\n\t\t\t\t\t\t\t: value\n\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\tif (Array.isArray(value))\n\t\t\t\t\t\tfnLiteral += `if(!c.body)c.body=${parsed}\\n`\n\t\t\t\t\telse if (typeof value === 'object')\n\t\t\t\t\t\tfnLiteral += `c.body=Object.assign(${parsed},c.body)\\n`\n\t\t\t\t\telse fnLiteral += `c.body=${parsed}\\n`\n\t\t\t\t}\n\n\t\t\t\tfnLiteral += composeCleaner({\n\t\t\t\t\tname: 'c.body',\n\t\t\t\t\tschema: validator.body,\n\t\t\t\t\ttype: 'body',\n\t\t\t\t\tnormalize\n\t\t\t\t})\n\n\t\t\t\tif (validator.body?.schema?.noValidate !== true) {\n\t\t\t\t\tif (validator.body.isOptional)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(isNotEmptyObject&&validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t'}'\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfnLiteral += composeCleaner({\n\t\t\t\t\tname: 'c.body',\n\t\t\t\t\tschema: validator.body,\n\t\t\t\t\ttype: 'body',\n\t\t\t\t\tnormalize\n\t\t\t\t})\n\n\t\t\t\tif (validator.body?.schema?.noValidate !== true) {\n\t\t\t\t\tif (validator.body.isOptional)\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(isNotEmptyObject&&validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t'}'\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(validator.body.Check(c.body)===false){` +\n\t\t\t\t\t\t\tvalidation.validate('body') +\n\t\t\t\t\t\t\t'}'\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (validator.body.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)\\n`,\n\t\t\t\t\t'body'\n\t\t\t\t)\n\n\t\t\tif (hasUnion && validator.body.schema.anyOf?.length) {\n\t\t\t\tconst iterator = Object.values(\n\t\t\t\t\tvalidator.body.schema.anyOf\n\t\t\t\t) as TAnySchema[]\n\n\t\t\t\tfor (let i = 0; i < iterator.length; i++) {\n\t\t\t\t\tconst type = iterator[i]\n\n\t\t\t\t\tif (hasType('File', type) || hasType('Files', type)) {\n\t\t\t\t\t\tconst candidate = getSchemaValidator(type, {\n\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\tmodules: app.definitions.typebox,\n\t\t\t\t\t\t\tdynamic: !app.config.aot,\n\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\tmodels: app.definitions.type,\n\t\t\t\t\t\t\tnormalize: app.config.normalize,\n\t\t\t\t\t\t\tadditionalCoerce: coercePrimitiveRoot(),\n\t\t\t\t\t\t\tsanitize: () => app.config.sanitize\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif (candidate) {\n\t\t\t\t\t\t\tconst isFirst = fileUnions.length === 0\n\n\t\t\t\t\t\t\tconst iterator = Object.entries(\n\t\t\t\t\t\t\t\ttype.properties\n\t\t\t\t\t\t\t) as [string, TSchema][]\n\n\t\t\t\t\t\t\tlet validator = isFirst ? '\\n' : ' else '\n\t\t\t\t\t\t\tvalidator += `if(fileUnions[${fileUnions.length}].Check(c.body)){`\n\n\t\t\t\t\t\t\tlet validateFile = ''\n\t\t\t\t\t\t\tlet validatorLength = 0\n\t\t\t\t\t\t\tfor (let i = 0; i < iterator.length; i++) {\n\t\t\t\t\t\t\t\tconst [k, v] = iterator[i]\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!v.extension ||\n\t\t\t\t\t\t\t\t\t(v[Kind] !== 'File' && v[Kind] !== 'Files')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\t\tif (validatorLength) validateFile += ','\n\t\t\t\t\t\t\t\tvalidateFile += `validateFileExtension(c.body.${k},${JSON.stringify(v.extension)},'body.${k}')`\n\n\t\t\t\t\t\t\t\tvalidatorLength++\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (validateFile) {\n\t\t\t\t\t\t\t\tif (validatorLength === 1)\n\t\t\t\t\t\t\t\t\tvalidator += `await ${validateFile}\\n`\n\t\t\t\t\t\t\t\telse if (validatorLength > 1)\n\t\t\t\t\t\t\t\t\tvalidator += `await Promise.all([${validateFile}])\\n`\n\n\t\t\t\t\t\t\t\tvalidator += '}'\n\n\t\t\t\t\t\t\t\tfnLiteral += validator\n\t\t\t\t\t\t\t\tfileUnions.push(candidate)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\thasNonUnionFileWithDefault ||\n\t\t\t\t(!hasUnion &&\n\t\t\t\t\t(hasType(\n\t\t\t\t\t\t'File',\n\t\t\t\t\t\tunwrapImportSchema(validator.body.schema)\n\t\t\t\t\t) ||\n\t\t\t\t\t\thasType(\n\t\t\t\t\t\t\t'Files',\n\t\t\t\t\t\t\tunwrapImportSchema(validator.body.schema)\n\t\t\t\t\t\t)))\n\t\t\t) {\n\t\t\t\tlet validateFile = ''\n\n\t\t\t\tlet i = 0\n\t\t\t\tfor (const [k, v] of Object.entries(\n\t\t\t\t\tunwrapImportSchema(validator.body.schema).properties\n\t\t\t\t) as [string, TSchema][]) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!v.extension ||\n\t\t\t\t\t\t(v[Kind] !== 'File' && v[Kind] !== 'Files')\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif (i) validateFile += ','\n\t\t\t\t\tvalidateFile += `validateFileExtension(c.body.${k},${JSON.stringify(v.extension)},'body.${k}')`\n\n\t\t\t\t\ti++\n\t\t\t\t}\n\n\t\t\t\tif (i) fnLiteral += '\\n'\n\n\t\t\t\tif (i === 1) fnLiteral += `await ${validateFile}\\n`\n\t\t\t\telse if (i > 1)\n\t\t\t\t\tfnLiteral += `await Promise.all([${validateFile}])\\n`\n\t\t\t}\n\t\t}\n\n\t\tif (validator.cookie) {\n\t\t\t// ! Get latest app.config.cookie\n\t\t\tconst cookieValidator = getCookieValidator({\n\t\t\t\t// @ts-expect-error private property\n\t\t\t\tmodules: app.definitions.typebox,\n\t\t\t\tvalidator: validator.cookie as any,\n\t\t\t\tdefaultConfig: app.config.cookie,\n\t\t\t\tdynamic: !!app.config.aot,\n\t\t\t\tconfig: validator.cookie?.config ?? {},\n\t\t\t\tnormalize: app.config.normalize,\n\t\t\t\t// @ts-expect-error\n\t\t\t\tmodels: app.definitions.type\n\t\t\t})!\n\n\t\t\tfnLiteral +=\n\t\t\t\t`const cookieValue={}\\n` +\n\t\t\t\t`for(const [key,value] of Object.entries(c.cookie))` +\n\t\t\t\t`cookieValue[key]=value.value\\n`\n\n\t\t\tif (cookieValidator.hasDefault)\n\t\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\t\tValue.Default(cookieValidator.schema, {}) as Object\n\t\t\t\t)) {\n\t\t\t\t\tfnLiteral += `cookieValue['${key}'] = ${\n\t\t\t\t\t\ttypeof value === 'object'\n\t\t\t\t\t\t\t? JSON.stringify(value)\n\t\t\t\t\t\t\t: value\n\t\t\t\t\t}\\n`\n\t\t\t\t}\n\n\t\t\tif (cookieValidator.isOptional)\n\t\t\t\tfnLiteral += `if(isNotEmpty(c.cookie)){`\n\n\t\t\tif (validator.body?.schema?.noValidate !== true) {\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`if(validator.cookie.Check(cookieValue)===false){` +\n\t\t\t\t\tvalidation.validate('cookie', 'cookieValue') +\n\t\t\t\t\t'}'\n\t\t\t}\n\n\t\t\tif (cookieValidator.hasTransform)\n\t\t\t\tfnLiteral += coerceTransformDecodeError(\n\t\t\t\t\t`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))` +\n\t\t\t\t\t\t`c.cookie[key].value=value\\n`,\n\t\t\t\t\t'cookie'\n\t\t\t\t)\n\n\t\t\tif (cookieValidator.isOptional) fnLiteral += `}`\n\t\t}\n\t}\n\n\tif (hooks?.beforeHandle || hasTrace) {\n\t\tconst reporter = report('beforeHandle', {\n\t\t\ttotal: hooks.beforeHandle?.length\n\t\t})\n\n\t\tlet hasResolve = false\n\n\t\tif (hooks.beforeHandle?.length) {\n\t\t\tfor (let i = 0; i < hooks.beforeHandle.length; i++) {\n\t\t\t\tconst beforeHandle = hooks.beforeHandle[i]\n\n\t\t\t\tconst endUnit = reporter.resolveChild(beforeHandle.fn.name)\n\n\t\t\t\tconst returning = hasReturn(beforeHandle)\n\t\t\t\tconst isResolver =\n\t\t\t\t\tbeforeHandle.subType === 'resolve' ||\n\t\t\t\t\tbeforeHandle.subType === 'mapResolve'\n\n\t\t\t\tif (isResolver) {\n\t\t\t\t\tif (!hasResolve) {\n\t\t\t\t\t\thasResolve = true\n\t\t\t\t\t\tfnLiteral += '\\nlet resolved\\n'\n\t\t\t\t\t}\n\n\t\t\t\t\tfnLiteral += isAsync(beforeHandle)\n\t\t\t\t\t\t? `resolved=await e.beforeHandle[${i}](c);\\n`\n\t\t\t\t\t\t: `resolved=e.beforeHandle[${i}](c);\\n`\n\n\t\t\t\t\tif (beforeHandle.subType === 'mapResolve')\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(resolved instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\t\tmapResponse('resolved') +\n\t\t\t\t\t\t\t`}else{` +\n\t\t\t\t\t\t\t`resolved.request=c.request\\n` +\n\t\t\t\t\t\t\t`resolved.store=c.store\\n` +\n\t\t\t\t\t\t\t`resolved.qi=c.qi\\n` +\n\t\t\t\t\t\t\t`resolved.path=c.path\\n` +\n\t\t\t\t\t\t\t`resolved.url=c.url\\n` +\n\t\t\t\t\t\t\t`resolved.redirect=c.redirect\\n` +\n\t\t\t\t\t\t\t`resolved.set=c.set\\n` +\n\t\t\t\t\t\t\t`resolved.error=c.error\\n` +\n\t\t\t\t\t\t\t`c=resolved` +\n\t\t\t\t\t\t\t`}`\n\t\t\t\t\telse\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`if(resolved instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t\t\tmapResponse('resolved') +\n\t\t\t\t\t\t\t`}` +\n\t\t\t\t\t\t\t`else Object.assign(c, resolved)\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t} else if (!returning) {\n\t\t\t\t\tfnLiteral += isAsync(beforeHandle)\n\t\t\t\t\t\t? `await e.beforeHandle[${i}](c)\\n`\n\t\t\t\t\t\t: `e.beforeHandle[${i}](c)\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t} else {\n\t\t\t\t\tfnLiteral += isAsync(beforeHandle)\n\t\t\t\t\t\t? `be=await e.beforeHandle[${i}](c)\\n`\n\t\t\t\t\t\t: `be=e.beforeHandle[${i}](c)\\n`\n\n\t\t\t\t\tendUnit('be')\n\n\t\t\t\t\tfnLiteral += `if(be!==undefined){`\n\t\t\t\t\treporter.resolve()\n\n\t\t\t\t\tif (hooks.afterHandle?.length || hasTrace) {\n\t\t\t\t\t\treport('handle', {\n\t\t\t\t\t\t\tname: isHandleFn\n\t\t\t\t\t\t\t\t? (handler as Function).name\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}).resolve()\n\n\t\t\t\t\t\tconst reporter = report('afterHandle', {\n\t\t\t\t\t\t\ttotal: hooks.afterHandle?.length\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif(hooks.afterHandle?.length) {\n\t\t\t\t\t\t\tfor (let i = 0; i < hooks.afterHandle.length; i++) {\n\t\t\t\t\t\t\t\tconst hook = hooks.afterHandle[i]\n\t\t\t\t\t\t\t\tconst returning = hasReturn(hook)\n\t\t\t\t\t\t\t\tconst endUnit = reporter.resolveChild(hook.fn.name)\n\n\t\t\t\t\t\t\t\tfnLiteral += `c.response = be\\n`\n\n\t\t\t\t\t\t\t\tif (!returning) {\n\t\t\t\t\t\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t\t\t\t\t\t? `await e.afterHandle[${i}](c, be)\\n`\n\t\t\t\t\t\t\t\t\t\t: `e.afterHandle[${i}](c, be)\\n`\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t\t\t\t\t\t? `af=await e.afterHandle[${i}](c)\\n`\n\t\t\t\t\t\t\t\t\t\t: `af=e.afterHandle[${i}](c)\\n`\n\n\t\t\t\t\t\t\t\t\tfnLiteral += `if(af!==undefined) c.response=be=af\\n`\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tendUnit('af')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treporter.resolve()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (validator.response) fnLiteral += validation.response('be')\n\n\t\t\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t\t\t})\n\n\t\t\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\t\t\tfnLiteral += `c.response=be\\n`\n\n\t\t\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t\t`if(mr===undefined){` +\n\t\t\t\t\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t\t\t`if(mr!==undefined)be=c.response=mr` +\n\t\t\t\t\t\t\t\t'}'\n\n\t\t\t\t\t\t\tendUnit()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tmapResponseReporter.resolve()\n\n\t\t\t\t\tfnLiteral += encodeCookie()\n\t\t\t\t\tfnLiteral += `return mapEarlyResponse(${saveResponse}be,c.set${\n\t\t\t\t\t\tmapResponseContext\n\t\t\t\t\t})}\\n`\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\t}\n\n\tif (hooks.afterHandle?.length || hasTrace) {\n\t\tconst handleReporter = report('handle', {\n\t\t\tname: isHandleFn ? (handler as Function).name : undefined\n\t\t})\n\n\t\tif (hooks.afterHandle?.length)\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=c.response=await ${handle}\\n`\n\t\t\t\t: `let r=c.response=${handle}\\n`\n\t\telse\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=await ${handle}\\n`\n\t\t\t\t: `let r=${handle}\\n`\n\n\t\thandleReporter.resolve()\n\n\t\tconst reporter = report('afterHandle', {\n\t\t\ttotal: hooks.afterHandle?.length\n\t\t})\n\n\t\tif(hooks.afterHandle?.length) {\n\t\t\tfor (let i = 0; i < hooks.afterHandle.length; i++) {\n\t\t\t\tconst hook = hooks.afterHandle[i]\n\t\t\t\tconst returning = hasReturn(hook)\n\t\t\t\tconst endUnit = reporter.resolveChild(hook.fn.name)\n\n\t\t\t\tif (!returning) {\n\t\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t\t? `await e.afterHandle[${i}](c)\\n`\n\t\t\t\t\t\t: `e.afterHandle[${i}](c)\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t} else {\n\t\t\t\t\tfnLiteral += isAsync(hook.fn)\n\t\t\t\t\t\t? `af=await e.afterHandle[${i}](c)\\n`\n\t\t\t\t\t\t: `af=e.afterHandle[${i}](c)\\n`\n\n\t\t\t\t\tendUnit('af')\n\n\t\t\t\t\tif (validator.response) {\n\t\t\t\t\t\tfnLiteral += `if(af!==undefined){`\n\t\t\t\t\t\treporter.resolve()\n\n\t\t\t\t\t\tfnLiteral += validation.response('af')\n\n\t\t\t\t\t\tfnLiteral += `c.response=af}`\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfnLiteral += `if(af!==undefined){`\n\t\t\t\t\t\treporter.resolve()\n\n\t\t\t\t\t\tfnLiteral += `c.response=af}`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\n\t\tif (hooks.afterHandle?.length) fnLiteral += `r=c.response\\n`\n\n\t\tif (validator.response) fnLiteral += validation.response()\n\n\t\tfnLiteral += encodeCookie()\n\n\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\ttotal: hooks.mapResponse?.length\n\t\t})\n\t\tif (hooks.mapResponse?.length) {\n\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t)\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`mr=${\n\t\t\t\t\t\tisAsyncName(mapResponse) ? 'await ' : ''\n\t\t\t\t\t}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t`if(mr!==undefined)r=c.response=mr\\n`\n\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\t\tmapResponseReporter.resolve()\n\n\t\tfnLiteral += mapResponse()\n\t} else {\n\t\tconst handleReporter = report('handle', {\n\t\t\tname: isHandleFn ? (handler as Function).name : undefined\n\t\t})\n\n\t\tif (validator.response || hooks.mapResponse?.length || hasTrace) {\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=await ${handle}\\n`\n\t\t\t\t: `let r=${handle}\\n`\n\n\t\t\thandleReporter.resolve()\n\n\t\t\tif (validator.response) fnLiteral += validation.response()\n\n\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t})\n\n\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\tfnLiteral += '\\nc.response=r\\n'\n\n\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t)\n\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`\\nif(mr===undefined){` +\n\t\t\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t`if(mr!==undefined)r=c.response=mr` +\n\t\t\t\t\t\t`}\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapResponseReporter.resolve()\n\n\t\t\tfnLiteral += encodeCookie()\n\n\t\t\tif (handler instanceof Response) {\n\t\t\t\tfnLiteral += afterResponse()\n\n\t\t\t\tfnLiteral += inference.set\n\t\t\t\t\t? `if(` +\n\t\t\t\t\t\t`isNotEmpty(c.set.headers)||` +\n\t\t\t\t\t\t`c.set.status!==200||` +\n\t\t\t\t\t\t`c.set.redirect||` +\n\t\t\t\t\t\t`c.set.cookie)return mapResponse(${saveResponse}${handle}.clone(),c.set${\n\t\t\t\t\t\t\tmapResponseContext\n\t\t\t\t\t\t})\\n` +\n\t\t\t\t\t\t`else return ${handle}.clone()`\n\t\t\t\t\t: `return ${handle}.clone()`\n\n\t\t\t\tfnLiteral += '\\n'\n\t\t\t} else fnLiteral += mapResponse()\n\t\t} else if (hasCookie || hasTrace) {\n\t\t\tfnLiteral += isAsyncHandler\n\t\t\t\t? `let r=await ${handle}\\n`\n\t\t\t\t: `let r=${handle}\\n`\n\n\t\t\thandleReporter.resolve()\n\n\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t})\n\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\tfnLiteral += 'c.response= r\\n'\n\n\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t)\n\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`if(mr===undefined){` +\n\t\t\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t`if(mr!==undefined)r=c.response=mr` +\n\t\t\t\t\t\t`}`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapResponseReporter.resolve()\n\n\t\t\tfnLiteral += encodeCookie() + mapResponse()\n\t\t} else {\n\t\t\thandleReporter.resolve()\n\n\t\t\tconst handled = isAsyncHandler ? `await ${handle}` : handle\n\n\t\t\tif (handler instanceof Response) {\n\t\t\t\tfnLiteral += afterResponse()\n\n\t\t\t\tfnLiteral += inference.set\n\t\t\t\t\t? `if(isNotEmpty(c.set.headers)||` +\n\t\t\t\t\t\t`c.set.status!==200||` +\n\t\t\t\t\t\t`c.set.redirect||` +\n\t\t\t\t\t\t`c.set.cookie)` +\n\t\t\t\t\t\t`return mapResponse(${saveResponse}${handle}.clone(),c.set${\n\t\t\t\t\t\t\tmapResponseContext\n\t\t\t\t\t\t})\\n` +\n\t\t\t\t\t\t`else return ${handle}.clone()\\n`\n\t\t\t\t\t: `return ${handle}.clone()\\n`\n\t\t\t} else fnLiteral += mapResponse(handled)\n\t\t}\n\t}\n\n\tfnLiteral += `\\n}catch(error){`\n\n\tif (!maybeAsync && hooks.error?.length) fnLiteral += `return(async()=>{`\n\tfnLiteral +=\n\t\t`const set=c.set\\n` +\n\t\t`if(!set.status||set.status<300)set.status=error?.status||500\\n`\n\n\tif (hasCookie) fnLiteral += encodeCookie()\n\n\tif (hasTrace && hooks.trace)\n\t\tfor (let i = 0; i < hooks.trace.length; i++)\n\t\t\t// There's a case where the error is thrown before any trace is called\n\t\t\tfnLiteral += `report${i}?.resolve(error);reportChild${i}?.(error)\\n`\n\n\tconst errorReporter = report('error', {\n\t\ttotal: hooks.error?.length\n\t})\n\n\tif (hooks.error?.length) {\n\t\tfnLiteral += `c.error=error\\n`\n\n\t\tif (hasValidation)\n\t\t\tfnLiteral +=\n\t\t\t\t`if(error instanceof TypeBoxError){` +\n\t\t\t\t'c.code=\"VALIDATION\"\\n' +\n\t\t\t\t'c.set.status=422' +\n\t\t\t\t'}else{' +\n\t\t\t\t`c.code=error.code??error[ERROR_CODE]??\"UNKNOWN\"}`\n\t\telse fnLiteral += `c.code=error.code??error[ERROR_CODE]??\"UNKNOWN\"\\n`\n\n\t\tfnLiteral += `let er\\n`\n\t\t// Mapped error Response\n\t\tif (hooks.mapResponse?.length) fnLiteral += 'let mep\\n'\n\n\t\tfor (let i = 0; i < hooks.error.length; i++) {\n\t\t\tconst endUnit = errorReporter.resolveChild(hooks.error[i].fn.name)\n\n\t\t\tif (isAsync(hooks.error[i]))\n\t\t\t\tfnLiteral += `er=await e.error[${i}](c)\\n`\n\t\t\telse\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`er=e.error[${i}](c)\\n` +\n\t\t\t\t\t`if(er instanceof Promise)er=await er\\n`\n\n\t\t\tendUnit()\n\n\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\t\ttotal: hooks.mapResponse?.length\n\t\t\t\t})\n\n\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t)\n\n\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t`c.response=er\\n` +\n\t\t\t\t\t\t`mep=e.mapResponse[${i}](c)\\n` +\n\t\t\t\t\t\t`if(mep instanceof Promise)er=await er\\n` +\n\t\t\t\t\t\t`if(mep!==undefined)er=mep\\n`\n\n\t\t\t\t\tendUnit()\n\t\t\t\t}\n\t\t\t\tmapResponseReporter.resolve()\n\t\t\t}\n\n\t\t\tfnLiteral += `er=mapEarlyResponse(er,set${mapResponseContext})\\n`\n\t\t\tfnLiteral += `if(er){`\n\n\t\t\tif (hasTrace && hooks.trace) {\n\t\t\t\tfor (let i = 0; i < hooks.trace.length; i++)\n\t\t\t\t\tfnLiteral += `report${i}.resolve()\\n`\n\n\t\t\t\terrorReporter.resolve()\n\t\t\t}\n\n\t\t\tfnLiteral += `return er}`\n\t\t}\n\t}\n\n\terrorReporter.resolve()\n\n\tfnLiteral += `return handleError(c,error,true)`\n\tif (!maybeAsync && hooks.error?.length) fnLiteral += '})()'\n\tfnLiteral += '}'\n\n\tconst adapterVariables = adapter.inject\n\t\t? Object.keys(adapter.inject).join(',') + ','\n\t\t: ''\n\n\tlet init =\n\t\t`const {` +\n\t\t`handler,` +\n\t\t`handleError,` +\n\t\t`hooks:e, ` +\n\t\tallocateIf(`validator,`, hasValidation) +\n\t\t`mapResponse,` +\n\t\t`mapCompactResponse,` +\n\t\t`mapEarlyResponse,` +\n\t\t`isNotEmpty,` +\n\t\t`utils:{` +\n\t\tallocateIf(`parseQuery,`, hasBody) +\n\t\tallocateIf(`parseQueryFromURL,`, hasQuery) +\n\t\t`},` +\n\t\t`error:{` +\n\t\tallocateIf(`ValidationError,`, hasValidation) +\n\t\tallocateIf(`ParseError`, hasBody) +\n\t\t`},` +\n\t\t`validateFileExtension,` +\n\t\t`schema,` +\n\t\t`definitions,` +\n\t\t`ERROR_CODE,` +\n\t\tallocateIf(`parseCookie,`, hasCookie) +\n\t\tallocateIf(`signCookie,`, hasCookie) +\n\t\tallocateIf(`decodeURIComponent,`, hasQuery) +\n\t\t`ElysiaCustomStatusResponse,` +\n\t\tallocateIf(`ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tallocateIf('parser,', hooks.parse?.length) +\n\t\tallocateIf(`getServer,`, inference.server) +\n\t\tallocateIf(`fileUnions,`, fileUnions.length) +\n\t\tadapterVariables +\n\t\tallocateIf('TypeBoxError', hasValidation) +\n\t\t`}=hooks\\n` +\n\t\t`const trace=e.trace\\n` +\n\t\t`return ${maybeAsync ? 'async ' : ''}function handle(c){`\n\n\tif (hooks.beforeHandle?.length) init += 'let be\\n'\n\tif (hooks.afterHandle?.length) init += 'let af\\n'\n\tif (hooks.mapResponse?.length) init += 'let mr\\n'\n\tif (allowMeta) init += 'c.schema=schema\\nc.defs=definitions\\n'\n\n\tfnLiteral = init + fnLiteral + '}'\n\tinit = ''\n\n\ttry {\n\t\treturn Function(\n\t\t\t'hooks',\n\t\t\t'\"use strict\";\\n' + fnLiteral\n\t\t)({\n\t\t\thandler,\n\t\t\thooks: lifeCycleToFn(hooks),\n\t\t\tvalidator: hasValidation ? validator : undefined,\n\t\t\t// @ts-expect-error\n\t\t\thandleError: app.handleError,\n\t\t\tmapResponse: adapterHandler.mapResponse,\n\t\t\tmapCompactResponse: adapterHandler.mapCompactResponse,\n\t\t\tmapEarlyResponse: adapterHandler.mapEarlyResponse,\n\t\t\tisNotEmpty,\n\t\t\tutils: {\n\t\t\t\tparseQuery: hasBody ? parseQuery : undefined,\n\t\t\t\tparseQueryFromURL: hasQuery ? parseQueryFromURL : undefined\n\t\t\t},\n\t\t\terror: {\n\t\t\t\tValidationError: hasValidation ? ValidationError : undefined,\n\t\t\t\tParseError: hasBody ? ParseError : undefined\n\t\t\t},\n\t\t\tvalidateFileExtension,\n\t\t\tschema: app.router.history,\n\t\t\t// @ts-expect-error\n\t\t\tdefinitions: app.definitions.type,\n\t\t\tERROR_CODE,\n\t\t\tparseCookie: hasCookie ? parseCookie : undefined,\n\t\t\tsignCookie: hasCookie ? signCookie : undefined,\n\t\t\tdecodeURIComponent: hasQuery ? decode : undefined,\n\t\t\tElysiaCustomStatusResponse,\n\t\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\t\t// @ts-expect-error private property\n\t\t\tgetServer: inference.server ? () => app.getServer() : undefined,\n\t\t\tfileUnions: fileUnions.length ? fileUnions : undefined,\n\t\t\tTypeBoxError: hasValidation ? TypeBoxError : undefined,\n\t\t\tparser: app['~parser'],\n\t\t\t...adapter.inject\n\t\t})\n\t} catch (error) {\n\t\tconst debugHooks = lifeCycleToFn(hooks)\n\n\t\tconsole.log('[Composer] failed to generate optimized handler')\n\t\tconsole.log('---')\n\t\tconsole.log({\n\t\t\thandler:\n\t\t\t\ttypeof handler === 'function' ? handler.toString() : handler,\n\t\t\tinstruction: fnLiteral,\n\t\t\thooks: {\n\t\t\t\t...debugHooks,\n\t\t\t\t// @ts-ignore\n\t\t\t\ttransform: debugHooks?.transform?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\tresolve: debugHooks?.resolve?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\tbeforeHandle: debugHooks?.beforeHandle?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tafterHandle: debugHooks?.afterHandle?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tmapResponse: debugHooks?.mapResponse?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tparse: debugHooks?.parse?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\terror: debugHooks?.error?.map?.((x) => x.toString()),\n\t\t\t\t// @ts-ignore\n\t\t\t\tafterResponse: debugHooks?.afterResponse?.map?.((x) =>\n\t\t\t\t\tx.toString()\n\t\t\t\t),\n\t\t\t\t// @ts-ignore\n\t\t\t\tstop: debugHooks?.stop?.map?.((x) => x.toString())\n\t\t\t},\n\t\t\tvalidator,\n\t\t\t// @ts-expect-error\n\t\t\tdefinitions: app.definitions.type,\n\t\t\terror\n\t\t})\n\t\tconsole.log('---')\n\n\t\tprocess.exit(1)\n\t}\n}\n\nexport interface ComposerGeneralHandlerOptions {\n\t/**\n\t * optimization for standard internet hostname\n\t * this will assume hostname is always use a standard internet hostname\n\t * assuming hostname is at minimum of 11 length of string (http://a.bc)\n\t *\n\t * setting this to true will skip the first 11 character of the hostname\n\t *\n\t * @default true\n\t */\n\tstandardHostname?: boolean\n}\n\nexport const createOnRequestHandler = (\n\tapp: AnyElysia,\n\taddFn?: (word: string) => void\n) => {\n\tlet fnLiteral = ''\n\n\tconst report = createReport({\n\t\ttrace: app.event.trace,\n\t\taddFn:\n\t\t\taddFn ??\n\t\t\t((word) => {\n\t\t\t\tfnLiteral += word\n\t\t\t})\n\t})\n\n\tconst reporter = report('request', {\n\t\ttotal: app.event.request?.length\n\t})\n\n\tif (app.event.request?.length) {\n\t\tfnLiteral += `try{`\n\n\t\tfor (let i = 0; i < app.event.request.length; i++) {\n\t\t\tconst hook = app.event.request[i]\n\t\t\tconst withReturn = hasReturn(hook)\n\t\t\tconst maybeAsync = isAsync(hook)\n\n\t\t\tconst endUnit = reporter.resolveChild(app.event.request[i].fn.name)\n\n\t\t\tif (withReturn) {\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`re=mapEarlyResponse(` +\n\t\t\t\t\t`${maybeAsync ? 'await ' : ''}onRequest[${i}](c),` +\n\t\t\t\t\t`c.set)\\n`\n\n\t\t\t\tendUnit('re')\n\t\t\t\tfnLiteral += `if(re!==undefined)return re\\n`\n\t\t\t} else {\n\t\t\t\tfnLiteral += `${maybeAsync ? 'await ' : ''}onRequest[${i}](c)\\n`\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\n\t\tfnLiteral += `}catch(error){return app.handleError(c,error,false)}`\n\t}\n\n\treporter.resolve()\n\n\treturn fnLiteral\n}\n\nexport const createHoc = (app: AnyElysia, fnName = 'map') => {\n\t// @ts-expect-error private property\n\tconst hoc = app.extender.higherOrderFunctions\n\n\tif (!hoc.length) return 'return ' + fnName\n\n\tconst adapter = app['~adapter'].composeGeneralHandler\n\n\tlet handler = fnName\n\n\tfor (let i = 0; i < hoc.length; i++)\n\t\thandler = `hoc[${i}](${handler},${adapter.parameters})`\n\n\treturn `return function hocMap(${adapter.parameters}){return ${handler}(${adapter.parameters})}`\n}\n\nexport const composeGeneralHandler = (app: AnyElysia) => {\n\tconst adapter = app['~adapter'].composeGeneralHandler\n\tapp.router.http.build()\n\n\tconst hasTrace = app.event.trace?.length\n\n\tlet fnLiteral = ''\n\n\tconst router = app.router\n\n\tlet findDynamicRoute = router.http.root.WS\n\t\t? `const route=router.find(r.method === \"GET\" && r.headers.get('upgrade')==='websocket'?'WS':r.method,p)`\n\t\t: `const route=router.find(r.method,p)`\n\n\tfindDynamicRoute += router.http.root.ALL ? '??router.find(\"ALL\",p)\\n' : '\\n'\n\n\tlet afterResponse = `c.error=notFound\\n`\n\tif (app.event.afterResponse?.length && !app.event.error) {\n\t\tconst prefix = app.event.afterResponse.some(isAsync) ? 'async' : ''\n\t\tafterResponse += `\\nsetImmediate(${prefix}()=>{`\n\n\t\tfor (let i = 0; i < app.event.afterResponse.length; i++) {\n\t\t\tconst fn = app.event.afterResponse[i].fn\n\n\t\t\tafterResponse += `\\n${isAsyncName(fn) ? 'await ' : ''}afterResponse[${i}](c)\\n`\n\t\t}\n\n\t\tafterResponse += `})\\n`\n\t}\n\n\t// @ts-ignore\n\tif (app.inference.query)\n\t\tafterResponse +=\n\t\t\t'if(c.qi===-1){' +\n\t\t\t'c.query={}' +\n\t\t\t'}else{' +\n\t\t\t'c.query=parseQueryFromURL(c.url,c.qi+1)' +\n\t\t\t'}'\n\n\tconst error404 = adapter.error404(\n\t\t!!app.event.request?.length,\n\t\t!!app.event.error?.length,\n\t\tafterResponse\n\t)\n\n\tfindDynamicRoute += error404.code\n\n\tfindDynamicRoute +=\n\t\t`\\nc.params=route.params\\n` +\n\t\t`if(route.store.handler)return route.store.handler(c)\\n` +\n\t\t`return route.store.compile()(c)\\n`\n\n\tlet switchMap = ''\n\tfor (const [path, methods] of Object.entries(router.static)) {\n\t\tswitchMap += `case'${path}':`\n\n\t\tif (app.config.strictPath !== true)\n\t\t\tswitchMap += `case'${getLoosePath(path)}':`\n\n\t\tconst encoded = encodePath(path)\n\t\tif (path !== encoded) switchMap += `case'${encoded}':`\n\n\t\tswitchMap += 'switch(r.method){'\n\n\t\tif ('GET' in methods || 'WS' in methods) {\n\t\t\tswitchMap += `case 'GET':`\n\n\t\t\tif ('WS' in methods)\n\t\t\t\tswitchMap +=\n\t\t\t\t\t`if(r.headers.get('upgrade')==='websocket')` +\n\t\t\t\t\t`return ht[${methods.WS}].composed(c)\\n`\n\n\t\t\tif ('GET' in methods)\n\t\t\t\tswitchMap += `return ht[${methods.GET}].composed(c)\\n`\n\t\t}\n\n\t\tfor (const [method, index] of Object.entries(methods)) {\n\t\t\tif (method === 'ALL' || method === 'GET' || method === 'WS')\n\t\t\t\tcontinue\n\n\t\t\tswitchMap += `case '${method}':return ht[${index}].composed(c)\\n`\n\t\t}\n\n\t\tif ('ALL' in methods)\n\t\t\tswitchMap += `default:return ht[${methods.ALL}].composed(c)\\n`\n\t\telse switchMap += `default:break map\\n`\n\n\t\tswitchMap += '}'\n\t}\n\n\tconst maybeAsync = !!app.event.request?.some(isAsync)\n\n\tconst adapterVariables = adapter.inject\n\t\t? Object.keys(adapter.inject).join(',') + ','\n\t\t: ''\n\n\tfnLiteral +=\n\t\t`\\nconst {` +\n\t\t`app,` +\n\t\t`mapEarlyResponse,` +\n\t\t`NotFoundError,` +\n\t\t`randomId,` +\n\t\t`handleError,` +\n\t\t`status,` +\n\t\t`redirect,` +\n\t\t// @ts-ignore\n\t\tallocateIf(`parseQueryFromURL,`, app.inference.query) +\n\t\tallocateIf(`ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tadapterVariables +\n\t\t`}=data\\n` +\n\t\t`const store=app.singleton.store\\n` +\n\t\t`const decorator=app.singleton.decorator\\n` +\n\t\t`const staticRouter=app.router.static.http\\n` +\n\t\t`const ht=app.router.history\\n` +\n\t\t`const router=app.router.http\\n` +\n\t\t`const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[]\\n` +\n\t\t`const notFound=new NotFoundError()\\n` +\n\t\t`const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)\\n`\n\n\tif (app.event.request?.length)\n\t\tfnLiteral += `const onRequest=app.event.request.map(x=>x.fn)\\n`\n\n\tif (app.event.afterResponse?.length)\n\t\tfnLiteral += `const afterResponse=app.event.afterResponse.map(x=>x.fn)\\n`\n\n\tfnLiteral += error404.declare\n\n\tif (app.event.trace?.length)\n\t\tfnLiteral +=\n\t\t\t`const ` +\n\t\t\tapp.event.trace\n\t\t\t\t.map((_, i) => `tr${i}=app.event.trace[${i}].fn`)\n\t\t\t\t.join(',') +\n\t\t\t'\\n'\n\n\tfnLiteral += `${maybeAsync ? 'async ' : ''}function map(${adapter.parameters}){`\n\n\tif (app.event.request?.length) fnLiteral += `let re\\n`\n\n\tfnLiteral += adapter.createContext(app)\n\n\tif (app.event.trace?.length)\n\t\tfnLiteral +=\n\t\t\t`c[ELYSIA_TRACE]=[` +\n\t\t\tapp.event.trace.map((_, i) => `tr${i}(c)`).join(',') +\n\t\t\t`]\\n`\n\n\tfnLiteral += createOnRequestHandler(app)\n\n\tif (switchMap) fnLiteral += `\\nmap: switch(p){\\n` + switchMap + `}`\n\n\tfnLiteral += findDynamicRoute + `}\\n` + createHoc(app)\n\n\tconst handleError = composeErrorHandler(app)\n\n\t// @ts-expect-error private property\n\tapp.handleError = handleError\n\n\tconst fn = Function(\n\t\t'data',\n\t\t'\"use strict\";\\n' + fnLiteral\n\t)({\n\t\tapp,\n\t\tmapEarlyResponse: app['~adapter']['handler'].mapEarlyResponse,\n\t\tNotFoundError,\n\t\trandomId,\n\t\thandleError,\n\t\tstatus,\n\t\tredirect,\n\t\t// @ts-ignore\n\t\tparseQueryFromURL: app.inference.query ? parseQueryFromURL : undefined,\n\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\t...adapter.inject\n\t})\n\n\tif (isBun) Bun.gc(false)\n\n\treturn fn\n}\n\nexport const composeErrorHandler = (app: AnyElysia) => {\n\tconst hooks = app.event\n\tlet fnLiteral = ''\n\n\tconst adapter = app['~adapter'].composeError\n\tconst adapterVariables = adapter.inject\n\t\t? Object.keys(adapter.inject).join(',') + ','\n\t\t: ''\n\n\tconst hasTrace = !!app.event.trace?.length\n\n\tfnLiteral +=\n\t\t`const {` +\n\t\t`mapResponse,` +\n\t\t`ERROR_CODE,` +\n\t\t`ElysiaCustomStatusResponse,` +\n\t\tallocateIf(`onError,`, app.event.error) +\n\t\tallocateIf(`afterResponse,`, app.event.afterResponse) +\n\t\tallocateIf(`trace,`, app.event.trace) +\n\t\tallocateIf(`onMapResponse,`, app.event.mapResponse) +\n\t\tallocateIf(`ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tadapterVariables +\n\t\t`}=inject\\n`\n\n\tfnLiteral += `return ${\n\t\tapp.event.error?.find(isAsync) || app.event.mapResponse?.find(isAsync)\n\t\t\t? 'async '\n\t\t\t: ''\n\t}function(context,error,skipGlobal){`\n\n\tfnLiteral += ''\n\n\tif (hasTrace) fnLiteral += 'const id=context[ELYSIA_REQUEST_ID]\\n'\n\n\tconst report = createReport({\n\t\tcontext: 'context',\n\t\ttrace: hooks.trace,\n\t\taddFn: (word) => {\n\t\t\tfnLiteral += word\n\t\t}\n\t})\n\n\tconst afterResponse = () => {\n\t\tif (!hooks.afterResponse?.length && !hasTrace) return ''\n\n\t\tlet afterResponse = ''\n\t\tconst prefix = hooks.afterResponse?.some(isAsync) ? 'async' : ''\n\t\tafterResponse += `\\nsetImmediate(${prefix}()=>{`\n\n\t\tconst reporter = createReport({\n\t\t\tcontext: 'context',\n\t\t\ttrace: hooks.trace,\n\t\t\taddFn: (word) => {\n\t\t\t\tafterResponse += word\n\t\t\t}\n\t\t})('afterResponse', {\n\t\t\ttotal: hooks.afterResponse?.length,\n\t\t\tname: 'context'\n\t\t})\n\n\t\tif (hooks.afterResponse?.length && hooks.afterResponse) {\n\t\t\tfor (let i = 0; i < hooks.afterResponse.length; i++) {\n\t\t\t\tconst fn = hooks.afterResponse[i].fn\n\t\t\t\tconst endUnit = reporter.resolveChild(fn.name)\n\n\t\t\t\tafterResponse += `\\n${isAsyncName(fn) ? 'await ' : ''}afterResponse[${i}](context)\\n`\n\n\t\t\t\tendUnit()\n\t\t\t}\n\t\t}\n\n\t\treporter.resolve()\n\n\t\tafterResponse += `})\\n`\n\n\t\treturn afterResponse\n\t}\n\n\tfnLiteral +=\n\t\t`const set=context.set\\n` +\n\t\t`let _r\\n` +\n\t\t`if(!context.code)context.code=error.code??error[ERROR_CODE]\\n` +\n\t\t`if(!(context.error instanceof Error))context.error=error\\n` +\n\t\t`if(error instanceof ElysiaCustomStatusResponse){` +\n\t\t`set.status=error.status=error.code\\n` +\n\t\t`error.message=error.response` +\n\t\t`}`\n\n\tif (adapter.declare) fnLiteral += adapter.declare\n\n\tconst saveResponse =\n\t\thasTrace ||\n\t\t!!hooks.afterResponse?.length\n\t\t\t? 'context.response = '\n\t\t\t: ''\n\n\tif (app.event.error)\n\t\tfor (let i = 0; i < app.event.error.length; i++) {\n\t\t\tconst handler = app.event.error[i]\n\n\t\t\tconst response = `${\n\t\t\t\tisAsync(handler) ? 'await ' : ''\n\t\t\t}onError[${i}](context)\\n`\n\n\t\t\tfnLiteral += 'if(skipGlobal!==true){'\n\n\t\t\tif (hasReturn(handler)) {\n\t\t\t\tfnLiteral +=\n\t\t\t\t\t`_r=${response}\\nif(_r!==undefined){` +\n\t\t\t\t\t`if(_r instanceof Response){` +\n\t\t\t\t\tafterResponse() +\n\t\t\t\t\t`return mapResponse(_r,set${adapter.mapResponseContext})}` +\n\t\t\t\t\t`if(_r instanceof ElysiaCustomStatusResponse){` +\n\t\t\t\t\t`error.status=error.code\\n` +\n\t\t\t\t\t`error.message = error.response` +\n\t\t\t\t\t`}` +\n\t\t\t\t\t`if(set.status===200||!set.status)set.status=error.status\\n`\n\n\t\t\t\tconst mapResponseReporter = report('mapResponse', {\n\t\t\t\t\ttotal: hooks.mapResponse?.length,\n\t\t\t\t\tname: 'context'\n\t\t\t\t})\n\n\t\t\t\tif (hooks.mapResponse?.length) {\n\t\t\t\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\t\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\t\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\t\t\t\tmapResponse.fn.name\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tfnLiteral +=\n\t\t\t\t\t\t\t`context.response=_r` +\n\t\t\t\t\t\t\t`_r=${isAsyncName(mapResponse) ? 'await ' : ''}onMapResponse[${i}](context)\\n`\n\n\t\t\t\t\t\tendUnit()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmapResponseReporter.resolve()\n\n\t\t\t\tfnLiteral +=\n\t\t\t\t\tafterResponse() +\n\t\t\t\t\t`return mapResponse(${saveResponse}_r,set${adapter.mapResponseContext})}`\n\t\t\t} else fnLiteral += response\n\n\t\t\tfnLiteral += '}'\n\t\t}\n\n\tfnLiteral +=\n\t\t`if(error.constructor.name===\"ValidationError\"||error.constructor.name===\"TransformDecodeError\"){\\n` +\n\t\t`if(error.error)error=error.error\\n` +\n\t\t`set.status=error.status??422\\n` +\n\t\tafterResponse() +\n\t\tadapter.validationError +\n\t\t`\\n}\\n`\n\n\tfnLiteral +=\n\t\t`if(error instanceof Error){` +\n\t\tafterResponse() +\n\t\t`\\nif(typeof error.toResponse==='function')return context.response=error.toResponse()\\n` +\n\t\tadapter.unknownError +\n\t\t`\\n}`\n\n\tconst mapResponseReporter = report('mapResponse', {\n\t\ttotal: hooks.mapResponse?.length,\n\t\tname: 'context'\n\t})\n\n\tfnLiteral +=\n\t\t'\\nif(!context.response)context.response=error.message??error\\n'\n\n\tif (hooks.mapResponse?.length) {\n\t\tfnLiteral += 'let mr\\n'\n\n\t\tfor (let i = 0; i < hooks.mapResponse.length; i++) {\n\t\t\tconst mapResponse = hooks.mapResponse[i]\n\n\t\t\tconst endUnit = mapResponseReporter.resolveChild(\n\t\t\t\tmapResponse.fn.name\n\t\t\t)\n\n\t\t\tfnLiteral +=\n\t\t\t\t`if(mr===undefined){` +\n\t\t\t\t`mr=${isAsyncName(mapResponse) ? 'await ' : ''}onMapResponse[${i}](context)\\n` +\n\t\t\t\t`if(mr!==undefined)error=context.response=mr` +\n\t\t\t\t'}'\n\n\t\t\tendUnit()\n\t\t}\n\t}\n\n\tmapResponseReporter.resolve()\n\n\tfnLiteral +=\n\t\tafterResponse() +\n\t\t`\\nreturn mapResponse(${saveResponse}error,set${adapter.mapResponseContext})}`\n\n\tconst mapFn = (x: Function | HookContainer) =>\n\t\ttypeof x === 'function' ? x : x.fn\n\n\treturn Function(\n\t\t'inject',\n\t\t'\"use strict\";\\n' + fnLiteral\n\t)({\n\t\tmapResponse: app['~adapter'].handler.mapResponse,\n\t\tERROR_CODE,\n\t\tElysiaCustomStatusResponse,\n\t\tonError: app.event.error?.map(mapFn),\n\t\tafterResponse: app.event.afterResponse?.map(mapFn),\n\t\ttrace: app.event.trace?.map(mapFn),\n\t\tonMapResponse: app.event.mapResponse?.map(mapFn),\n\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\t...adapter.inject\n\t})\n}\n",
|
|
23
23
|
"import decode from 'fast-decode-uri-component'\n\n// Parse query without array\nexport function parseQueryFromURL(\n\tinput: string,\n\tstartIndex: number = 0\n): Record<string, string> {\n\tconst result = Object.create(null)\n\n\t// bit flags\n\tconst KEY_PLUS_FLAG = 1\n\tconst KEY_DECODE_FLAG = 2\n\tconst VALUE_PLUS_FLAG = 4\n\tconst VALUE_DECODE_FLAG = 8\n\n\tlet flags = 0\n\tlet startingIndex = startIndex - 1\n\tlet equalityIndex = startingIndex\n\tconst inputLength = input.length\n\n\t// Main parsing loop\n\tfor (let i = startIndex; i < inputLength; i++)\n\t\tswitch (input.charCodeAt(i)) {\n\t\t\t// '&'\n\t\t\tcase 38:\n\t\t\t\tprocessKeyValuePair(i)\n\n\t\t\t\t// Reset for next pair\n\t\t\t\tstartingIndex = i\n\t\t\t\tequalityIndex = i\n\t\t\t\tflags = 0\n\n\t\t\t\tbreak\n\n\t\t\t// '='\n\t\t\tcase 61:\n\t\t\t\tif (equalityIndex <= startingIndex) equalityIndex = i\n\t\t\t\telse flags |= VALUE_DECODE_FLAG\n\n\t\t\t\tbreak\n\n\t\t\t// '+'\n\t\t\tcase 43:\n\t\t\t\tif (equalityIndex > startingIndex) flags |= VALUE_PLUS_FLAG\n\t\t\t\telse flags |= KEY_PLUS_FLAG\n\n\t\t\t\tbreak\n\n\t\t\t// '%'\n\t\t\tcase 37:\n\t\t\t\tif (equalityIndex > startingIndex) flags |= VALUE_DECODE_FLAG\n\t\t\t\telse flags |= KEY_DECODE_FLAG\n\n\t\t\t\tbreak\n\t\t}\n\n\t// Process the last pair if there is one\n\tprocessKeyValuePair(inputLength)\n\n\treturn result\n\n\tfunction processKeyValuePair(endIndex: number) {\n\t\tconst hasBothKeyValuePair = equalityIndex > startingIndex\n\t\tconst keyEndIndex = hasBothKeyValuePair ? equalityIndex : endIndex\n\n\t\t// Extract and process key only if the slice is not empty\n\t\tif (keyEndIndex <= startingIndex + 1) return\n\n\t\tlet keySlice = input.slice(startingIndex + 1, keyEndIndex)\n\t\tif (flags & KEY_PLUS_FLAG) keySlice = keySlice.replace(/\\+/g, ' ')\n\t\tif (flags & KEY_DECODE_FLAG) keySlice = decode(keySlice) || keySlice\n\n\t\t// Only add to result if this key doesn't already exist\n\t\tif (result[keySlice] !== undefined) return\n\n\t\t// Process value if it exists\n\t\tlet finalValue = ''\n\t\tif (hasBothKeyValuePair) {\n\t\t\tfinalValue = input.slice(equalityIndex + 1, endIndex)\n\n\t\t\tif (flags & VALUE_PLUS_FLAG)\n\t\t\t\tfinalValue = finalValue.replace(/\\+/g, ' ')\n\t\t\tif (flags & VALUE_DECODE_FLAG)\n\t\t\t\tfinalValue = decode(finalValue) || finalValue\n\t\t}\n\n\t\tresult[keySlice] = finalValue\n\t}\n}\n\n/**\n * @callback parse\n * @param {string} input\n */\nexport function parseQuery(input: string) {\n\tconst result = Object.create(null) as Record<string, string | string[]>\n\n\t// bit flags\n\tlet flags = 0\n\tconst KEY_HAS_PLUS = 1\n\tconst KEY_NEEDS_DECODE = 2\n\tconst VALUE_HAS_PLUS = 4\n\tconst VALUE_NEEDS_DECODE = 8\n\n\tconst inputLength = input.length\n\tlet startingIndex = -1\n\tlet equalityIndex = -1\n\n\tfor (let i = 0; i < inputLength; i++)\n\t\tswitch (input.charCodeAt(i)) {\n\t\t\t// '&'\n\t\t\tcase 38:\n\t\t\t\tprocessKeyValuePair(input, i)\n\n\t\t\t\t// Reset state variables\n\t\t\t\tstartingIndex = i\n\t\t\t\tequalityIndex = i\n\t\t\t\tflags = 0\n\n\t\t\t\tbreak\n\n\t\t\t// '='\n\t\t\tcase 61:\n\t\t\t\tif (equalityIndex <= startingIndex) equalityIndex = i\n\t\t\t\t// If '=' character occurs again, we should decode the input\n\t\t\t\telse flags |= VALUE_NEEDS_DECODE\n\n\t\t\t\tbreak\n\n\t\t\t// '+'\n\t\t\tcase 43:\n\t\t\t\tif (equalityIndex > startingIndex) flags |= VALUE_HAS_PLUS\n\t\t\t\telse flags |= KEY_HAS_PLUS\n\n\t\t\t\tbreak\n\n\t\t\t// '%'\n\t\t\tcase 37:\n\t\t\t\tif (equalityIndex > startingIndex) flags |= VALUE_NEEDS_DECODE\n\t\t\t\telse flags |= KEY_NEEDS_DECODE\n\n\t\t\t\tbreak\n\t\t}\n\n\t// Process the last pair if needed\n\tif (startingIndex < inputLength) processKeyValuePair(input, inputLength)\n\n\treturn result\n\n\tfunction processKeyValuePair(input: string, endIndex: number) {\n\t\tconst hasBothKeyValuePair = equalityIndex > startingIndex\n\t\tconst effectiveEqualityIndex = hasBothKeyValuePair\n\t\t\t? equalityIndex\n\t\t\t: endIndex\n\n\t\tconst keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex)\n\n\t\t// Skip processing if key is empty\n\t\tif (!hasBothKeyValuePair && keySlice.length === 0) return\n\n\t\tlet finalKey = keySlice\n\t\tif (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\\+/g, ' ')\n\t\tif (flags & KEY_NEEDS_DECODE) finalKey = decode(finalKey) || finalKey\n\n\t\tlet finalValue = ''\n\t\tif (hasBothKeyValuePair) {\n\t\t\tlet valueSlice = input.slice(equalityIndex + 1, endIndex)\n\t\t\tif (flags & VALUE_HAS_PLUS)\n\t\t\t\tvalueSlice = valueSlice.replace(/\\+/g, ' ')\n\t\t\tif (flags & VALUE_NEEDS_DECODE)\n\t\t\t\tvalueSlice = decode(valueSlice) || valueSlice\n\t\t\tfinalValue = valueSlice\n\t\t}\n\n\t\tconst currentValue = result[finalKey]\n\t\tif (currentValue === undefined) result[finalKey] = finalValue\n\t\telse if (Array.isArray(currentValue)) currentValue.push(finalValue)\n\t\telse result[finalKey] = [currentValue, finalValue]\n\t}\n}\n",
|
|
24
24
|
"import { ELYSIA_REQUEST_ID } from './utils'\n\nimport type { Context } from './context'\nimport type { Prettify, RouteSchema, SingletonBase } from './types'\n\nexport type TraceEvent =\n\t| 'request'\n\t| 'parse'\n\t| 'transform'\n\t| 'beforeHandle'\n\t| 'handle'\n\t| 'afterHandle'\n\t| 'mapResponse'\n\t| 'afterResponse'\n\t| 'error'\n\nexport type TraceStream = {\n\tid: number\n\tevent: TraceEvent\n\ttype: 'begin' | 'end'\n\tbegin: number\n\tname?: string\n\ttotal?: number\n}\n\ntype TraceEndDetail = {\n\t/**\n\t * Timestamp of a function after it's executed since the server start\n\t */\n\tend: TraceProcess<'end'>\n\t/**\n\t * Error that was thrown in the lifecycle\n\t */\n\terror: Error | null\n\t/**\n\t * Elapsed time of the lifecycle\n\t */\n\telapsed: number\n}\n\nexport type TraceProcess<\n\tType extends 'begin' | 'end' = 'begin' | 'end',\n\tWithChildren extends boolean = true\n> = Type extends 'begin'\n\t? Prettify<\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Function name\n\t\t\t\t */\n\t\t\t\tname: string\n\t\t\t\t/**\n\t\t\t\t * Timestamp of a function is called since the server start\n\t\t\t\t */\n\t\t\t\tbegin: number\n\t\t\t\t/**\n\t\t\t\t * Timestamp of a function after it's executed since the server start\n\t\t\t\t */\n\t\t\t\tend: Promise<number>\n\t\t\t\t/**\n\t\t\t\t * Error that was thrown in the lifecycle\n\t\t\t\t */\n\t\t\t\terror: Promise<Error | null>\n\t\t\t\t/**\n\t\t\t\t * Listener to intercept the end of the lifecycle\n\t\t\t\t *\n\t\t\t\t * If you want to mutate the context, you must do it in this function\n\t\t\t\t * as there's a lock mechanism to ensure the context is mutate successfully\n\t\t\t\t */\n\t\t\t\tonStop(\n\t\t\t\t\t/**\n\t\t\t\t\t * A callback function that will be called when the function ends\n\t\t\t\t\t *\n\t\t\t\t\t * If you want to mutate the context, you must do it in this function\n\t\t\t\t\t * as there's a lock mechanism to ensure the context is mutate successfully\n\t\t\t\t\t */\n\t\t\t\t\tcallback?: (detail: TraceEndDetail) => unknown\n\t\t\t\t): Promise<void>\n\t\t\t} & (WithChildren extends true\n\t\t\t\t? {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * total number of lifecycle's children and\n\t\t\t\t\t\t * total number of `onEvent` will be called\n\t\t\t\t\t\t * if there were no early exists or error thrown\n\t\t\t\t\t\t */\n\t\t\t\t\t\ttotal: number\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Listener to intercept each child lifecycle\n\t\t\t\t\t\t */\n\t\t\t\t\t\tonEvent(\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * Callback function that will be called for when each child start\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tcallback?: (\n\t\t\t\t\t\t\t\tprocess: TraceProcess<'begin', false>\n\t\t\t\t\t\t\t) => unknown\n\t\t\t\t\t\t): Promise<void>\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Index of the child event\n\t\t\t\t\t\t */\n\t\t\t\t\t\tindex: number\n\t\t\t\t\t})\n\t\t>\n\t: number\n\nexport type TraceListener = (\n\tcallback?: (process: TraceProcess<'begin'>) => unknown\n) => Promise<TraceProcess<'begin'>>\n\nexport type TraceHandler<\n\tin out Route extends RouteSchema = {},\n\tin out Singleton extends SingletonBase = {\n\t\tdecorator: {}\n\t\tstore: {}\n\t\tderive: {}\n\t\tresolve: {}\n\t}\n> = {\n\t(\n\t\tlifecycle: Prettify<\n\t\t\t{\n\t\t\t\tid: number\n\t\t\t\tcontext: Context<Route, Singleton>\n\t\t\t\tset: Context['set']\n\t\t\t\ttime: number\n\t\t\t\tstore: Singleton['store']\n\t\t\t\tresponse: unknown\n\t\t\t} & {\n\t\t\t\t[x in `on${Capitalize<TraceEvent>}`]: TraceListener\n\t\t\t}\n\t\t>\n\t): unknown\n}\n\nexport const ELYSIA_TRACE = Symbol('ElysiaTrace')\n\nconst createProcess = () => {\n\tconst { promise, resolve } = Promise.withResolvers<TraceProcess>()\n\tconst { promise: end, resolve: resolveEnd } =\n\t\tPromise.withResolvers<number>()\n\tconst { promise: error, resolve: resolveError } =\n\t\tPromise.withResolvers<Error | null>()\n\n\tconst callbacks = <Function[]>[]\n\tconst callbacksEnd = <Function[]>[]\n\n\treturn [\n\t\t(callback?: Function) => {\n\t\t\tif (callback) callbacks.push(callback)\n\n\t\t\treturn promise\n\t\t},\n\t\t(process: TraceStream) => {\n\t\t\tconst processes = <((callback?: Function) => Promise<void>)[]>[]\n\t\t\tconst resolvers = <((process: TraceStream) => () => void)[]>[]\n\n\t\t\t// When error is return but not thrown\n\t\t\tlet groupError: Error | null = null\n\n\t\t\tfor (let i = 0; i < (process.total ?? 0); i++) {\n\t\t\t\tconst { promise, resolve } = Promise.withResolvers<void>()\n\t\t\t\tconst { promise: end, resolve: resolveEnd } =\n\t\t\t\t\tPromise.withResolvers<number>()\n\t\t\t\tconst { promise: error, resolve: resolveError } =\n\t\t\t\t\tPromise.withResolvers<Error | null>()\n\n\t\t\t\tconst callbacks = <Function[]>[]\n\t\t\t\tconst callbacksEnd = <Function[]>[]\n\n\t\t\t\tprocesses.push((callback?: Function) => {\n\t\t\t\t\tif (callback) callbacks.push(callback)\n\n\t\t\t\t\treturn promise\n\t\t\t\t})\n\n\t\t\t\tresolvers.push((process: TraceStream) => {\n\t\t\t\t\tconst result = {\n\t\t\t\t\t\t...process,\n\t\t\t\t\t\tend,\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tonStop(callback?: Function) {\n\t\t\t\t\t\t\tif (callback) callbacksEnd.push(callback)\n\n\t\t\t\t\t\t\treturn end\n\t\t\t\t\t\t}\n\t\t\t\t\t} as any\n\n\t\t\t\t\tresolve(result)\n\t\t\t\t\tfor (let i = 0; i < callbacks.length; i++)\n\t\t\t\t\t\tcallbacks[i](result)\n\n\t\t\t\t\treturn (error: Error | null = null) => {\n\t\t\t\t\t\tconst end = performance.now()\n\n\t\t\t\t\t\t// Catch return error\n\t\t\t\t\t\tif (error) groupError = error\n\n\t\t\t\t\t\tconst detail = {\n\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\tget elapsed() {\n\t\t\t\t\t\t\t\treturn end - process.begin\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (let i = 0; i < callbacksEnd.length; i++)\n\t\t\t\t\t\t\tcallbacksEnd[i](detail)\n\n\t\t\t\t\t\tresolveEnd(end)\n\t\t\t\t\t\tresolveError(error)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconst result = {\n\t\t\t\t...process,\n\t\t\t\tend,\n\t\t\t\terror,\n\t\t\t\tonEvent(callback?: Function) {\n\t\t\t\t\tfor (let i = 0; i < processes.length; i++)\n\t\t\t\t\t\tprocesses[i](callback)\n\t\t\t\t},\n\t\t\t\tonStop(callback?: Function) {\n\t\t\t\t\tif (callback) callbacksEnd.push(callback)\n\n\t\t\t\t\treturn end\n\t\t\t\t}\n\t\t\t} as any\n\n\t\t\tresolve(result)\n\t\t\tfor (let i = 0; i < callbacks.length; i++) callbacks[i](result)\n\n\t\t\treturn {\n\t\t\t\tresolveChild: resolvers,\n\t\t\t\tresolve(error: Error | null = null) {\n\t\t\t\t\tconst end = performance.now()\n\n\t\t\t\t\t// If error is return, parent group will not catch an error\n\t\t\t\t\t// but the child group will catch the error\n\t\t\t\t\tif (!error && groupError) error = groupError\n\n\t\t\t\t\tconst detail = {\n\t\t\t\t\t\tend,\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tget elapsed() {\n\t\t\t\t\t\t\treturn end - process.begin\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (let i = 0; i < callbacksEnd.length; i++)\n\t\t\t\t\t\tcallbacksEnd[i](detail)\n\n\t\t\t\t\tresolveEnd(end)\n\t\t\t\t\tresolveError(error)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t] as const\n}\n\nexport const createTracer = (traceListener: TraceHandler) => {\n\treturn (context: Context) => {\n\t\tconst [onRequest, resolveRequest] = createProcess()\n\t\tconst [onParse, resolveParse] = createProcess()\n\t\tconst [onTransform, resolveTransform] = createProcess()\n\t\tconst [onBeforeHandle, resolveBeforeHandle] = createProcess()\n\t\tconst [onHandle, resolveHandle] = createProcess()\n\t\tconst [onAfterHandle, resolveAfterHandle] = createProcess()\n\t\tconst [onError, resolveError] = createProcess()\n\t\tconst [onMapResponse, resolveMapResponse] = createProcess()\n\t\tconst [onAfterResponse, resolveAfterResponse] = createProcess()\n\n\t\ttraceListener({\n\t\t\t// @ts-ignore\n\t\t\tid: context[ELYSIA_REQUEST_ID],\n\t\t\tcontext,\n\t\t\tset: context.set,\n\t\t\t// @ts-ignore\n\t\t\tonRequest,\n\t\t\t// @ts-ignore\n\t\t\tonParse,\n\t\t\t// @ts-ignore\n\t\t\tonTransform,\n\t\t\t// @ts-ignore\n\t\t\tonBeforeHandle,\n\t\t\t// @ts-ignore\n\t\t\tonHandle,\n\t\t\t// @ts-ignore\n\t\t\tonAfterHandle,\n\t\t\t// @ts-ignore\n\t\t\tonMapResponse,\n\t\t\t// @ts-ignore\n\t\t\tonAfterResponse,\n\t\t\t// @ts-ignore\n\t\t\tonError,\n\t\t\ttime: Date.now(),\n\t\t\tstore: context.store\n\t\t})\n\n\t\t// ? This is pass to compiler\n\t\treturn {\n\t\t\trequest: resolveRequest,\n\t\t\tparse: resolveParse,\n\t\t\ttransform: resolveTransform,\n\t\t\tbeforeHandle: resolveBeforeHandle,\n\t\t\thandle: resolveHandle,\n\t\t\tafterHandle: resolveAfterHandle,\n\t\t\terror: resolveError,\n\t\t\tmapResponse: resolveMapResponse,\n\t\t\tafterResponse: resolveAfterResponse\n\t\t}\n\t}\n}\n",
|
|
25
25
|
"/* eslint-disable sonarjs/no-duplicate-string */\nimport {\n\tKind,\n\tOptionalKind,\n\tTModule,\n\tTObject,\n\tTransformKind,\n\tTSchema,\n\ttype TAnySchema\n} from '@sinclair/typebox'\nimport { Value } from '@sinclair/typebox/value'\nimport { TypeCompiler } from '@sinclair/typebox/compiler'\n\nimport {\n\tcreateMirror,\n\ttype Instruction as ExactMirrorInstruction\n} from 'exact-mirror'\n\nimport { t, type TypeCheck } from './type-system'\n\nimport { mergeCookie, randomId } from './utils'\nimport { mapValueError } from './error'\n\nimport type { CookieOptions } from './cookies'\nimport type {\n\tElysiaConfig,\n\tInputSchema,\n\tMaybeArray,\n\tStandaloneInputSchema\n} from './types'\n\ntype MapValueError = ReturnType<typeof mapValueError>\n\nexport interface ElysiaTypeCheck<T extends TSchema>\n\textends Omit<TypeCheck<T>, 'schema'> {\n\tschema: T\n\tconfig: Object\n\tClean?(v: unknown): T\n\tparse(v: unknown): T\n\tsafeParse(v: unknown):\n\t\t| { success: true; data: T; error: null }\n\t\t| {\n\t\t\t\tsuccess: false\n\t\t\t\tdata: null\n\t\t\t\terror: string | undefined\n\t\t\t\terrors: MapValueError[]\n\t\t }\n\thasAdditionalProperties: boolean\n\t'~hasAdditionalProperties'?: boolean\n\thasDefault: boolean\n\t'~hasDefault'?: boolean\n\tisOptional: boolean\n\t'~isOptional'?: boolean\n\thasTransform: boolean\n\t'~hasTransform'?: boolean\n\thasRef: boolean\n\t'~hasRef'?: boolean\n}\n\nexport const isOptional = (\n\tschema?: TSchema | TypeCheck<any> | ElysiaTypeCheck<any>\n) => {\n\tif (!schema) return false\n\n\t// @ts-ignore\n\tif (schema?.[Kind] === 'Import' && schema.References)\n\t\treturn schema.References().some(isOptional as any)\n\n\t// @ts-expect-error private property\n\tif (schema.schema)\n\t\t// @ts-expect-error private property\n\t\tschema = schema.schema\n\n\treturn !!schema && OptionalKind in schema\n}\n\nexport const hasAdditionalProperties = (\n\t_schema: TAnySchema | TypeCheck<any> | ElysiaTypeCheck<any>\n): boolean => {\n\tif (!_schema) return false\n\n\t// @ts-expect-error private property\n\tconst schema: TAnySchema = (_schema as TypeCheck<any>)?.schema ?? _schema\n\n\tif (schema[Kind] === 'Import' && _schema.References)\n\t\treturn _schema.References().some(hasAdditionalProperties)\n\n\tif (schema.anyOf) return schema.anyOf.some(hasAdditionalProperties)\n\tif (schema.someOf) return schema.someOf.some(hasAdditionalProperties)\n\tif (schema.allOf) return schema.allOf.some(hasAdditionalProperties)\n\tif (schema.not) return schema.not.some(hasAdditionalProperties)\n\n\tif (schema.type === 'object') {\n\t\tconst properties = schema.properties as Record<string, TAnySchema>\n\n\t\tif ('additionalProperties' in schema) return schema.additionalProperties\n\t\tif ('patternProperties' in schema) return false\n\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst property = properties[key]\n\n\t\t\tif (property.type === 'object') {\n\t\t\t\tif (hasAdditionalProperties(property)) return true\n\t\t\t} else if (property.anyOf) {\n\t\t\t\tfor (let i = 0; i < property.anyOf.length; i++)\n\t\t\t\t\tif (hasAdditionalProperties(property.anyOf[i])) return true\n\t\t\t}\n\n\t\t\treturn property.additionalProperties\n\t\t}\n\n\t\treturn false\n\t}\n\n\tif (schema.type === 'array' && schema.items && !Array.isArray(schema.items))\n\t\treturn hasAdditionalProperties(schema.items)\n\n\treturn false\n}\n\nexport const hasType = (type: string, schema: TAnySchema) => {\n\tif (!schema) return false\n\n\tif (Kind in schema && schema[Kind] === type) return true\n\n\tif (schema.type === 'object') {\n\t\tconst properties = schema.properties as Record<string, TAnySchema>\n\t\tif (!properties) return false\n\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst property = properties[key]\n\n\t\t\tif (property.type === 'object') {\n\t\t\t\tif (hasType(type, property)) return true\n\t\t\t} else if (property.anyOf) {\n\t\t\t\tfor (let i = 0; i < property.anyOf.length; i++)\n\t\t\t\t\tif (hasType(type, property.anyOf[i])) return true\n\t\t\t}\n\n\t\t\tif (Kind in property && property[Kind] === type) return true\n\t\t}\n\n\t\treturn false\n\t}\n\n\treturn (\n\t\t!!schema.properties &&\n\t\tKind in schema.properties &&\n\t\tschema.properties[Kind] === type\n\t)\n}\n\nexport const hasProperty = (\n\texpectedProperty: string,\n\t_schema: TAnySchema | TypeCheck<any> | ElysiaTypeCheck<any>\n) => {\n\tif (!_schema) return\n\n\t// @ts-expect-error private property\n\tconst schema = _schema.schema ?? _schema\n\n\tif (schema[Kind] === 'Import' && _schema.References)\n\t\treturn _schema\n\t\t\t.References()\n\t\t\t.some((schema: TAnySchema) => hasProperty(expectedProperty, schema))\n\n\tif (schema.type === 'object') {\n\t\tconst properties = schema.properties as Record<string, TAnySchema>\n\n\t\tif (!properties) return false\n\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst property = properties[key]\n\n\t\t\tif (expectedProperty in property) return true\n\n\t\t\tif (property.type === 'object') {\n\t\t\t\tif (hasProperty(expectedProperty, property)) return true\n\t\t\t} else if (property.anyOf)\n\t\t\t\tfor (let i = 0; i < property.anyOf.length; i++)\n\t\t\t\t\tif (hasProperty(expectedProperty, property.anyOf[i]))\n\t\t\t\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\treturn expectedProperty in schema\n}\n\nexport const hasRef = (schema: TAnySchema): boolean => {\n\tif (!schema) return false\n\n\tif (schema.oneOf)\n\t\tfor (let i = 0; i < schema.oneOf.length; i++)\n\t\t\tif (hasRef(schema.oneOf[i])) return true\n\n\tif (schema.anyOf)\n\t\tfor (let i = 0; i < schema.anyOf.length; i++)\n\t\t\tif (hasRef(schema.anyOf[i])) return true\n\n\tif (schema.oneOf)\n\t\tfor (let i = 0; i < schema.oneOf.length; i++)\n\t\t\tif (hasRef(schema.oneOf[i])) return true\n\n\tif (schema.allOf)\n\t\tfor (let i = 0; i < schema.allOf.length; i++)\n\t\t\tif (hasRef(schema.allOf[i])) return true\n\n\tif (schema.not && hasRef(schema.not)) return true\n\n\tif (schema.type === 'object' && schema.properties) {\n\t\tconst properties = schema.properties as Record<string, TAnySchema>\n\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst property = properties[key]\n\n\t\t\tif (hasRef(property)) return true\n\n\t\t\tif (\n\t\t\t\tproperty.type === 'array' &&\n\t\t\t\tproperty.items &&\n\t\t\t\thasRef(property.items)\n\t\t\t)\n\t\t\t\treturn true\n\t\t}\n\t}\n\n\tif (schema.type === 'array' && schema.items && hasRef(schema.items))\n\t\treturn true\n\n\treturn schema[Kind] === 'Ref' && '$ref' in schema\n}\n\nexport const hasTransform = (schema: TAnySchema): boolean => {\n\tif (!schema) return false\n\n\tif (\n\t\tschema.$ref &&\n\t\tschema.$defs &&\n\t\tschema.$ref in schema.$defs &&\n\t\thasTransform(schema.$defs[schema.$ref])\n\t)\n\t\treturn true\n\n\tif (schema.oneOf)\n\t\tfor (let i = 0; i < schema.oneOf.length; i++)\n\t\t\tif (hasTransform(schema.oneOf[i])) return true\n\n\tif (schema.anyOf)\n\t\tfor (let i = 0; i < schema.anyOf.length; i++)\n\t\t\tif (hasTransform(schema.anyOf[i])) return true\n\n\tif (schema.allOf)\n\t\tfor (let i = 0; i < schema.allOf.length; i++)\n\t\t\tif (hasTransform(schema.allOf[i])) return true\n\n\tif (schema.not && hasTransform(schema.not)) return true\n\n\tif (schema.type === 'object' && schema.properties) {\n\t\tconst properties = schema.properties as Record<string, TAnySchema>\n\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst property = properties[key]\n\n\t\t\tif (hasTransform(property)) return true\n\n\t\t\tif (\n\t\t\t\tproperty.type === 'array' &&\n\t\t\t\tproperty.items &&\n\t\t\t\thasTransform(property.items)\n\t\t\t)\n\t\t\t\treturn true\n\t\t}\n\t}\n\n\tif (schema.type === 'array' && schema.items && hasTransform(schema.items))\n\t\treturn true\n\n\treturn TransformKind in schema\n}\n\ninterface ReplaceSchemaTypeOptions {\n\tfrom: TSchema\n\tto(options: Object): TSchema | null\n\texcludeRoot?: boolean\n\trootOnly?: boolean\n\toriginal?: TAnySchema\n\t/**\n\t * Traverse until object is found except root object\n\t **/\n\tuntilObjectFound?: boolean\n\t/**\n\t * Only replace first object type\n\t **/\n\tonlyFirst?: 'object' | 'array' | (string & {})\n}\n\ninterface ReplaceSchemaTypeConfig {\n\troot: boolean\n\tdefinitions?: Record<string, TSchema> | undefined\n}\n\nexport const replaceSchemaType = (\n\tschema: TSchema,\n\toptions: MaybeArray<ReplaceSchemaTypeOptions>,\n\t_config: Partial<Omit<ReplaceSchemaTypeConfig, 'root'>> = {}\n) => {\n\tconst config = _config as ReplaceSchemaTypeConfig\n\tconfig.root = true\n\n\t// if (schema.$defs)\n\t// \tconfig.definitions = {\n\t// \t\t...config.definitions,\n\t// \t\t...schema.$defs\n\t// \t}\n\n\t// const corceDefinitions = (option: ReplaceSchemaTypeOptions) => {\n\t// \tif (!config.definitions) return\n\n\t// \tfor (const [key, value] of Object.entries(config.definitions)) {\n\t// \t\tconst fromSymbol = option.from[Kind]\n\n\t// \t\tif (fromSymbol === 'Ref') continue\n\n\t// \t\tconfig.definitions[key] = _replaceSchemaType(value, option, config)\n\t// \t}\n\t// }\n\n\tif (!Array.isArray(options)) {\n\t\toptions.original = schema\n\n\t\t// corceDefinitions(options)\n\n\t\treturn _replaceSchemaType(schema, options, config)\n\t}\n\n\tfor (const option of options) {\n\t\toption.original = schema\n\n\t\t// corceDefinitions(option)\n\n\t\tschema = _replaceSchemaType(schema, option, config)\n\t}\n\n\treturn schema\n}\n\nconst _replaceSchemaType = (\n\tschema: TSchema,\n\toptions: ReplaceSchemaTypeOptions,\n\tconfig: ReplaceSchemaTypeConfig\n): TSchema => {\n\tif (!schema) return schema\n\n\tconst root = config.root\n\n\tif (options.onlyFirst && schema.type === options.onlyFirst)\n\t\treturn options.to(schema) ?? schema\n\n\tif (options.untilObjectFound && !root && schema.type === 'object')\n\t\treturn schema\n\n\tconst fromSymbol = options.from[Kind]\n\n\t// if (schema.$ref) {\n\t// \tif (schema.$defs && schema.$ref in schema.$defs) {\n\t// \t\tconst definitions: Record<string, TSchema> = {}\n\n\t// \t\tfor (const [key, value] of Object.entries(schema.$defs))\n\t// \t\t\tdefinitions[key] = _replaceSchemaType(\n\t// \t\t\t\tvalue as TSchema,\n\t// \t\t\t\toptions,\n\t// \t\t\t\tconfig\n\t// \t\t\t)\n\n\t// \t\tconfig.definitions = { ...config.definitions, ...definitions }\n\t// \t}\n\n\t// \treturn schema\n\t// }\n\n\tif (schema.oneOf) {\n\t\tfor (let i = 0; i < schema.oneOf.length; i++)\n\t\t\tschema.oneOf[i] = _replaceSchemaType(\n\t\t\t\tschema.oneOf[i],\n\t\t\t\toptions,\n\t\t\t\tconfig\n\t\t\t)\n\n\t\treturn schema\n\t}\n\n\tif (schema.anyOf) {\n\t\tfor (let i = 0; i < schema.anyOf.length; i++)\n\t\t\tschema.anyOf[i] = _replaceSchemaType(\n\t\t\t\tschema.anyOf[i],\n\t\t\t\toptions,\n\t\t\t\tconfig\n\t\t\t)\n\n\t\treturn schema\n\t}\n\n\tif (schema.allOf) {\n\t\tfor (let i = 0; i < schema.allOf.length; i++)\n\t\t\tschema.allOf[i] = _replaceSchemaType(\n\t\t\t\tschema.allOf[i],\n\t\t\t\toptions,\n\t\t\t\tconfig\n\t\t\t)\n\n\t\treturn schema\n\t}\n\n\tif (schema.not) return _replaceSchemaType(schema.not, options, config)\n\n\tconst isRoot = root && !!options.excludeRoot\n\n\tif (schema[Kind] === fromSymbol) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tconst { anyOf, oneOf, allOf, not, properties, items, ...rest } = schema\n\n\t\tconst to = options.to(rest)\n\n\t\tif (!to) return schema\n\n\t\t// If t.Transform is used, we need to re-calculate Encode, Decode\n\t\tlet transform\n\n\t\tconst composeProperties = (schema: TSchema) => {\n\t\t\tconst v = _composeProperties(schema)\n\n\t\t\t// $id is removed because it's used in Union inside an Import\n\t\t\tif (v.$id) delete v.$id\n\n\t\t\treturn v\n\t\t}\n\n\t\tconst _composeProperties = (v: TSchema) => {\n\t\t\tif (properties && v.type === 'object') {\n\t\t\t\tconst newProperties = <Record<string, unknown>>{}\n\t\t\t\tfor (const [key, value] of Object.entries(properties))\n\t\t\t\t\tnewProperties[key] = _replaceSchemaType(\n\t\t\t\t\t\tvalue as TSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\t...v,\n\t\t\t\t\tproperties: newProperties\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (items && v.type === 'array')\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\t...v,\n\t\t\t\t\titems: _replaceSchemaType(items, options, {\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\troot: false\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\tconst value = {\n\t\t\t\t...rest,\n\t\t\t\t...v\n\t\t\t}\n\n\t\t\t// Remove required as it's not object\n\t\t\tdelete value['required']\n\n\t\t\t// Create default value for ObjectString\n\t\t\tif (\n\t\t\t\tproperties &&\n\t\t\t\tv.type === 'string' &&\n\t\t\t\tv.format === 'ObjectString' &&\n\t\t\t\tv.default === '{}'\n\t\t\t) {\n\t\t\t\ttransform = t.ObjectString(properties, rest)\n\t\t\t\tvalue.default = JSON.stringify(\n\t\t\t\t\tValue.Create(t.Object(properties))\n\t\t\t\t)\n\t\t\t\tvalue.properties = properties\n\t\t\t}\n\n\t\t\t// Create default value for ArrayString\n\t\t\tif (\n\t\t\t\titems &&\n\t\t\t\tv.type === 'string' &&\n\t\t\t\tv.format === 'ArrayString' &&\n\t\t\t\tv.default === '[]'\n\t\t\t) {\n\t\t\t\ttransform = t.ArrayString(items, rest)\n\t\t\t\tvalue.default = JSON.stringify(Value.Create(t.Array(items)))\n\t\t\t\tvalue.items = items\n\t\t\t}\n\n\t\t\treturn value\n\t\t}\n\n\t\tif (isRoot) {\n\t\t\tif (properties) {\n\t\t\t\tconst newProperties = <Record<string, unknown>>{}\n\t\t\t\tfor (const [key, value] of Object.entries(properties))\n\t\t\t\t\tnewProperties[key] = _replaceSchemaType(\n\t\t\t\t\t\tvalue as TSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\tproperties: newProperties\n\t\t\t\t}\n\t\t\t} else if (items?.map)\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\titems: items.map((v: TSchema) =>\n\t\t\t\t\t\t_replaceSchemaType(v, options, {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\treturn rest\n\t\t}\n\n\t\tif (to.anyOf)\n\t\t\tfor (let i = 0; i < to.anyOf.length; i++)\n\t\t\t\tto.anyOf[i] = composeProperties(to.anyOf[i])\n\t\telse if (to.oneOf)\n\t\t\tfor (let i = 0; i < to.oneOf.length; i++)\n\t\t\t\tto.oneOf[i] = composeProperties(to.oneOf[i])\n\t\telse if (to.allOf)\n\t\t\tfor (let i = 0; i < to.allOf.length; i++)\n\t\t\t\tto.allOf[i] = composeProperties(to.allOf[i])\n\t\telse if (to.not) to.not = composeProperties(to.not)\n\n\t\tif (transform) to[TransformKind as any] = transform[TransformKind]\n\n\t\tif (to.anyOf || to.oneOf || to.allOf || to.not) return to\n\n\t\tif (properties) {\n\t\t\tconst newProperties = <Record<string, unknown>>{}\n\t\t\tfor (const [key, value] of Object.entries(properties))\n\t\t\t\tnewProperties[key] = _replaceSchemaType(\n\t\t\t\t\tvalue as TSchema,\n\t\t\t\t\toptions,\n\t\t\t\t\t{\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\troot: false\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\treturn {\n\t\t\t\t...rest,\n\t\t\t\t...to,\n\t\t\t\tproperties: newProperties\n\t\t\t}\n\t\t} else if (items?.map)\n\t\t\treturn {\n\t\t\t\t...rest,\n\t\t\t\t...to,\n\t\t\t\titems: items.map((v: TSchema) =>\n\t\t\t\t\t_replaceSchemaType(v, options, {\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\troot: false\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t}\n\n\t\treturn {\n\t\t\t...rest,\n\t\t\t...to\n\t\t}\n\t}\n\n\tconst properties = schema?.properties as Record<string, TSchema>\n\n\tif (properties && root && options.rootOnly !== true)\n\t\tfor (const [key, value] of Object.entries(properties)) {\n\t\t\tswitch (value[Kind]) {\n\t\t\t\tcase fromSymbol:\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t\t\tconst { anyOf, oneOf, allOf, not, type, ...rest } = value\n\t\t\t\t\tconst to = options.to(rest)\n\n\t\t\t\t\tif (!to) return schema\n\n\t\t\t\t\tif (to.anyOf)\n\t\t\t\t\t\tfor (let i = 0; i < to.anyOf.length; i++)\n\t\t\t\t\t\t\tto.anyOf[i] = { ...rest, ...to.anyOf[i] }\n\t\t\t\t\telse if (to.oneOf)\n\t\t\t\t\t\tfor (let i = 0; i < to.oneOf.length; i++)\n\t\t\t\t\t\t\tto.oneOf[i] = { ...rest, ...to.oneOf[i] }\n\t\t\t\t\telse if (to.allOf)\n\t\t\t\t\t\tfor (let i = 0; i < to.allOf.length; i++)\n\t\t\t\t\t\t\tto.allOf[i] = { ...rest, ...to.allOf[i] }\n\t\t\t\t\telse if (to.not) to.not = { ...rest, ...to.not }\n\n\t\t\t\t\tproperties[key] = {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\t..._replaceSchemaType(rest, options, {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'Object':\n\t\t\t\tcase 'Union':\n\t\t\t\t\tproperties[key] = _replaceSchemaType(value, options, {\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\troot: false\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\n\t\t\t\tdefault:\n\t\t\t\t\tif (Array.isArray(value.items)) {\n\t\t\t\t\t\tfor (let i = 0; i < value.items.length; i++) {\n\t\t\t\t\t\t\tvalue.items[i] = _replaceSchemaType(\n\t\t\t\t\t\t\t\tvalue.items[i],\n\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tvalue.anyOf ||\n\t\t\t\t\t\tvalue.oneOf ||\n\t\t\t\t\t\tvalue.allOf ||\n\t\t\t\t\t\tvalue.not\n\t\t\t\t\t)\n\t\t\t\t\t\tproperties[key] = _replaceSchemaType(value, options, {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t})\n\t\t\t\t\telse if (value.type === 'array') {\n\t\t\t\t\t\tvalue.items = _replaceSchemaType(value.items, options, {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\troot: false\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\tif (schema.type === 'array' && schema.items)\n\t\tif (Array.isArray(schema.items))\n\t\t\tschema.items = schema.items.map((item) =>\n\t\t\t\t_replaceSchemaType(item, options, {\n\t\t\t\t\t...config,\n\t\t\t\t\troot: false\n\t\t\t\t})\n\t\t\t)\n\t\telse\n\t\t\tschema.items = _replaceSchemaType(schema.items, options, {\n\t\t\t\t...config,\n\t\t\t\troot: false\n\t\t\t})\n\n\treturn schema\n}\n\nconst createCleaner = (schema: TAnySchema) => (value: unknown) => {\n\tif (typeof value === 'object')\n\t\ttry {\n\t\t\treturn Value.Clean(schema, value)\n\t\t} catch {}\n\n\treturn value\n}\n\n// const caches = <Record<string, ElysiaTypeCheck<any>>>{}\n\nexport const getSchemaValidator = <T extends TSchema | string | undefined>(\n\ts: T,\n\t{\n\t\tmodels = {},\n\t\tdynamic = false,\n\t\tmodules,\n\t\tnormalize = false,\n\t\tadditionalProperties = false,\n\t\tcoerce = false,\n\t\tadditionalCoerce = [],\n\t\tvalidators,\n\t\tsanitize\n\t}: {\n\t\tmodels?: Record<string, TSchema>\n\t\tmodules?: TModule<any, any>\n\t\tadditionalProperties?: boolean\n\t\tdynamic?: boolean\n\t\tnormalize?: ElysiaConfig<''>['normalize']\n\t\tcoerce?: boolean\n\t\tadditionalCoerce?: MaybeArray<ReplaceSchemaTypeOptions>\n\t\tvalidators?: InputSchema['body'][]\n\t\tsanitize?: () => ExactMirrorInstruction['sanitize']\n\t} = {}\n): T extends TSchema ? ElysiaTypeCheck<T> : undefined => {\n\tvalidators = validators?.filter((x) => x)\n\n\tif (!s) {\n\t\tif (!validators?.length) return undefined as any\n\n\t\ts = validators[0] as any\n\t\tvalidators = validators.slice(1)\n\t}\n\n\tlet doesHaveRef: boolean | undefined = undefined\n\n\tconst replaceSchema = (schema: TAnySchema): TAnySchema => {\n\t\tif (coerce)\n\t\t\treturn replaceSchemaType(schema, [\n\t\t\t\t{\n\t\t\t\t\tfrom: t.Number(),\n\t\t\t\t\tto: (options) => t.Numeric(options),\n\t\t\t\t\tuntilObjectFound: true\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tfrom: t.Boolean(),\n\t\t\t\t\tto: (options) => t.BooleanString(options),\n\t\t\t\t\tuntilObjectFound: true\n\t\t\t\t},\n\t\t\t\t...(Array.isArray(additionalCoerce)\n\t\t\t\t\t? additionalCoerce\n\t\t\t\t\t: [additionalCoerce])\n\t\t\t])\n\n\t\treturn replaceSchemaType(schema, additionalCoerce)\n\t}\n\n\tconst mapSchema = (s: string | TSchema | undefined): TSchema => {\n\t\tlet schema: TSchema\n\n\t\tif (!s) return undefined as any\n\n\t\tif (typeof s !== 'string') schema = s\n\t\telse {\n\t\t\t// if (s in caches) return caches[s] as any\n\n\t\t\tconst isArray = s.endsWith('[]')\n\t\t\tconst key = isArray ? s.substring(0, s.length - 2) : s\n\n\t\t\tschema =\n\t\t\t\t(modules as TModule<{}, {}> | undefined)?.Import(\n\t\t\t\t\tkey as never\n\t\t\t\t) ?? models[key]\n\n\t\t\tif (isArray) schema = t.Array(schema)\n\t\t}\n\n\t\tif (!schema) return undefined as any\n\n\t\tlet _doesHaveRef: boolean\n\t\tif (schema[Kind] !== 'Import' && (_doesHaveRef = hasRef(schema))) {\n\t\t\tconst id = randomId()\n\n\t\t\tif (doesHaveRef === undefined) doesHaveRef = _doesHaveRef\n\n\t\t\tconst model: any = t.Module({\n\t\t\t\t// @ts-expect-error private property\n\t\t\t\t...modules?.$defs,\n\t\t\t\t[id]: schema\n\t\t\t})\n\n\t\t\tschema = model.Import(id)\n\t\t}\n\n\t\tif (schema[Kind] === 'Import') {\n\t\t\tconst newDefs: Record<string, TSchema> = {}\n\n\t\t\tfor (const [key, value] of Object.entries(schema.$defs))\n\t\t\t\tnewDefs[key] = replaceSchema(value as TSchema)\n\n\t\t\tconst key = schema.$ref\n\t\t\tschema = t.Module(newDefs).Import(key)\n\t\t} else if (coerce || additionalCoerce) schema = replaceSchema(schema)\n\n\t\treturn schema\n\t}\n\n\tlet schema = mapSchema(s)\n\n\tif (validators?.length) {\n\t\tlet hasAdditional = false\n\n\t\tconst { schema: mergedObjectSchema, notObjects } = mergeObjectSchemas([\n\t\t\tschema,\n\t\t\t...validators.map(mapSchema)\n\t\t])\n\n\t\tif (notObjects) {\n\t\t\tschema = t.Intersect([\n\t\t\t\t...(mergedObjectSchema ? [mergedObjectSchema] : []),\n\t\t\t\t...notObjects.map((x) => {\n\t\t\t\t\tconst schema = mapSchema(x)\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tschema.type === 'object' &&\n\t\t\t\t\t\t'additionalProperties' in schema\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!hasAdditional &&\n\t\t\t\t\t\t\tschema.additionalProperties === false\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thasAdditional = true\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tdelete schema.additionalProperties\n\t\t\t\t\t}\n\n\t\t\t\t\treturn schema\n\t\t\t\t})\n\t\t\t])\n\n\t\t\tif (schema.type === 'object' && hasAdditional)\n\t\t\t\tschema.additionalProperties = false\n\t\t}\n\t} else {\n\t\tif (\n\t\t\tschema.type === 'object' &&\n\t\t\t'additionalProperties' in schema === false\n\t\t)\n\t\t\tschema.additionalProperties = additionalProperties\n\t\telse\n\t\t\tschema = replaceSchemaType(schema, {\n\t\t\t\tonlyFirst: 'object',\n\t\t\t\tfrom: t.Object({}),\n\t\t\t\t// @ts-ignore\n\t\t\t\tto({ properties, ...options }) {\n\t\t\t\t\t// If nothing is return, use the original schema\n\t\t\t\t\tif (!properties) return\n\t\t\t\t\tif ('additionalProperties' in schema) return\n\n\t\t\t\t\treturn t.Object(properties, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tadditionalProperties: false\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t}\n\n\tif (dynamic) {\n\t\tconst validator: ElysiaTypeCheck<any> = {\n\t\t\tschema,\n\t\t\treferences: '',\n\t\t\tcheckFunc: () => {},\n\t\t\tcode: '',\n\t\t\t// @ts-expect-error\n\t\t\tCheck: (value: unknown) => Value.Check(schema, value),\n\t\t\tErrors: (value: unknown) => Value.Errors(schema, value),\n\t\t\tCode: () => '',\n\t\t\tClean: createCleaner(schema),\n\t\t\tDecode: (value: unknown) => Value.Decode(schema, value),\n\t\t\tEncode: (value: unknown) => Value.Encode(schema, value),\n\t\t\tget hasAdditionalProperties() {\n\t\t\t\tif ('~hasAdditionalProperties' in this)\n\t\t\t\t\treturn this['~hasAdditionalProperties'] as boolean\n\n\t\t\t\treturn (this['~hasAdditionalProperties'] =\n\t\t\t\t\thasAdditionalProperties(schema))\n\t\t\t},\n\t\t\tget hasDefault() {\n\t\t\t\tif ('~hasDefault' in this) return this['~hasDefault']\n\n\t\t\t\treturn (this['~hasDefault'] = hasProperty('default', schema))\n\t\t\t},\n\t\t\tget isOptional() {\n\t\t\t\tif ('~isOptional' in this) return this['~isOptional']!\n\n\t\t\t\treturn (this['~isOptional'] = isOptional(schema))\n\t\t\t},\n\t\t\tget hasTransform() {\n\t\t\t\tif ('~hasTransform' in this) return this['~hasTransform']!\n\n\t\t\t\treturn (this['~hasTransform'] = hasTransform(schema))\n\t\t\t},\n\t\t\t'~hasRef': doesHaveRef,\n\t\t\tget hasRef() {\n\t\t\t\tif ('~hasRef' in this) return this['~hasRef']!\n\n\t\t\t\treturn (this['~hasRef'] = hasTransform(schema))\n\t\t\t}\n\t\t}\n\n\t\tif (schema.config) {\n\t\t\tvalidator.config = schema.config\n\n\t\t\tif (validator?.schema?.config) delete validator.schema.config\n\t\t}\n\n\t\tif (normalize && schema.additionalProperties === false) {\n\t\t\tif (normalize === true || normalize === 'exactMirror') {\n\t\t\t\ttry {\n\t\t\t\t\tvalidator.Clean = createMirror(schema, {\n\t\t\t\t\t\tTypeCompiler,\n\t\t\t\t\t\tsanitize: sanitize?.(),\n\t\t\t\t\t\tmodules\n\t\t\t\t\t})\n\t\t\t\t} catch {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues'\n\t\t\t\t\t)\n\t\t\t\t\tconsole.warn(schema)\n\t\t\t\t\tvalidator.Clean = createCleaner(schema)\n\t\t\t\t}\n\t\t\t} else validator.Clean = createCleaner(schema)\n\t\t}\n\n\t\tvalidator.parse = (v) => {\n\t\t\ttry {\n\t\t\t\treturn validator.Decode(validator.Clean?.(v) ?? v)\n\t\t\t} catch (error) {\n\t\t\t\tthrow [...validator.Errors(v)].map(mapValueError)\n\t\t\t}\n\t\t}\n\n\t\tvalidator.safeParse = (v) => {\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: validator.Decode(validator.Clean?.(v) ?? v),\n\t\t\t\t\terror: null\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst errors = [...compiled.Errors(v)].map(mapValueError)\n\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tdata: null,\n\t\t\t\t\terror: errors[0]?.summary,\n\t\t\t\t\terrors\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// if (cacheKey) caches[cacheKey] = validator\n\n\t\treturn validator as any\n\t}\n\n\tconst compiled = TypeCompiler.Compile(\n\t\tschema,\n\t\tObject.values(models)\n\t) as any as ElysiaTypeCheck<any>\n\n\tif (schema.config) {\n\t\tcompiled.config = schema.config\n\n\t\tif (compiled?.schema?.config) delete compiled.schema.config\n\t}\n\n\tif (normalize === true || normalize === 'exactMirror') {\n\t\ttry {\n\t\t\tcompiled.Clean = createMirror(schema, {\n\t\t\t\tTypeCompiler,\n\t\t\t\tsanitize: sanitize?.(),\n\t\t\t\tmodules\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tconsole.warn(\n\t\t\t\t'Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues'\n\t\t\t)\n\t\t\tconsole.dir(schema, {\n\t\t\t\tdepth: null\n\t\t\t})\n\n\t\t\tcompiled.Clean = createCleaner(schema)\n\t\t}\n\t} else if (normalize === 'typebox') compiled.Clean = createCleaner(schema)\n\n\tcompiled.parse = (v) => {\n\t\ttry {\n\t\t\treturn compiled.Decode(compiled.Clean?.(v) ?? v)\n\t\t} catch (error) {\n\t\t\tthrow [...compiled.Errors(v)].map(mapValueError)\n\t\t}\n\t}\n\n\tcompiled.safeParse = (v) => {\n\t\ttry {\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: compiled.Decode(compiled.Clean?.(v) ?? v),\n\t\t\t\terror: null\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errors = [...compiled.Errors(v)].map(mapValueError)\n\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tdata: null,\n\t\t\t\terror: errors[0]?.summary,\n\t\t\t\terrors\n\t\t\t}\n\t\t}\n\t}\n\n\tObject.assign(compiled, {\n\t\tget hasAdditionalProperties() {\n\t\t\tif ('~hasAdditionalProperties' in this)\n\t\t\t\treturn this['~hasAdditionalProperties']\n\n\t\t\treturn (this['~hasAdditionalProperties'] =\n\t\t\t\thasAdditionalProperties(compiled))\n\t\t},\n\t\tget hasDefault() {\n\t\t\tif ('~hasDefault' in this) return this['~hasDefault']\n\n\t\t\treturn (this['~hasDefault'] = hasProperty('default', compiled))\n\t\t},\n\t\tget isOptional() {\n\t\t\tif ('~isOptional' in this) return this['~isOptional']!\n\n\t\t\treturn (this['~isOptional'] = isOptional(compiled))\n\t\t},\n\t\tget hasTransform() {\n\t\t\tif ('~hasTransform' in this) return this['~hasTransform']!\n\n\t\t\treturn (this['~hasTransform'] = hasTransform(schema))\n\t\t},\n\t\tget hasRef() {\n\t\t\tif ('~hasRef' in this) return this['~hasRef']!\n\n\t\t\treturn (this['~hasRef'] = hasRef(schema))\n\t\t},\n\t\t'~hasRef': doesHaveRef\n\t} as ElysiaTypeCheck<any>)\n\n\t// if (cacheKey) caches[cacheKey] = compiled\n\n\treturn compiled as any\n}\n\nexport const isUnion = (schema: TSchema) =>\n\tschema[Kind] === 'Union' || (!schema.schema && !!schema.anyOf)\n\nexport const mergeObjectSchemas = (\n\tschemas: TSchema[]\n): {\n\tschema: TObject | undefined\n\tnotObjects: TSchema[]\n} => {\n\tif (schemas.length === 0) {\n\t\treturn {\n\t\t\tschema: undefined,\n\t\t\tnotObjects: []\n\t\t}\n\t}\n\tif (schemas.length === 1)\n\t\treturn schemas[0].type === 'object'\n\t\t\t? {\n\t\t\t\t\tschema: schemas[0] as TObject,\n\t\t\t\t\tnotObjects: []\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tschema: undefined,\n\t\t\t\t\tnotObjects: schemas\n\t\t\t\t}\n\n\tlet newSchema: TObject\n\tconst notObjects = <TSchema[]>[]\n\n\tlet additionalPropertiesIsTrue = false\n\tlet additionalPropertiesIsFalse = false\n\n\tfor (const schema of schemas) {\n\t\tif (schema.type !== 'object') {\n\t\t\tnotObjects.push(schema)\n\t\t\tcontinue\n\t\t}\n\n\t\tif ('additionalProperties' in schema) {\n\t\t\tif (schema.additionalProperties === true)\n\t\t\t\tadditionalPropertiesIsTrue = true\n\t\t\telse if (schema.additionalProperties === false)\n\t\t\t\tadditionalPropertiesIsFalse = true\n\t\t}\n\n\t\tif (!newSchema!) {\n\t\t\tnewSchema = schema as TObject\n\t\t\tcontinue\n\t\t}\n\n\t\tnewSchema = {\n\t\t\t...newSchema,\n\t\t\t...schema,\n\t\t\tproperties: {\n\t\t\t\t...newSchema.properties,\n\t\t\t\t...schema.properties\n\t\t\t},\n\t\t\trequired: [...(newSchema?.required ?? []), ...schema.required]\n\t\t} as TObject\n\t}\n\n\tif (newSchema!) {\n\t\tif (newSchema.required)\n\t\t\tnewSchema.required = [...new Set(newSchema.required)]\n\n\t\tif (additionalPropertiesIsFalse) newSchema.additionalProperties = false\n\t\telse if (additionalPropertiesIsTrue)\n\t\t\tnewSchema.additionalProperties = true\n\t}\n\n\treturn {\n\t\tschema: newSchema!,\n\t\tnotObjects\n\t}\n}\n\nexport const getResponseSchemaValidator = (\n\ts: InputSchema['response'] | undefined,\n\t{\n\t\tmodels = {},\n\t\tmodules,\n\t\tdynamic = false,\n\t\tnormalize = false,\n\t\tadditionalProperties = false,\n\t\tvalidators = [],\n\t\tsanitize\n\t}: {\n\t\tmodules: TModule<any, any>\n\t\tmodels?: Record<string, TSchema>\n\t\tadditionalProperties?: boolean\n\t\tdynamic?: boolean\n\t\tnormalize?: ElysiaConfig<''>['normalize']\n\t\tvalidators?: StandaloneInputSchema['response'][]\n\t\tsanitize?: () => ExactMirrorInstruction['sanitize']\n\t}\n): Record<number, ElysiaTypeCheck<any>> | undefined => {\n\tvalidators = validators.filter((x) => x)\n\n\tif (!s) {\n\t\tif (!validators?.length) return undefined as any\n\n\t\ts = validators[0] as any\n\t\tvalidators = validators.slice(1)\n\t}\n\n\tlet maybeSchemaOrRecord: TSchema | Record<number, string | TSchema>\n\n\tif (typeof s !== 'string') maybeSchemaOrRecord = s!\n\telse {\n\t\tconst isArray = s.endsWith('[]')\n\t\tconst key = isArray ? s.substring(0, s.length - 2) : s\n\n\t\tmaybeSchemaOrRecord =\n\t\t\t(modules as TModule<{}, {}>).Import(key as never) ?? models[key]\n\n\t\tif (isArray)\n\t\t\tmaybeSchemaOrRecord = t.Array(maybeSchemaOrRecord as TSchema)\n\t}\n\n\tif (!maybeSchemaOrRecord) return\n\n\tif (Kind in maybeSchemaOrRecord) {\n\t\treturn {\n\t\t\t200: getSchemaValidator(maybeSchemaOrRecord, {\n\t\t\t\tmodules,\n\t\t\t\tmodels,\n\t\t\t\tadditionalProperties,\n\t\t\t\tdynamic,\n\t\t\t\tnormalize,\n\t\t\t\tcoerce: false,\n\t\t\t\tadditionalCoerce: [],\n\t\t\t\tvalidators: validators.map((x) => x![200]),\n\t\t\t\tsanitize\n\t\t\t})\n\t\t}\n\t}\n\n\tconst record: Record<number, ElysiaTypeCheck<any>> = {}\n\n\tObject.keys(maybeSchemaOrRecord).forEach((status): TSchema | undefined => {\n\t\tif (isNaN(+status)) return\n\n\t\tconst maybeNameOrSchema = maybeSchemaOrRecord[+status]\n\n\t\tif (typeof maybeNameOrSchema === 'string') {\n\t\t\tif (maybeNameOrSchema in models) {\n\t\t\t\tconst schema = models[maybeNameOrSchema]\n\n\t\t\t\t// Inherits model maybe already compiled\n\t\t\t\trecord[+status] =\n\t\t\t\t\tKind in schema\n\t\t\t\t\t\t? getSchemaValidator(schema, {\n\t\t\t\t\t\t\t\tmodules,\n\t\t\t\t\t\t\t\tmodels,\n\t\t\t\t\t\t\t\tadditionalProperties,\n\t\t\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\t\t\tcoerce: false,\n\t\t\t\t\t\t\t\tadditionalCoerce: [],\n\t\t\t\t\t\t\t\tvalidators: validators.map((x) => x![+status]),\n\t\t\t\t\t\t\t\tsanitize\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: schema\n\t\t\t}\n\n\t\t\treturn undefined\n\t\t}\n\n\t\t// Inherits model maybe already compiled\n\t\trecord[+status] =\n\t\t\tKind in maybeNameOrSchema\n\t\t\t\t? getSchemaValidator(maybeNameOrSchema as TSchema, {\n\t\t\t\t\t\tmodules,\n\t\t\t\t\t\tmodels,\n\t\t\t\t\t\tadditionalProperties,\n\t\t\t\t\t\tdynamic,\n\t\t\t\t\t\tnormalize,\n\t\t\t\t\t\tcoerce: false,\n\t\t\t\t\t\tadditionalCoerce: [],\n\t\t\t\t\t\tvalidators: validators.map((x) => x![+status]),\n\t\t\t\t\t\tsanitize\n\t\t\t\t\t})\n\t\t\t\t: maybeNameOrSchema\n\t})\n\n\treturn record\n}\n\nlet _stringToStructureCoercions: ReplaceSchemaTypeOptions[]\n\nexport const stringToStructureCoercions = () => {\n\tif (!_stringToStructureCoercions) {\n\t\t_stringToStructureCoercions = [\n\t\t\t{\n\t\t\t\tfrom: t.Object({}),\n\t\t\t\tto: () => t.ObjectString({}),\n\t\t\t\texcludeRoot: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tfrom: t.Array(t.Any()),\n\t\t\t\tto: () => t.ArrayString(t.Any())\n\t\t\t}\n\t\t] satisfies ReplaceSchemaTypeOptions[]\n\t}\n\n\treturn _stringToStructureCoercions\n}\n\nlet _coercePrimitiveRoot: ReplaceSchemaTypeOptions[]\n\nexport const coercePrimitiveRoot = () => {\n\tif (!_coercePrimitiveRoot)\n\t\t_coercePrimitiveRoot = [\n\t\t\t{\n\t\t\t\tfrom: t.Number(),\n\t\t\t\tto: (options) => t.Numeric(options),\n\t\t\t\trootOnly: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tfrom: t.Boolean(),\n\t\t\t\tto: (options) => t.BooleanString(options),\n\t\t\t\trootOnly: true\n\t\t\t}\n\t\t] satisfies ReplaceSchemaTypeOptions[]\n\n\treturn _coercePrimitiveRoot\n}\n\nexport const getCookieValidator = ({\n\tvalidator,\n\tmodules,\n\tdefaultConfig = {},\n\tconfig,\n\tdynamic,\n\tnormalize = false,\n\tmodels,\n\tvalidators,\n\tsanitize\n}: {\n\tvalidator: TSchema | string | undefined\n\tmodules: TModule<any, any>\n\tdefaultConfig: CookieOptions | undefined\n\tconfig: CookieOptions\n\tdynamic: boolean\n\tnormalize: ElysiaConfig<''>['normalize'] | undefined\n\tmodels: Record<string, TSchema> | undefined\n\tvalidators?: InputSchema['cookie'][]\n\tsanitize?: () => ExactMirrorInstruction['sanitize']\n}) => {\n\tlet cookieValidator = getSchemaValidator(validator, {\n\t\tmodules,\n\t\tdynamic,\n\t\tmodels,\n\t\tnormalize,\n\t\tadditionalProperties: true,\n\t\tcoerce: true,\n\t\tadditionalCoerce: stringToStructureCoercions(),\n\t\tvalidators,\n\t\tsanitize\n\t})\n\n\tif (cookieValidator)\n\t\tcookieValidator.config = mergeCookie(cookieValidator.config, config)\n\telse {\n\t\tcookieValidator = getSchemaValidator(t.Cookie(t.Any()), {\n\t\t\tmodules,\n\t\t\tdynamic,\n\t\t\tmodels,\n\t\t\tadditionalProperties: true,\n\t\t\tvalidators,\n\t\t\tsanitize\n\t\t})\n\n\t\tcookieValidator.config = defaultConfig\n\t}\n\n\treturn cookieValidator\n}\n\n/**\n * This function will return the type of unioned if all unioned type is the same.\n * It's intent to use for content-type mapping only\n *\n * ```ts\n * t.Union([\n * t.Object({\n * password: t.String()\n * }),\n * t.Object({\n * token: t.String()\n * })\n * ])\n * ```\n */\n// const getUnionedType = (validator: TypeCheck<any> | undefined) => {\n// \tif (!validator) return\n\n// \t// @ts-ignore\n// \tconst schema = validator?.schema ?? validator\n\n// \tif (schema && 'anyOf' in schema) {\n// \t\tlet foundDifference = false\n// \t\tconst type: string = schema.anyOf[0].type\n\n// \t\tfor (const validator of schema.anyOf as { type: string }[]) {\n// \t\t\tif (validator.type !== type) {\n// \t\t\t\tfoundDifference = true\n// \t\t\t\tbreak\n// \t\t\t}\n// \t\t}\n\n// \t\tif (!foundDifference) return type\n// \t}\n\n// \t// @ts-ignore\n// \treturn validator.schema?.type\n// }\n\nexport const unwrapImportSchema = (schema: TSchema): TSchema =>\n\tschema[Kind] === 'Import' && schema.$defs[schema.$ref][Kind] === 'Object'\n\t\t? schema.$defs[schema.$ref]\n\t\t: schema\n",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"import { mapEarlyResponse } from './handler'\nimport { sucrose, type Sucrose } from '../../sucrose'\nimport { createHoc, createOnRequestHandler, isAsync } from '../../compose'\n\nimport { randomId, ELYSIA_REQUEST_ID, redirect, isNotEmpty } from '../../utils'\nimport { status } from '../../error'\nimport { ELYSIA_TRACE } from '../../trace'\n\nimport type { AnyElysia } from '../..'\nimport type { InternalRoute } from '../../types'\n\nconst allocateIf = (value: string, condition: unknown) =>\n\tcondition ? value : ''\n\nconst createContext = (\n\tapp: AnyElysia,\n\troute: InternalRoute,\n\tinference: Sucrose.Inference,\n\tisInline = false\n) => {\n\tlet fnLiteral = ''\n\n\t// @ts-expect-error private\n\tconst defaultHeaders = app.setHeaders\n\n\tconst hasTrace = !!app.event.trace?.length\n\tif (hasTrace) fnLiteral += `const id=randomId()\\n`\n\n\tconst isDynamic = /[:*]/.test(route.path)\n\n\tconst standardHostname = app.config.handler?.standardHostname ?? true\n\n\tconst getQi =\n\t\t`const u=request.url,` +\n\t\t`s=u.indexOf('/',${standardHostname ? 11 : 7}),` +\n\t\t`qi=u.indexOf('?', s + 1)\\n`\n\n\tconst needsQuery =\n\t\tinference.query ||\n\t\t!!route.hooks.query ||\n\t\t!!route.standaloneValidators?.find((x) => x.query) ||\n\t\tapp.event.request?.length\n\n\tif (needsQuery) fnLiteral += getQi\n\n\tconst getPath = !inference.path\n\t\t? ''\n\t\t: !isDynamic\n\t\t\t? `path:'${route.path}',`\n\t\t\t: `get path(){` +\n\t\t\t\t(needsQuery ? '' : getQi) +\n\t\t\t\t`if(qi===-1)return u.substring(s)\\n` +\n\t\t\t\t`return u.substring(s,qi)\\n` +\n\t\t\t\t`},`\n\n\tfnLiteral +=\n\t\tallocateIf(`const c=`, !isInline) +\n\t\t`{request,` +\n\t\t`store,` +\n\t\tallocateIf(`qi,`, needsQuery) +\n\t\tallocateIf(`params:request.params,`, isDynamic) +\n\t\tgetPath +\n\t\tallocateIf(\n\t\t\t`url:request.url,`,\n\t\t\thasTrace || inference.url || needsQuery\n\t\t) +\n\t\t`redirect,` +\n\t\t`error:status,` +\n\t\t`status,` +\n\t\t`set:{headers:` +\n\t\t(isNotEmpty(defaultHeaders)\n\t\t\t? 'Object.assign({},app.setHeaders)'\n\t\t\t: 'Object.create(null)') +\n\t\t`,status:200}`\n\n\tif (inference.server) fnLiteral += `,get server(){return app.getServer()}`\n\n\tif (hasTrace) fnLiteral += ',[ELYSIA_REQUEST_ID]:id'\n\n\t{\n\t\tlet decoratorsLiteral = ''\n\t\t// @ts-expect-error private\n\t\tfor (const key of Object.keys(app.singleton.decorator))\n\t\t\tdecoratorsLiteral += `,'${key}':decorator['${key}']`\n\n\t\tfnLiteral += decoratorsLiteral\n\t}\n\n\tfnLiteral += `}\\n`\n\n\treturn fnLiteral\n}\n\nexport const createBunRouteHandler = (app: AnyElysia, route: InternalRoute) => {\n\tconst hasTrace = !!app.event.trace?.length\n\t// @ts-expect-error private property\n\tconst hasHoc = !!app.extender.higherOrderFunctions.length\n\n\tlet inference = sucrose(\n\t\troute.hooks,\n\t\t// @ts-expect-error\n\t\tapp.inference\n\t)\n\tinference = sucrose(\n\t\t{\n\t\t\thandler: route.handler\n\t\t},\n\t\tinference\n\t)\n\n\tlet fnLiteral =\n\t\t'const handler=data.handler,' +\n\t\t`app=data.app,` +\n\t\t'store=data.store,' +\n\t\t`decorator=data.decorator,` +\n\t\t'redirect=data.redirect,' +\n\t\t'route=data.route,' +\n\t\t'mapEarlyResponse=data.mapEarlyResponse,' +\n\t\tallocateIf('randomId=data.randomId,', hasTrace) +\n\t\tallocateIf(`ELYSIA_REQUEST_ID=data.ELYSIA_REQUEST_ID,`, hasTrace) +\n\t\tallocateIf(`ELYSIA_TRACE=data.ELYSIA_TRACE,`, hasTrace) +\n\t\tallocateIf(`trace=data.trace,`, hasTrace) +\n\t\tallocateIf(`hoc=data.hoc,`, hasHoc) +\n\t\t'status=data.status\\n'\n\n\tif (app.event.request?.length)\n\t\tfnLiteral += `const onRequest=app.event.request.map(x=>x.fn)\\n`\n\n\tfnLiteral += `${app.event.request?.find(isAsync) ? 'async' : ''} function map(request){`\n\n\tconst needsQuery =\n\t\tinference.query ||\n\t\t!!route.hooks.query ||\n\t\t!!route.standaloneValidators?.find((x) => x.query)\n\n\t// inference.query require declaring const 'qi'\n\tif (hasTrace || needsQuery || app.event.request?.length) {\n\t\tfnLiteral += createContext(app, route, inference)\n\t\tfnLiteral += createOnRequestHandler(app)\n\n\t\tfnLiteral += 'return handler(c)}'\n\t} else\n\t\tfnLiteral += `return handler(${createContext(app, route, inference, true)})}`\n\n\tfnLiteral += createHoc(app)\n\n\treturn Function(\n\t\t'data',\n\t\tfnLiteral\n\t)({\n\t\tapp,\n\t\thandler: route.compile?.() ?? route.composed,\n\t\tredirect,\n\t\tstatus,\n\t\t// @ts-expect-error private property\n\t\thoc: app.extender.higherOrderFunctions.map((x) => x.fn),\n\t\tstore: app.store,\n\t\tdecorator: app.decorator,\n\t\troute: route.path,\n\t\trandomId: hasTrace ? randomId : undefined,\n\t\tELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined,\n\t\tELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined,\n\t\ttrace: hasTrace ? app.event.trace?.map((x) => x?.fn ?? x) : undefined,\n\t\tmapEarlyResponse: mapEarlyResponse\n\t})\n}\n",
|
|
28
28
|
"import { isHTMLBundle } from '.'\nimport type { Context } from '../../context'\nimport type { AnyLocalHook, MaybePromise } from '../../types'\n\nimport { mapResponse } from './handler'\n\nexport const createNativeStaticHandler = (\n\thandle: unknown,\n\thooks: AnyLocalHook,\n\tset?: Context['set']\n): (() => MaybePromise<Response>) | undefined => {\n\tif (typeof handle === 'function' || handle instanceof Blob) return\n\n\tif (isHTMLBundle(handle)) return () => handle as any\n\n\tconst response = mapResponse(\n\t\thandle,\n\t\tset ?? {\n\t\t\theaders: {}\n\t\t}\n\t)\n\n\tif (\n\t\t!hooks.parse?.length &&\n\t\t!hooks.transform?.length &&\n\t\t!hooks.beforeHandle?.length &&\n\t\t!hooks.afterHandle?.length\n\t) {\n\t\tif (response instanceof Promise)\n\t\t\treturn response.then((response) => {\n\t\t\t\tif (!response) return\n\n\t\t\t\tif (!response.headers.has('content-type'))\n\t\t\t\t\tresponse.headers.append('content-type', 'text/plain')\n\n\t\t\t\treturn response.clone()\n\t\t\t}) as any as () => Promise<Response>\n\n\t\tif (!response.headers.has('content-type'))\n\t\t\tresponse.headers.append('content-type', 'text/plain')\n\n\t\treturn () => response.clone() as Response\n\t}\n}\n",
|
|
29
29
|
"import { isNumericString } from '../utils'\n\nimport type {\n\tServerWebSocket,\n\tServerWebSocketSendStatus,\n\tBufferSource,\n\tWebSocketHandler\n} from './bun'\n\nimport type { TSchema } from '@sinclair/typebox'\nimport type { TypeCheck } from '../type-system'\nimport type { ElysiaTypeCheck } from '../schema'\n\nimport type { FlattenResponse, WSParseHandler } from './types'\nimport type { MaybeArray, Prettify, RouteSchema } from '../types'\nimport { ValidationError } from '../error'\n\nexport const websocket: WebSocketHandler<any> = {\n\topen(ws) {\n\t\tws.data.open?.(ws)\n\t},\n\tmessage(ws, message) {\n\t\tws.data.message?.(ws, message)\n\t},\n\tdrain(ws) {\n\t\tws.data.drain?.(ws)\n\t},\n\tclose(ws, code, reason) {\n\t\tws.data.close?.(ws, code, reason)\n\t}\n}\n\ntype ElysiaServerWebSocket = Omit<\n\tServerWebSocket<unknown>,\n\t'send' | 'ping' | 'pong' | 'publish'\n>\n\nexport class ElysiaWS<Context = unknown, Route extends RouteSchema = {}>\n\timplements ElysiaServerWebSocket\n{\n\tconstructor(\n\t\tpublic raw: ServerWebSocket<{\n\t\t\tid?: string\n\t\t\tvalidator?: TypeCheck<TSchema>\n\t\t}>,\n\t\tpublic data: Prettify<\n\t\t\tOmit<Context, 'body' | 'error' | 'status' | 'redirect'>\n\t\t>,\n\t\tpublic body: Route['body'] = undefined\n\t) {\n\t\tthis.validator = raw.data?.validator\n\n\t\tthis.sendText = raw.sendText.bind(raw)\n\t\tthis.sendBinary = raw.sendBinary.bind(raw)\n\t\tthis.close = raw.close.bind(raw)\n\t\tthis.terminate = raw.terminate.bind(raw)\n\t\tthis.publishText = raw.publishText.bind(raw)\n\t\tthis.publishBinary = raw.publishBinary.bind(raw)\n\t\tthis.subscribe = raw.subscribe.bind(raw)\n\t\tthis.unsubscribe = raw.unsubscribe.bind(raw)\n\t\tthis.isSubscribed = raw.isSubscribed.bind(raw)\n\t\tthis.cork = raw.cork.bind(raw)\n\t\tthis.remoteAddress = raw.remoteAddress\n\t\tthis.binaryType = raw.binaryType\n\t\tthis.data = raw.data as any\n\n\t\tthis.send = this.send.bind(this)\n\t\tthis.ping = this.ping.bind(this)\n\t\tthis.pong = this.pong.bind(this)\n\t\tthis.publish = this.publish.bind(this)\n\t}\n\n\t/**\n\t * Sends a message to the client.\n\t *\n\t * @param data The data to send.\n\t * @param compress Should the data be compressed? If the client does not support compression, this is ignored.\n\t * @example\n\t * ws.send(\"Hello!\");\n\t * ws.send(\"Compress this.\", true);\n\t * ws.send(new Uint8Array([1, 2, 3, 4]));\n\t */\n\tsend(\n\t\tdata: FlattenResponse<Route['response']> | BufferSource,\n\t\tcompress?: boolean\n\t): ServerWebSocketSendStatus {\n\t\tif (Buffer.isBuffer(data))\n\t\t\treturn this.raw.send(data as unknown as BufferSource, compress)\n\n\t\tif (this.validator?.Check(data) === false)\n\t\t\treturn this.raw.send(\n\t\t\t\tnew ValidationError('message', this.validator, data).message\n\t\t\t)\n\n\t\tif (typeof data === 'object') data = JSON.stringify(data) as any\n\n\t\treturn this.raw.send(data as unknown as string, compress)\n\t}\n\n\t/**\n\t * Sends a ping.\n\t *\n\t * @param data The data to send\n\t */\n\tping(\n\t\tdata?: FlattenResponse<Route['response']> | BufferSource\n\t): ServerWebSocketSendStatus {\n\t\tif (Buffer.isBuffer(data))\n\t\t\treturn this.raw.ping(data as unknown as BufferSource)\n\n\t\tif (this.validator?.Check(data) === false)\n\t\t\treturn this.raw.send(\n\t\t\t\tnew ValidationError('message', this.validator, data).message\n\t\t\t)\n\n\t\tif (typeof data === 'object') data = JSON.stringify(data) as any\n\n\t\treturn this.raw.ping(data as string)\n\t}\n\n\t/**\n\t * Sends a pong.\n\t *\n\t * @param data The data to send\n\t */\n\tpong(\n\t\tdata?: FlattenResponse<Route['response']> | BufferSource\n\t): ServerWebSocketSendStatus {\n\t\tif (Buffer.isBuffer(data))\n\t\t\treturn this.raw.pong(data as unknown as BufferSource)\n\n\t\tif (this.validator?.Check(data) === false)\n\t\t\treturn this.raw.send(\n\t\t\t\tnew ValidationError('message', this.validator, data).message\n\t\t\t)\n\n\t\tif (typeof data === 'object') data = JSON.stringify(data) as any\n\n\t\treturn this.raw.pong(data as string)\n\t}\n\n\t/**\n\t * Sends a message to subscribers of the topic.\n\t *\n\t * @param topic The topic name.\n\t * @param data The data to send.\n\t * @param compress Should the data be compressed? If the client does not support compression, this is ignored.\n\t * @example\n\t * ws.publish(\"chat\", \"Hello!\");\n\t * ws.publish(\"chat\", \"Compress this.\", true);\n\t * ws.publish(\"chat\", new Uint8Array([1, 2, 3, 4]));\n\t */\n\tpublish(\n\t\ttopic: string,\n\t\tdata: FlattenResponse<Route['response']> | BufferSource,\n\t\tcompress?: boolean\n\t): ServerWebSocketSendStatus {\n\t\tif (Buffer.isBuffer(data))\n\t\t\treturn this.raw.publish(\n\t\t\t\ttopic,\n\t\t\t\tdata as unknown as BufferSource,\n\t\t\t\tcompress\n\t\t\t)\n\n\t\tif (this.validator?.Check(data) === false)\n\t\t\treturn this.raw.send(\n\t\t\t\tnew ValidationError('message', this.validator, data).message\n\t\t\t)\n\n\t\tif (typeof data === 'object') data = JSON.stringify(data) as any\n\n\t\treturn this.raw.publish(topic, data as unknown as string, compress)\n\t}\n\n\tsendText: ServerWebSocket['sendText']\n\tsendBinary: ServerWebSocket['sendBinary']\n\tclose: ServerWebSocket['close']\n\tterminate: ServerWebSocket['terminate']\n\tpublishText: ServerWebSocket['publishText']\n\tpublishBinary: ServerWebSocket['publishBinary']\n\tsubscribe: ServerWebSocket['subscribe']\n\tunsubscribe: ServerWebSocket['unsubscribe']\n\tisSubscribed: ServerWebSocket['isSubscribed']\n\tcork: ServerWebSocket['cork']\n\tremoteAddress: ServerWebSocket['remoteAddress']\n\tbinaryType: ServerWebSocket['binaryType']\n\n\tget readyState() {\n\t\treturn this.raw.readyState\n\t}\n\n\tvalidator?: TypeCheck<TSchema>;\n\t['~types']?: {\n\t\tvalidator: Prettify<Route>\n\t}\n\n\tget id(): string {\n\t\t// @ts-ignore\n\t\treturn this.data.id\n\t}\n}\n\nexport const createWSMessageParser = (\n\tparse: MaybeArray<WSParseHandler<any>>\n) => {\n\tconst parsers = typeof parse === 'function' ? [parse] : parse\n\n\treturn async function parseMessage(ws: ServerWebSocket<any>, message: any) {\n\t\tif (typeof message === 'string') {\n\t\t\tconst start = message?.charCodeAt(0)\n\n\t\t\tif (start === 34 || start === 47 || start === 91 || start === 123)\n\t\t\t\ttry {\n\t\t\t\t\tmessage = JSON.parse(message)\n\t\t\t\t} catch {\n\t\t\t\t\t// Not empty\n\t\t\t\t}\n\t\t\telse if (isNumericString(message)) message = +message\n\t\t\telse if (message === 'true') message = true\n\t\t\telse if (message === 'false') message = false\n\t\t\telse if (message === 'null') message = null\n\t\t}\n\n\t\tif (parsers)\n\t\t\tfor (let i = 0; i < parsers.length; i++) {\n\t\t\t\tlet temp = parsers[i](ws as any, message)\n\t\t\t\tif (temp instanceof Promise) temp = await temp\n\n\t\t\t\tif (temp !== undefined) return temp\n\t\t\t}\n\n\t\treturn message\n\t}\n}\n\nexport const createHandleWSResponse = (\n\tvalidateResponse: TypeCheck<any> | ElysiaTypeCheck<any> | undefined\n) => {\n\tconst handleWSResponse = (\n\t\tws: ServerWebSocket<any>,\n\t\tdata: unknown\n\t): unknown => {\n\t\tif (data instanceof Promise)\n\t\t\treturn data.then((data) => handleWSResponse(ws, data))\n\n\t\tif (Buffer.isBuffer(data)) return ws.send(data.toString())\n\n\t\tif (data === undefined) return\n\n\t\tconst send = (datum: unknown) => {\n\t\t\tif (validateResponse?.Check(datum) === false)\n\t\t\t\treturn ws.send(\n\t\t\t\t\tnew ValidationError('message', validateResponse, datum)\n\t\t\t\t\t\t.message\n\t\t\t\t)\n\n\t\t\tif (typeof datum === 'object') return ws.send(JSON.stringify(datum))\n\n\t\t\tws.send(datum)\n\t\t}\n\n\t\tif (typeof (data as Generator)?.next !== 'function')\n\t\t\treturn void send(data)\n\n\t\tconst init = (data as Generator | AsyncGenerator).next()\n\n\t\tif (init instanceof Promise)\n\t\t\treturn (async () => {\n\t\t\t\tconst first = await init\n\n\t\t\t\tif (validateResponse?.Check(first) === false)\n\t\t\t\t\treturn ws.send(\n\t\t\t\t\t\tnew ValidationError('message', validateResponse, first)\n\t\t\t\t\t\t\t.message\n\t\t\t\t\t)\n\n\t\t\t\tsend(first.value as any)\n\n\t\t\t\tif (!first.done)\n\t\t\t\t\tfor await (const datum of data as Generator) send(datum)\n\t\t\t})()\n\n\t\tsend(init.value)\n\n\t\tif (!init.done) for (const datum of data as Generator) send(datum)\n\t}\n\n\treturn handleWSResponse\n}\n\nexport type { WSLocalHook } from './types'\n",
|
|
30
|
-
"/* eslint-disable sonarjs/no-duplicate-string */\nimport type { TSchema } from '@sinclair/typebox'\n\nimport { WebStandardAdapter } from '../web-standard/index'\nimport { parseSetCookies } from '../utils'\nimport type { ElysiaAdapter } from '../types'\nimport type { Serve } from '../../universal/server'\n\nimport { createBunRouteHandler } from './compose'\nimport { createNativeStaticHandler } from './handler-native'\n\nimport { serializeCookie } from '../../cookies'\nimport { isProduction, ValidationError } from '../../error'\nimport { getSchemaValidator } from '../../schema'\nimport {\n\thasHeaderShorthand,\n\tisNotEmpty,\n\tisNumericString,\n\trandomId,\n\tsupportPerMethodInlineHandler\n} from '../../utils'\n\nimport {\n\tmapResponse,\n\tmapEarlyResponse,\n\tmapCompactResponse,\n\tcreateStaticHandler\n} from './handler'\n\nimport {\n\tcreateHandleWSResponse,\n\tcreateWSMessageParser,\n\tElysiaWS,\n\twebsocket\n} from '../../ws/index'\nimport type { ServerWebSocket } from '../../ws/bun'\nimport type { AnyElysia } from '../..'\n\nconst optionalParam = /:.+?\\?(?=\\/|$)/\n\nconst getPossibleParams = (path: string) => {\n\tconst match = optionalParam.exec(path)\n\n\tif (!match) return [path]\n\n\tconst routes: string[] = []\n\n\tconst head = path.slice(0, match.index)\n\tconst param = match[0].slice(0, -1)\n\tconst tail = path.slice(match.index + match[0].length)\n\n\troutes.push(head.slice(0, -1))\n\troutes.push(head + param)\n\n\tfor (const fragment of getPossibleParams(tail)) {\n\t\tif (!fragment) continue\n\n\t\tif (!fragment.startsWith('/:'))\n\t\t\troutes.push(head.slice(0, -1) + fragment)\n\n\t\troutes.push(head + param + fragment)\n\t}\n\n\treturn routes\n}\n\nexport const isHTMLBundle = (handle: any) => {\n\treturn (\n\t\ttypeof handle === 'object' &&\n\t\thandle !== null &&\n\t\t(handle.toString() === '[object HTMLBundle]' ||\n\t\t\ttypeof handle.index === 'string')\n\t)\n}\n\nconst supportedMethods = {\n\tGET: true,\n\tHEAD: true,\n\tOPTIONS: true,\n\tDELETE: true,\n\tPATCH: true,\n\tPOST: true,\n\tPUT: true\n} as const\n\nconst mapRoutes = (app: AnyElysia) => {\n\tif (!app.config.aot || !app.config.systemRouter) return undefined\n\n\tconst routes = <Record<string, Function | Record<string, unknown>>>{}\n\n\tconst add = (\n\t\troute: {\n\t\t\tpath: string\n\t\t\tmethod: string\n\t\t},\n\t\thandler: Function\n\t) => {\n\t\tif (routes[route.path]) {\n\t\t\t// @ts-ignore\n\t\t\tif (!routes[route.path][route.method])\n\t\t\t\t// @ts-ignore\n\t\t\t\troutes[route.path][route.method] = handler\n\t\t} else\n\t\t\troutes[route.path] = {\n\t\t\t\t[route.method]: handler\n\t\t\t}\n\t}\n\n\t// @ts-expect-error\n\tconst tree = app.routeTree\n\n\tfor (const route of app.router.history) {\n\t\tif (typeof route.handler !== 'function') continue\n\n\t\tconst method = route.method\n\n\t\tif (\n\t\t\t(method === 'GET' && `WS_${route.path}` in tree) ||\n\t\t\tmethod === 'WS' ||\n\t\t\troute.path.charCodeAt(route.path.length - 1) === 42 ||\n\t\t\t!(method in supportedMethods)\n\t\t)\n\t\t\tcontinue\n\n\t\tif (method === 'ALL') {\n\t\t\tif (!(`WS_${route.path}` in tree))\n\t\t\t\troutes[route.path] = route.hooks?.config?.mount\n\t\t\t\t\t? route.hooks.trace ||\n\t\t\t\t\t\tapp.event.trace ||\n\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\tapp.extender.higherOrderFunctions\n\t\t\t\t\t\t? createBunRouteHandler(app, route)\n\t\t\t\t\t\t: route.hooks.mount || route.handler\n\t\t\t\t\t: route.handler\n\n\t\t\tcontinue\n\t\t}\n\n\t\tlet compiled: Function\n\n\t\tconst handler = app.config.precompile\n\t\t\t? createBunRouteHandler(app, route)\n\t\t\t: (request: Request) => {\n\t\t\t\t\tif (compiled) return compiled(request)\n\n\t\t\t\t\treturn (compiled = createBunRouteHandler(app, route))(\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\tfor (const path of getPossibleParams(route.path))\n\t\t\tadd(\n\t\t\t\t{\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath\n\t\t\t\t},\n\t\t\t\thandler\n\t\t\t)\n\t}\n\n\treturn routes\n}\n\ntype Routes = Record<string, Function | Response | Record<string, unknown>>\n\nconst mergeRoutes = (r1: Routes, r2?: Routes) => {\n\tif (!r2) return r1\n\n\tfor (const key of Object.keys(r2)) {\n\t\tif (r1[key] === r2[key]) continue\n\n\t\tif (!r1[key]) {\n\t\t\tr1[key] = r2[key]\n\t\t\tcontinue\n\t\t}\n\n\t\tif (r1[key] && r2[key]) {\n\t\t\tif (typeof r1[key] === 'function' || r1[key] instanceof Response) {\n\t\t\t\tr1[key] = r2[key]\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tr1[key] = {\n\t\t\t\t...r1[key],\n\t\t\t\t...r2[key]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn r1\n}\n\nexport const BunAdapter: ElysiaAdapter = {\n\t...WebStandardAdapter,\n\tname: 'bun',\n\thandler: {\n\t\tmapResponse,\n\t\tmapEarlyResponse,\n\t\tmapCompactResponse,\n\t\tcreateStaticHandler,\n\t\tcreateNativeStaticHandler\n\t},\n\tcomposeHandler: {\n\t\t...WebStandardAdapter.composeHandler,\n\t\theaders: hasHeaderShorthand\n\t\t\t? 'c.headers=c.request.headers.toJSON()\\n'\n\t\t\t: 'c.headers={}\\n' +\n\t\t\t\t'for(const [k,v] of c.request.headers.entries())' +\n\t\t\t\t'c.headers[k]=v\\n'\n\t},\n\tlisten(app) {\n\t\treturn (options, callback) => {\n\t\t\tif (typeof Bun === 'undefined')\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'.listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch'\n\t\t\t\t)\n\n\t\t\tapp.compile()\n\n\t\t\tif (typeof options === 'string') {\n\t\t\t\tif (!isNumericString(options))\n\t\t\t\t\tthrow new Error('Port must be a numeric value')\n\n\t\t\t\toptions = parseInt(options)\n\t\t\t}\n\n\t\t\tconst createStaticRoute = <\n\t\t\t\tWithAsync extends boolean | undefined = false\n\t\t\t>(\n\t\t\t\titerator: AnyElysia['router']['response'],\n\t\t\t\t{ withAsync = false }: { withAsync?: WithAsync } = {}\n\t\t\t): true extends WithAsync\n\t\t\t\t? Promise<{\n\t\t\t\t\t\t[path: string]:\n\t\t\t\t\t\t\t| Response\n\t\t\t\t\t\t\t| { [method: string]: Response }\n\t\t\t\t\t}>\n\t\t\t\t: {\n\t\t\t\t\t\t[path: string]:\n\t\t\t\t\t\t\t| Response\n\t\t\t\t\t\t\t| { [method: string]: Response }\n\t\t\t\t\t} => {\n\t\t\t\tconst staticRoutes = <\n\t\t\t\t\t{\n\t\t\t\t\t\t[path: string]:\n\t\t\t\t\t\t\t| Response\n\t\t\t\t\t\t\t| { [method: string]: Response }\n\t\t\t\t\t}\n\t\t\t\t>{}\n\t\t\t\tconst ops = <Promise<any>[]>[]\n\n\t\t\t\tfor (const [path, route] of Object.entries(iterator)) {\n\t\t\t\t\tif (supportPerMethodInlineHandler) {\n\t\t\t\t\t\tif (!route) continue\n\n\t\t\t\t\t\tfor (const [method, value] of Object.entries(route)) {\n\t\t\t\t\t\t\tif (!value || !(method in supportedMethods))\n\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\tif (value instanceof Promise) {\n\t\t\t\t\t\t\t\tif (withAsync) {\n\t\t\t\t\t\t\t\t\tif (!staticRoutes[path])\n\t\t\t\t\t\t\t\t\t\tstaticRoutes[path] = {}\n\n\t\t\t\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\t\t\t\tvalue.then((awaited) => {\n\t\t\t\t\t\t\t\t\t\t\tif (awaited instanceof Response)\n\t\t\t\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\t\t\t\tstaticRoutes[path][method] =\n\t\t\t\t\t\t\t\t\t\t\t\t\tawaited\n\n\t\t\t\t\t\t\t\t\t\t\tif (isHTMLBundle(awaited))\n\t\t\t\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\t\t\t\tstaticRoutes[path][method] =\n\t\t\t\t\t\t\t\t\t\t\t\t\tawaited\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!(value instanceof Response) &&\n\t\t\t\t\t\t\t\t!isHTMLBundle(value)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\tif (!staticRoutes[path]) staticRoutes[path] = {}\n\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tstaticRoutes[path][method] = value\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!route) continue\n\n\t\t\t\t\t\tif (route instanceof Promise) {\n\t\t\t\t\t\t\tif (withAsync) {\n\t\t\t\t\t\t\t\tif (!staticRoutes[path]) staticRoutes[path] = {}\n\n\t\t\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\t\t\troute.then((awaited) => {\n\t\t\t\t\t\t\t\t\t\tif (awaited instanceof Response)\n\t\t\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\t\t\tstaticRoutes[path] = awaited\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!(route instanceof Response)) continue\n\n\t\t\t\t\t\tstaticRoutes[path] = route\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (withAsync)\n\t\t\t\t\treturn Promise.all(ops).then(() => staticRoutes) as any\n\n\t\t\t\treturn staticRoutes as any\n\t\t\t}\n\n\t\t\tconst serve =\n\t\t\t\ttypeof options === 'object'\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\tdevelopment: !isProduction,\n\t\t\t\t\t\t\treusePort: true,\n\t\t\t\t\t\t\tidleTimeout: 30,\n\t\t\t\t\t\t\t...(app.config.serve || {}),\n\t\t\t\t\t\t\t...(options || {}),\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\troutes: mergeRoutes(\n\t\t\t\t\t\t\t\tmergeRoutes(\n\t\t\t\t\t\t\t\t\tcreateStaticRoute(app.router.response),\n\t\t\t\t\t\t\t\t\tmapRoutes(app)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\t\tapp.config.serve?.routes\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\twebsocket: {\n\t\t\t\t\t\t\t\t...(app.config.websocket || {}),\n\t\t\t\t\t\t\t\t...(websocket || {})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetch: app.fetch\n\t\t\t\t\t\t} as Serve)\n\t\t\t\t\t: ({\n\t\t\t\t\t\t\tdevelopment: !isProduction,\n\t\t\t\t\t\t\treusePort: true,\n\t\t\t\t\t\t\tidleTimeout: 30,\n\t\t\t\t\t\t\t...(app.config.serve || {}),\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\troutes: mergeRoutes(\n\t\t\t\t\t\t\t\tmergeRoutes(\n\t\t\t\t\t\t\t\t\tcreateStaticRoute(app.router.response),\n\t\t\t\t\t\t\t\t\tmapRoutes(app)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\t\tapp.config.serve?.routes\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\twebsocket: {\n\t\t\t\t\t\t\t\t...(app.config.websocket || {}),\n\t\t\t\t\t\t\t\t...(websocket || {})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tport: options,\n\t\t\t\t\t\t\tfetch: app.fetch\n\t\t\t\t\t\t} as Serve)\n\n\t\t\tapp.server = Bun.serve(serve as any) as any\n\n\t\t\tif (app.event.start)\n\t\t\t\tfor (let i = 0; i < app.event.start.length; i++)\n\t\t\t\t\tapp.event.start[i].fn(app)\n\n\t\t\tif (callback) callback(app.server!)\n\n\t\t\tprocess.on('beforeExit', () => {\n\t\t\t\tif (app.server) {\n\t\t\t\t\tapp.server.stop?.()\n\t\t\t\t\tapp.server = null\n\n\t\t\t\t\tif (app.event.stop)\n\t\t\t\t\t\tfor (let i = 0; i < app.event.stop.length; i++)\n\t\t\t\t\t\t\tapp.event.stop[i].fn(app)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\t// @ts-expect-error private\n\t\t\tapp.promisedModules.then(async () => {\n\t\t\t\tapp.server?.reload({\n\t\t\t\t\t...serve,\n\t\t\t\t\tfetch: app.fetch,\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\troutes: mergeRoutes(\n\t\t\t\t\t\tmergeRoutes(\n\t\t\t\t\t\t\tawait createStaticRoute(app.router.response, {\n\t\t\t\t\t\t\t\twithAsync: true\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmapRoutes(app)\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\tapp.config.serve?.routes\n\t\t\t\t\t)\n\t\t\t\t})\n\n\t\t\t\tBun?.gc(false)\n\t\t\t})\n\t\t}\n\t},\n\tasync stop(app, closeActiveConnections) {\n\t\tif (app.server) {\n\t\t\tapp.server.stop(closeActiveConnections)\n\t\t\tapp.server = null\n\n\t\t\tif (app.event.stop?.length)\n\t\t\t\tfor (let i = 0; i < app.event.stop.length; i++)\n\t\t\t\t\tapp.event.stop[i].fn(app)\n\t\t} else\n\t\t\tconsole.log(\n\t\t\t\t\"Elysia isn't running. Call `app.listen` to start the server.\",\n\t\t\t\tnew Error().stack\n\t\t\t)\n\t},\n\tws(app, path, options) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tconst { parse, body, response, ...rest } = options\n\n\t\tconst validateMessage = getSchemaValidator(body, {\n\t\t\t// @ts-expect-error private property\n\t\t\tmodules: app.definitions.typebox,\n\t\t\t// @ts-expect-error private property\n\t\t\tmodels: app.definitions.type as Record<string, TSchema>,\n\t\t\tnormalize: app.config.normalize\n\t\t})\n\n\t\tconst validateResponse = getSchemaValidator(response as any, {\n\t\t\t// @ts-expect-error private property\n\t\t\tmodules: app.definitions.typebox,\n\t\t\t// @ts-expect-error private property\n\t\t\tmodels: app.definitions.type as Record<string, TSchema>,\n\t\t\tnormalize: app.config.normalize\n\t\t})\n\n\t\tapp.route(\n\t\t\t'WS',\n\t\t\tpath as any,\n\t\t\tasync (context: any) => {\n\t\t\t\tconst server =\n\t\t\t\t\t(context.server as (typeof app)['server']) ?? app.server\n\n\t\t\t\t// ! Enable static code analysis just in case resolveUnknownFunction doesn't work, do not remove\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t\tconst { set, path, qi, headers, query, params } = context\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tcontext.validator = validateResponse\n\n\t\t\t\tif (options.upgrade) {\n\t\t\t\t\tif (typeof options.upgrade === 'function') {\n\t\t\t\t\t\tconst temp = options.upgrade(context as any)\n\t\t\t\t\t\tif (temp instanceof Promise) await temp\n\t\t\t\t\t} else if (options.upgrade)\n\t\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t\tset.headers,\n\t\t\t\t\t\t\toptions.upgrade as Record<string, any>\n\t\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (set.cookie && isNotEmpty(set.cookie)) {\n\t\t\t\t\tconst cookie = serializeCookie(set.cookie)\n\n\t\t\t\t\tif (cookie) set.headers['set-cookie'] = cookie\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tset.headers['set-cookie'] &&\n\t\t\t\t\tArray.isArray(set.headers['set-cookie'])\n\t\t\t\t)\n\t\t\t\t\tset.headers = parseSetCookies(\n\t\t\t\t\t\tnew Headers(set.headers as any) as Headers,\n\t\t\t\t\t\tset.headers['set-cookie']\n\t\t\t\t\t) as any\n\n\t\t\t\tconst handleResponse = createHandleWSResponse(validateResponse)\n\t\t\t\tconst parseMessage = createWSMessageParser(parse)\n\n\t\t\t\tlet _id: string | undefined\n\n\t\t\t\tif (typeof options.beforeHandle === 'function') {\n\t\t\t\t\tconst result = options.beforeHandle(context)\n\t\t\t\t\tif (result instanceof Promise) await result\n\t\t\t\t}\n\n\t\t\t\tconst errorHandlers = [\n\t\t\t\t\t...(options.error\n\t\t\t\t\t\t? Array.isArray(options.error)\n\t\t\t\t\t\t\t? options.error\n\t\t\t\t\t\t\t: [options.error]\n\t\t\t\t\t\t: []),\n\t\t\t\t\t...(app.event.error ?? []).map((x) =>\n\t\t\t\t\t\ttypeof x === 'function' ? x : x.fn\n\t\t\t\t\t)\n\t\t\t\t].filter((x) => x)\n\n\t\t\t\tconst handleErrors = !errorHandlers.length\n\t\t\t\t\t? () => {}\n\t\t\t\t\t: async (ws: ServerWebSocket<any>, error: unknown) => {\n\t\t\t\t\t\t\tfor (const handleError of errorHandlers) {\n\t\t\t\t\t\t\t\tlet response = handleError(\n\t\t\t\t\t\t\t\t\tObject.assign(context, { error })\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\t\t\t\t\tresponse = await response\n\n\t\t\t\t\t\t\t\tawait handleResponse(ws, response)\n\n\t\t\t\t\t\t\t\tif (response) break\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tserver?.upgrade<any>(context.request, {\n\t\t\t\t\t\theaders: isNotEmpty(set.headers)\n\t\t\t\t\t\t\t? (set.headers as Record<string, string>)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tget id() {\n\t\t\t\t\t\t\t\tif (_id) return _id\n\n\t\t\t\t\t\t\t\treturn (_id = randomId())\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tvalidator: validateResponse,\n\t\t\t\t\t\t\tping(data?: unknown) {\n\t\t\t\t\t\t\t\toptions.ping?.(data)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpong(data?: unknown) {\n\t\t\t\t\t\t\t\toptions.pong?.(data)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\topen: async (ws: ServerWebSocket<any>) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.open?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(ws, context as any)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmessage: async (\n\t\t\t\t\t\t\t\tws: ServerWebSocket<any>,\n\t\t\t\t\t\t\t\t_message: any\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tconst message = await parseMessage(ws, _message)\n\n\t\t\t\t\t\t\t\tif (validateMessage?.Check(message) === false)\n\t\t\t\t\t\t\t\t\treturn void ws.send(\n\t\t\t\t\t\t\t\t\t\tnew ValidationError(\n\t\t\t\t\t\t\t\t\t\t\t'message',\n\t\t\t\t\t\t\t\t\t\t\tvalidateMessage,\n\t\t\t\t\t\t\t\t\t\t\tmessage\n\t\t\t\t\t\t\t\t\t\t).message as string\n\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.message?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(\n\t\t\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\t\t\tcontext as any,\n\t\t\t\t\t\t\t\t\t\t\t\tmessage\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tmessage as any\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdrain: async (ws: ServerWebSocket<any>) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.drain?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(ws, context as any)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tclose: async (\n\t\t\t\t\t\t\t\tws: ServerWebSocket<any>,\n\t\t\t\t\t\t\t\tcode: number,\n\t\t\t\t\t\t\t\treason: string\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.close?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(ws, context as any),\n\t\t\t\t\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t\t\t\t\t\treason\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\treturn\n\n\t\t\t\tset.status = 400\n\t\t\t\treturn 'Expected a websocket connection'\n\t\t\t},\n\t\t\t{\n\t\t\t\t...rest,\n\t\t\t\twebsocket: options\n\t\t\t} as any\n\t\t)\n\t}\n}\n",
|
|
30
|
+
"/* eslint-disable sonarjs/no-duplicate-string */\nimport type { TSchema } from '@sinclair/typebox'\n\nimport { WebStandardAdapter } from '../web-standard/index'\nimport { parseSetCookies } from '../utils'\nimport type { ElysiaAdapter } from '../types'\nimport type { Serve } from '../../universal/server'\n\nimport { createBunRouteHandler } from './compose'\nimport { createNativeStaticHandler } from './handler-native'\n\nimport { serializeCookie } from '../../cookies'\nimport { isProduction, ValidationError } from '../../error'\nimport { getSchemaValidator } from '../../schema'\nimport {\n\thasHeaderShorthand,\n\tisNotEmpty,\n\tisNumericString,\n\trandomId,\n\tsupportPerMethodInlineHandler\n} from '../../utils'\n\nimport {\n\tmapResponse,\n\tmapEarlyResponse,\n\tmapCompactResponse,\n\tcreateStaticHandler\n} from './handler'\n\nimport {\n\tcreateHandleWSResponse,\n\tcreateWSMessageParser,\n\tElysiaWS,\n\twebsocket\n} from '../../ws/index'\nimport type { ServerWebSocket } from '../../ws/bun'\nimport type { AnyElysia } from '../..'\n\nconst optionalParam = /:.+?\\?(?=\\/|$)/\n\nconst getPossibleParams = (path: string) => {\n\tconst match = optionalParam.exec(path)\n\n\tif (!match) return [path]\n\n\tconst routes: string[] = []\n\n\tconst head = path.slice(0, match.index)\n\tconst param = match[0].slice(0, -1)\n\tconst tail = path.slice(match.index + match[0].length)\n\n\troutes.push(head.slice(0, -1))\n\troutes.push(head + param)\n\n\tfor (const fragment of getPossibleParams(tail)) {\n\t\tif (!fragment) continue\n\n\t\tif (!fragment.startsWith('/:'))\n\t\t\troutes.push(head.slice(0, -1) + fragment)\n\n\t\troutes.push(head + param + fragment)\n\t}\n\n\treturn routes\n}\n\nexport const isHTMLBundle = (handle: any) => {\n\treturn (\n\t\ttypeof handle === 'object' &&\n\t\thandle !== null &&\n\t\t(handle.toString() === '[object HTMLBundle]' ||\n\t\t\ttypeof handle.index === 'string')\n\t)\n}\n\nconst supportedMethods = {\n\tGET: true,\n\tHEAD: true,\n\tOPTIONS: true,\n\tDELETE: true,\n\tPATCH: true,\n\tPOST: true,\n\tPUT: true\n} as const\n\nconst mapRoutes = (app: AnyElysia) => {\n\tif (!app.config.aot || !app.config.systemRouter) return undefined\n\n\tconst routes = <Record<string, Function | Record<string, unknown>>>{}\n\n\tconst add = (\n\t\troute: {\n\t\t\tpath: string\n\t\t\tmethod: string\n\t\t},\n\t\thandler: Function\n\t) => {\n\t\tif (routes[route.path]) {\n\t\t\t// @ts-ignore\n\t\t\tif (!routes[route.path][route.method])\n\t\t\t\t// @ts-ignore\n\t\t\t\troutes[route.path][route.method] = handler\n\t\t} else\n\t\t\troutes[route.path] = {\n\t\t\t\t[route.method]: handler\n\t\t\t}\n\t}\n\n\t// @ts-expect-error\n\tconst tree = app.routeTree\n\n\tfor (const route of app.router.history) {\n\t\tif (typeof route.handler !== 'function') continue\n\n\t\tconst method = route.method\n\n\t\tif (\n\t\t\t(method === 'GET' && `WS_${route.path}` in tree) ||\n\t\t\tmethod === 'WS' ||\n\t\t\troute.path.charCodeAt(route.path.length - 1) === 42 ||\n\t\t\t!(method in supportedMethods)\n\t\t)\n\t\t\tcontinue\n\n\t\tif (method === 'ALL') {\n\t\t\tif (!(`WS_${route.path}` in tree))\n\t\t\t\troutes[route.path] = route.hooks?.config?.mount\n\t\t\t\t\t? route.hooks.trace ||\n\t\t\t\t\t\tapp.event.trace ||\n\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\tapp.extender.higherOrderFunctions\n\t\t\t\t\t\t? createBunRouteHandler(app, route)\n\t\t\t\t\t\t: route.hooks.mount || route.handler\n\t\t\t\t\t: route.handler\n\n\t\t\tcontinue\n\t\t}\n\n\t\tlet compiled: Function\n\n\t\tconst handler = app.config.precompile\n\t\t\t? createBunRouteHandler(app, route)\n\t\t\t: (request: Request) => {\n\t\t\t\t\tif (compiled) return compiled(request)\n\n\t\t\t\t\treturn (compiled = createBunRouteHandler(app, route))(\n\t\t\t\t\t\trequest\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\tfor (const path of getPossibleParams(route.path))\n\t\t\tadd(\n\t\t\t\t{\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath\n\t\t\t\t},\n\t\t\t\thandler\n\t\t\t)\n\t}\n\n\treturn routes\n}\n\ntype Routes = Record<string, Function | Response | Record<string, unknown>>\n\nconst mergeRoutes = (r1: Routes, r2?: Routes) => {\n\tif (!r2) return r1\n\n\tfor (const key of Object.keys(r2)) {\n\t\tif (r1[key] === r2[key]) continue\n\n\t\tif (!r1[key]) {\n\t\t\tr1[key] = r2[key]\n\t\t\tcontinue\n\t\t}\n\n\t\tif (r1[key] && r2[key]) {\n\t\t\tif (typeof r1[key] === 'function' || r1[key] instanceof Response) {\n\t\t\t\tr1[key] = r2[key]\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tr1[key] = {\n\t\t\t\t...r1[key],\n\t\t\t\t...r2[key]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn r1\n}\n\nexport const BunAdapter: ElysiaAdapter = {\n\t...WebStandardAdapter,\n\tname: 'bun',\n\thandler: {\n\t\tmapResponse,\n\t\tmapEarlyResponse,\n\t\tmapCompactResponse,\n\t\tcreateStaticHandler,\n\t\tcreateNativeStaticHandler\n\t},\n\tcomposeHandler: {\n\t\t...WebStandardAdapter.composeHandler,\n\t\theaders: hasHeaderShorthand\n\t\t\t? 'c.headers=c.request.headers.toJSON()\\n'\n\t\t\t: 'c.headers={}\\n' +\n\t\t\t\t'for(const [k,v] of c.request.headers.entries())' +\n\t\t\t\t'c.headers[k]=v\\n'\n\t},\n\tlisten(app) {\n\t\treturn (options, callback) => {\n\t\t\tif (typeof Bun === 'undefined')\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'.listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch'\n\t\t\t\t)\n\n\t\t\tapp.compile()\n\n\t\t\tif (typeof options === 'string') {\n\t\t\t\tif (!isNumericString(options))\n\t\t\t\t\tthrow new Error('Port must be a numeric value')\n\n\t\t\t\toptions = parseInt(options)\n\t\t\t}\n\n\t\t\tconst createStaticRoute = <\n\t\t\t\tWithAsync extends boolean | undefined = false\n\t\t\t>(\n\t\t\t\titerator: AnyElysia['router']['response'],\n\t\t\t\t{ withAsync = false }: { withAsync?: WithAsync } = {}\n\t\t\t): true extends WithAsync\n\t\t\t\t? Promise<{\n\t\t\t\t\t\t[path: string]:\n\t\t\t\t\t\t\t| Response\n\t\t\t\t\t\t\t| { [method: string]: Response }\n\t\t\t\t\t}>\n\t\t\t\t: {\n\t\t\t\t\t\t[path: string]:\n\t\t\t\t\t\t\t| Response\n\t\t\t\t\t\t\t| { [method: string]: Response }\n\t\t\t\t\t} => {\n\t\t\t\tconst staticRoutes = <\n\t\t\t\t\t{\n\t\t\t\t\t\t[path: string]:\n\t\t\t\t\t\t\t| Response\n\t\t\t\t\t\t\t| { [method: string]: Response }\n\t\t\t\t\t}\n\t\t\t\t>{}\n\t\t\t\tconst ops = <Promise<any>[]>[]\n\n\t\t\t\tfor (const [path, route] of Object.entries(iterator)) {\n\t\t\t\t\tif (supportPerMethodInlineHandler) {\n\t\t\t\t\t\tif (!route) continue\n\n\t\t\t\t\t\tfor (const [method, value] of Object.entries(route)) {\n\t\t\t\t\t\t\tif (!value || !(method in supportedMethods))\n\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\tif (value instanceof Promise) {\n\t\t\t\t\t\t\t\tif (withAsync) {\n\t\t\t\t\t\t\t\t\tif (!staticRoutes[path])\n\t\t\t\t\t\t\t\t\t\tstaticRoutes[path] = {}\n\n\t\t\t\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\t\t\t\tvalue.then((awaited) => {\n\t\t\t\t\t\t\t\t\t\t\tif (awaited instanceof Response)\n\t\t\t\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\t\t\t\tstaticRoutes[path][method] =\n\t\t\t\t\t\t\t\t\t\t\t\t\tawaited\n\n\t\t\t\t\t\t\t\t\t\t\tif (isHTMLBundle(awaited))\n\t\t\t\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\t\t\t\tstaticRoutes[path][method] =\n\t\t\t\t\t\t\t\t\t\t\t\t\tawaited\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!(value instanceof Response) &&\n\t\t\t\t\t\t\t\t!isHTMLBundle(value)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\tif (!staticRoutes[path]) staticRoutes[path] = {}\n\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tstaticRoutes[path][method] = value\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!route) continue\n\n\t\t\t\t\t\tif (route instanceof Promise) {\n\t\t\t\t\t\t\tif (withAsync) {\n\t\t\t\t\t\t\t\tif (!staticRoutes[path]) staticRoutes[path] = {}\n\n\t\t\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\t\t\troute.then((awaited) => {\n\t\t\t\t\t\t\t\t\t\tif (awaited instanceof Response)\n\t\t\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\t\t\tstaticRoutes[path] = awaited\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!(route instanceof Response)) continue\n\n\t\t\t\t\t\tstaticRoutes[path] = route\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (withAsync)\n\t\t\t\t\treturn Promise.all(ops).then(() => staticRoutes) as any\n\n\t\t\t\treturn staticRoutes as any\n\t\t\t}\n\n\t\t\tconst serve =\n\t\t\t\ttypeof options === 'object'\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\tdevelopment: !isProduction,\n\t\t\t\t\t\t\treusePort: true,\n\t\t\t\t\t\t\tidleTimeout: 30,\n\t\t\t\t\t\t\t...(app.config.serve || {}),\n\t\t\t\t\t\t\t...(options || {}),\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\troutes: mergeRoutes(\n\t\t\t\t\t\t\t\tmergeRoutes(\n\t\t\t\t\t\t\t\t\tcreateStaticRoute(app.router.response),\n\t\t\t\t\t\t\t\t\tmapRoutes(app)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\t\tapp.config.serve?.routes\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\twebsocket: {\n\t\t\t\t\t\t\t\t...(app.config.websocket || {}),\n\t\t\t\t\t\t\t\t...(websocket || {}),\n\t\t\t\t\t\t\t\t// @ts-expect-error not available in this variant of options type\n\t\t\t\t\t\t\t\t...(options.websocket || {})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetch: app.fetch\n\t\t\t\t\t\t} as Serve)\n\t\t\t\t\t: ({\n\t\t\t\t\t\t\tdevelopment: !isProduction,\n\t\t\t\t\t\t\treusePort: true,\n\t\t\t\t\t\t\tidleTimeout: 30,\n\t\t\t\t\t\t\t...(app.config.serve || {}),\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\troutes: mergeRoutes(\n\t\t\t\t\t\t\t\tmergeRoutes(\n\t\t\t\t\t\t\t\t\tcreateStaticRoute(app.router.response),\n\t\t\t\t\t\t\t\t\tmapRoutes(app)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\t\t\tapp.config.serve?.routes\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\twebsocket: {\n\t\t\t\t\t\t\t\t...(app.config.websocket || {}),\n\t\t\t\t\t\t\t\t...(websocket || {})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tport: options,\n\t\t\t\t\t\t\tfetch: app.fetch\n\t\t\t\t\t\t} as Serve)\n\n\t\t\tapp.server = Bun.serve(serve as any) as any\n\n\t\t\tif (app.event.start)\n\t\t\t\tfor (let i = 0; i < app.event.start.length; i++)\n\t\t\t\t\tapp.event.start[i].fn(app)\n\n\t\t\tif (callback) callback(app.server!)\n\n\t\t\tprocess.on('beforeExit', () => {\n\t\t\t\tif (app.server) {\n\t\t\t\t\tapp.server.stop?.()\n\t\t\t\t\tapp.server = null\n\n\t\t\t\t\tif (app.event.stop)\n\t\t\t\t\t\tfor (let i = 0; i < app.event.stop.length; i++)\n\t\t\t\t\t\t\tapp.event.stop[i].fn(app)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\t// @ts-expect-error private\n\t\t\tapp.promisedModules.then(async () => {\n\t\t\t\tapp.server?.reload({\n\t\t\t\t\t...serve,\n\t\t\t\t\tfetch: app.fetch,\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\troutes: mergeRoutes(\n\t\t\t\t\t\tmergeRoutes(\n\t\t\t\t\t\t\tawait createStaticRoute(app.router.response, {\n\t\t\t\t\t\t\t\twithAsync: true\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmapRoutes(app)\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// @ts-expect-error private property\n\t\t\t\t\t\tapp.config.serve?.routes\n\t\t\t\t\t)\n\t\t\t\t})\n\n\t\t\t\tBun?.gc(false)\n\t\t\t})\n\t\t}\n\t},\n\tasync stop(app, closeActiveConnections) {\n\t\tif (app.server) {\n\t\t\tapp.server.stop(closeActiveConnections)\n\t\t\tapp.server = null\n\n\t\t\tif (app.event.stop?.length)\n\t\t\t\tfor (let i = 0; i < app.event.stop.length; i++)\n\t\t\t\t\tapp.event.stop[i].fn(app)\n\t\t} else\n\t\t\tconsole.log(\n\t\t\t\t\"Elysia isn't running. Call `app.listen` to start the server.\",\n\t\t\t\tnew Error().stack\n\t\t\t)\n\t},\n\tws(app, path, options) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tconst { parse, body, response, ...rest } = options\n\n\t\tconst validateMessage = getSchemaValidator(body, {\n\t\t\t// @ts-expect-error private property\n\t\t\tmodules: app.definitions.typebox,\n\t\t\t// @ts-expect-error private property\n\t\t\tmodels: app.definitions.type as Record<string, TSchema>,\n\t\t\tnormalize: app.config.normalize\n\t\t})\n\n\t\tconst validateResponse = getSchemaValidator(response as any, {\n\t\t\t// @ts-expect-error private property\n\t\t\tmodules: app.definitions.typebox,\n\t\t\t// @ts-expect-error private property\n\t\t\tmodels: app.definitions.type as Record<string, TSchema>,\n\t\t\tnormalize: app.config.normalize\n\t\t})\n\n\t\tapp.route(\n\t\t\t'WS',\n\t\t\tpath as any,\n\t\t\tasync (context: any) => {\n\t\t\t\tconst server =\n\t\t\t\t\t(context.server as (typeof app)['server']) ?? app.server\n\n\t\t\t\t// ! Enable static code analysis just in case resolveUnknownFunction doesn't work, do not remove\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t\tconst { set, path, qi, headers, query, params } = context\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tcontext.validator = validateResponse\n\n\t\t\t\tif (options.upgrade) {\n\t\t\t\t\tif (typeof options.upgrade === 'function') {\n\t\t\t\t\t\tconst temp = options.upgrade(context as any)\n\t\t\t\t\t\tif (temp instanceof Promise) await temp\n\t\t\t\t\t} else if (options.upgrade)\n\t\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t\tset.headers,\n\t\t\t\t\t\t\toptions.upgrade as Record<string, any>\n\t\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (set.cookie && isNotEmpty(set.cookie)) {\n\t\t\t\t\tconst cookie = serializeCookie(set.cookie)\n\n\t\t\t\t\tif (cookie) set.headers['set-cookie'] = cookie\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tset.headers['set-cookie'] &&\n\t\t\t\t\tArray.isArray(set.headers['set-cookie'])\n\t\t\t\t)\n\t\t\t\t\tset.headers = parseSetCookies(\n\t\t\t\t\t\tnew Headers(set.headers as any) as Headers,\n\t\t\t\t\t\tset.headers['set-cookie']\n\t\t\t\t\t) as any\n\n\t\t\t\tconst handleResponse = createHandleWSResponse(validateResponse)\n\t\t\t\tconst parseMessage = createWSMessageParser(parse)\n\n\t\t\t\tlet _id: string | undefined\n\n\t\t\t\tif (typeof options.beforeHandle === 'function') {\n\t\t\t\t\tconst result = options.beforeHandle(context)\n\t\t\t\t\tif (result instanceof Promise) await result\n\t\t\t\t}\n\n\t\t\t\tconst errorHandlers = [\n\t\t\t\t\t...(options.error\n\t\t\t\t\t\t? Array.isArray(options.error)\n\t\t\t\t\t\t\t? options.error\n\t\t\t\t\t\t\t: [options.error]\n\t\t\t\t\t\t: []),\n\t\t\t\t\t...(app.event.error ?? []).map((x) =>\n\t\t\t\t\t\ttypeof x === 'function' ? x : x.fn\n\t\t\t\t\t)\n\t\t\t\t].filter((x) => x)\n\n const hasCustomErrorHandlers = errorHandlers.length > 0\n\n\t\t\t\tconst handleErrors = !hasCustomErrorHandlers\n\t\t\t\t\t? () => {}\n\t\t\t\t\t: async (ws: ServerWebSocket<any>, error: unknown) => {\n\t\t\t\t\t\t\tfor (const handleError of errorHandlers) {\n\t\t\t\t\t\t\t\tlet response = handleError(\n\t\t\t\t\t\t\t\t\tObject.assign(context, { error })\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (response instanceof Promise)\n\t\t\t\t\t\t\t\t\tresponse = await response\n\n\t\t\t\t\t\t\t\tawait handleResponse(ws, response)\n\n\t\t\t\t\t\t\t\tif (response) break\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tserver?.upgrade<any>(context.request, {\n\t\t\t\t\t\theaders: isNotEmpty(set.headers)\n\t\t\t\t\t\t\t? (set.headers as Record<string, string>)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tget id() {\n\t\t\t\t\t\t\t\tif (_id) return _id\n\n\t\t\t\t\t\t\t\treturn (_id = randomId())\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tvalidator: validateResponse,\n\t\t\t\t\t\t\tping(data?: unknown) {\n\t\t\t\t\t\t\t\toptions.ping?.(data)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpong(data?: unknown) {\n\t\t\t\t\t\t\t\toptions.pong?.(data)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\topen: async (ws: ServerWebSocket<any>) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.open?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(ws, context as any)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmessage: async (\n\t\t\t\t\t\t\t\tws: ServerWebSocket<any>,\n\t\t\t\t\t\t\t\t_message: any\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tconst message = await parseMessage(ws, _message)\n\n\t\t\t\t\t\t\t\tif (validateMessage?.Check(message) === false) {\n const validationError = new ValidationError(\n 'message',\n validateMessage,\n message\n )\n\n if (!hasCustomErrorHandlers) {\n return void ws.send(validationError.message as string)\n }\n\n return handleErrors(ws, validationError)\n }\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.message?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(\n\t\t\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\t\t\tcontext as any,\n\t\t\t\t\t\t\t\t\t\t\t\tmessage\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tmessage as any\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdrain: async (ws: ServerWebSocket<any>) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.drain?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(ws, context as any)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tclose: async (\n\t\t\t\t\t\t\t\tws: ServerWebSocket<any>,\n\t\t\t\t\t\t\t\tcode: number,\n\t\t\t\t\t\t\t\treason: string\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait handleResponse(\n\t\t\t\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\t\t\t\toptions.close?.(\n\t\t\t\t\t\t\t\t\t\t\tnew ElysiaWS(ws, context as any),\n\t\t\t\t\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t\t\t\t\t\treason\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\thandleErrors(ws, error)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\treturn\n\n\t\t\t\tset.status = 400\n\t\t\t\treturn 'Expected a websocket connection'\n\t\t\t},\n\t\t\t{\n\t\t\t\t...rest,\n\t\t\t\twebsocket: options\n\t\t\t} as any\n\t\t)\n\t}\n}\n",
|
|
31
31
|
"import { isBun } from './utils'\n\nexport const env = isBun\n\t? Bun.env\n\t: typeof process !== 'undefined' && process?.env\n\t\t? process.env\n\t\t: {}\n",
|
|
32
32
|
"import type { AnyElysia, CookieOptions } from '.'\n\nimport { TransformDecodeError } from '@sinclair/typebox/value'\nimport { TypeCheck } from './type-system'\n\nimport type { Context } from './context'\nimport type { ElysiaTypeCheck } from './schema'\n\nimport {\n\tElysiaCustomStatusResponse,\n\tElysiaErrors,\n\tstatus,\n\tNotFoundError,\n\tValidationError\n} from './error'\n\nimport { parseQuery } from './parse-query'\n\nimport { redirect, signCookie, StatusMap } from './utils'\nimport { parseCookie } from './cookies'\n\nimport type { Handler, LifeCycleStore, SchemaValidator } from './types'\n\n// JIT Handler\nexport type DynamicHandler = {\n\thandle: unknown | Handler<any, any>\n\tcontent?: string\n\thooks: Partial<LifeCycleStore>\n\tvalidator?: SchemaValidator\n\troute: string\n}\n\nconst injectDefaultValues = (\n\ttypeChecker: TypeCheck<any> | ElysiaTypeCheck<any>,\n\tobj: Record<string, any>\n) => {\n\t// @ts-expect-error private property\n\tlet schema = typeChecker.schema\n\tif (!schema) return\n\n\tif (schema.$defs?.[schema.$ref]) schema = schema.$defs[schema.$ref]\n\n\tif (!schema?.properties) return\n\n\tfor (const [key, keySchema] of Object.entries(schema.properties)) {\n\t\t// @ts-expect-error private\n\t\tobj[key] ??= keySchema.default\n\t}\n}\n\nexport const createDynamicHandler = (app: AnyElysia) => {\n\tconst { mapResponse, mapEarlyResponse } = app['~adapter'].handler\n\n\t// @ts-ignore\n\tconst defaultHeader = app.setHeaders\n\n\treturn async (request: Request): Promise<Response> => {\n\t\tconst url = request.url,\n\t\t\ts = url.indexOf('/', 11),\n\t\t\tqi = url.indexOf('?', s + 1),\n\t\t\tpath = qi === -1 ? url.substring(s) : url.substring(s, qi)\n\n\t\tconst set: Context['set'] = {\n\t\t\tcookie: {},\n\t\t\tstatus: 200,\n\t\t\theaders: defaultHeader ? { ...defaultHeader } : {}\n\t\t}\n\n\t\tconst context = Object.assign(\n\t\t\t{},\n\t\t\t// @ts-expect-error\n\t\t\tapp.singleton.decorator,\n\t\t\t{\n\t\t\t\tset,\n\t\t\t\t// @ts-expect-error\n\t\t\t\tstore: app.singleton.store,\n\t\t\t\trequest,\n\t\t\t\tpath,\n\t\t\t\tqi,\n\t\t\t\terror: status,\n\t\t\t\tstatus,\n\t\t\t\tredirect\n\t\t\t}\n\t\t) as unknown as Context & {\n\t\t\tresponse: unknown\n\t\t}\n\n\t\ttry {\n\t\t\tif (app.event.request)\n\t\t\t\tfor (let i = 0; i < app.event.request.length; i++) {\n\t\t\t\t\tconst onRequest = app.event.request[i].fn\n\t\t\t\t\tlet response = onRequest(context as any)\n\t\t\t\t\tif (response instanceof Promise) response = await response\n\n\t\t\t\t\tresponse = mapEarlyResponse(response, set)\n\t\t\t\t\tif (response) return (context.response = response)\n\t\t\t\t}\n\n\t\t\tconst isWS =\n\t\t\t\trequest.method === 'GET' &&\n\t\t\t\trequest.headers.get('upgrade')?.toLowerCase() === 'websocket'\n\n\t\t\tconst methodKey = isWS ? 'WS' : request.method\n\n\t\t\tconst handler =\n\t\t\t\tapp.router.dynamic.find(request.method, path) ??\n\t\t\t\tapp.router.dynamic.find(methodKey, path) ??\n\t\t\t\tapp.router.dynamic.find('ALL', path)\n\n\t\t\tif (!handler) {\n\t\t\t\t// @ts-ignore\n\t\t\t\tcontext.query =\n\t\t\t\t\tqi === -1 ? {} : parseQuery(url.substring(qi + 1))\n\n\t\t\t\tthrow new NotFoundError()\n\t\t\t}\n\n\t\t\tconst { handle, hooks, validator, content, route } = handler.store\n\n\t\t\tlet body: string | Record<string, any> | undefined\n\t\t\tif (request.method !== 'GET' && request.method !== 'HEAD') {\n\t\t\t\tif (content) {\n\t\t\t\t\tswitch (content) {\n\t\t\t\t\t\tcase 'application/json':\n\t\t\t\t\t\t\tbody = (await request.json()) as any\n\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\tcase 'text/plain':\n\t\t\t\t\t\t\tbody = await request.text()\n\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\t\t\tbody = parseQuery(await request.text())\n\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\t\t\tbody = await request.arrayBuffer()\n\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\t\t\tbody = {}\n\n\t\t\t\t\t\t\tconst form = await request.formData()\n\t\t\t\t\t\t\tfor (const key of form.keys()) {\n\t\t\t\t\t\t\t\tif (body[key]) continue\n\n\t\t\t\t\t\t\t\tconst value = form.getAll(key)\n\t\t\t\t\t\t\t\tif (value.length === 1) body[key] = value[0]\n\t\t\t\t\t\t\t\telse body[key] = value\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet contentType\n\t\t\t\t\tif (request.body)\n\t\t\t\t\t\tcontentType = request.headers.get('content-type')\n\n\t\t\t\t\tif (contentType) {\n\t\t\t\t\t\tconst index = contentType.indexOf(';')\n\t\t\t\t\t\tif (index !== -1)\n\t\t\t\t\t\t\tcontentType = contentType.slice(0, index)\n\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tcontext.contentType = contentType\n\n\t\t\t\t\t\tif (hooks.parse)\n\t\t\t\t\t\t\tfor (let i = 0; i < hooks.parse.length; i++) {\n\t\t\t\t\t\t\t\tconst hook = hooks.parse[i].fn\n\n\t\t\t\t\t\t\t\tif (typeof hook === 'string')\n\t\t\t\t\t\t\t\t\tswitch (hook) {\n\t\t\t\t\t\t\t\t\t\tcase 'json':\n\t\t\t\t\t\t\t\t\t\tcase 'application/json':\n\t\t\t\t\t\t\t\t\t\t\tbody = (await request.json()) as any\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\t\t\tcase 'text':\n\t\t\t\t\t\t\t\t\t\tcase 'text/plain':\n\t\t\t\t\t\t\t\t\t\t\tbody = await request.text()\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\t\t\tcase 'urlencoded':\n\t\t\t\t\t\t\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\t\t\t\t\t\t\tbody = parseQuery(\n\t\t\t\t\t\t\t\t\t\t\t\tawait request.text()\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\t\t\tcase 'arrayBuffer':\n\t\t\t\t\t\t\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\t\t\t\t\t\t\tbody = await request.arrayBuffer()\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\t\t\tcase 'formdata':\n\t\t\t\t\t\t\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\t\t\t\t\t\t\tbody = {}\n\n\t\t\t\t\t\t\t\t\t\t\tconst form =\n\t\t\t\t\t\t\t\t\t\t\t\tawait request.formData()\n\t\t\t\t\t\t\t\t\t\t\tfor (const key of form.keys()) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (body[key]) continue\n\n\t\t\t\t\t\t\t\t\t\t\t\tconst value = form.getAll(key)\n\t\t\t\t\t\t\t\t\t\t\t\tif (value.length === 1)\n\t\t\t\t\t\t\t\t\t\t\t\t\tbody[key] = value[0]\n\t\t\t\t\t\t\t\t\t\t\t\telse body[key] = value\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\t\tconst parser = app['~parser'][hook]\n\t\t\t\t\t\t\t\t\t\t\tif (parser) {\n\t\t\t\t\t\t\t\t\t\t\t\tlet temp = parser(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontext as any,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontentType\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\tif (temp instanceof Promise)\n\t\t\t\t\t\t\t\t\t\t\t\t\ttemp = await temp\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (temp) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tbody = temp\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tlet temp = hook(context as any, contentType)\n\t\t\t\t\t\t\t\t\tif (temp instanceof Promise)\n\t\t\t\t\t\t\t\t\t\ttemp = await temp\n\n\t\t\t\t\t\t\t\t\tif (temp) {\n\t\t\t\t\t\t\t\t\t\tbody = temp\n\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tdelete context.contentType\n\n\t\t\t\t\t\t// body might be empty string thus can't use !body\n\t\t\t\t\t\tif (body === undefined) {\n\t\t\t\t\t\t\tswitch (contentType) {\n\t\t\t\t\t\t\t\tcase 'application/json':\n\t\t\t\t\t\t\t\t\tbody = (await request.json()) as any\n\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\tcase 'text/plain':\n\t\t\t\t\t\t\t\t\tbody = await request.text()\n\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\tcase 'application/x-www-form-urlencoded':\n\t\t\t\t\t\t\t\t\tbody = parseQuery(await request.text())\n\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\tcase 'application/octet-stream':\n\t\t\t\t\t\t\t\t\tbody = await request.arrayBuffer()\n\t\t\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t\tcase 'multipart/form-data':\n\t\t\t\t\t\t\t\t\tbody = {}\n\n\t\t\t\t\t\t\t\t\tconst form = await request.formData()\n\t\t\t\t\t\t\t\t\tfor (const key of form.keys()) {\n\t\t\t\t\t\t\t\t\t\tif (body[key]) continue\n\n\t\t\t\t\t\t\t\t\t\tconst value = form.getAll(key)\n\t\t\t\t\t\t\t\t\t\tif (value.length === 1)\n\t\t\t\t\t\t\t\t\t\t\tbody[key] = value[0]\n\t\t\t\t\t\t\t\t\t\telse body[key] = value\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontext.route = route\n\t\t\tcontext.body = body\n\t\t\tcontext.params = handler?.params || undefined\n\n\t\t\t// @ts-ignore\n\t\t\tcontext.query = qi === -1 ? {} : parseQuery(url.substring(qi + 1))\n\n\t\t\tcontext.headers = {}\n\t\t\tfor (const [key, value] of request.headers.entries())\n\t\t\t\tcontext.headers[key] = value\n\n\t\t\tconst cookieMeta = {\n\t\t\t\tdomain:\n\t\t\t\t\tapp.config.cookie?.domain ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.domain,\n\t\t\t\texpires:\n\t\t\t\t\tapp.config.cookie?.expires ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.expires,\n\t\t\t\thttpOnly:\n\t\t\t\t\tapp.config.cookie?.httpOnly ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.httpOnly,\n\t\t\t\tmaxAge:\n\t\t\t\t\tapp.config.cookie?.maxAge ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.maxAge,\n\t\t\t\t// @ts-ignore\n\t\t\t\tpath: app.config.cookie?.path ?? validator?.cookie?.config.path,\n\t\t\t\tpriority:\n\t\t\t\t\tapp.config.cookie?.priority ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.priority,\n\t\t\t\tpartitioned:\n\t\t\t\t\tapp.config.cookie?.partitioned ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.partitioned,\n\t\t\t\tsameSite:\n\t\t\t\t\tapp.config.cookie?.sameSite ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.sameSite,\n\t\t\t\tsecure:\n\t\t\t\t\tapp.config.cookie?.secure ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.secure,\n\t\t\t\tsecrets:\n\t\t\t\t\tapp.config.cookie?.secrets ??\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tvalidator?.cookie?.config.secrets,\n\t\t\t\t// @ts-ignore\n\t\t\t\tsign: app.config.cookie?.sign ?? validator?.cookie?.config.sign\n\t\t\t} as CookieOptions & {\n\t\t\t\tsign?: true | string | string[]\n\t\t\t}\n\n\t\t\tconst cookieHeaderValue = request.headers.get('cookie')\n\n\t\t\tcontext.cookie = (await parseCookie(\n\t\t\t\tcontext.set,\n\t\t\t\tcookieHeaderValue,\n\t\t\t\tcookieMeta\n\t\t\t)) as any\n\n\t\t\tconst headerValidator = validator?.createHeaders?.()\n\t\t\tif (headerValidator)\n\t\t\t\tinjectDefaultValues(headerValidator, context.headers)\n\n\t\t\tconst paramsValidator = validator?.createParams?.()\n\t\t\tif (paramsValidator)\n\t\t\t\tinjectDefaultValues(paramsValidator, context.params)\n\n\t\t\tconst queryValidator = validator?.createQuery?.()\n\t\t\tif (queryValidator)\n\t\t\t\tinjectDefaultValues(queryValidator, context.query)\n\n\t\t\tif (hooks.transform)\n\t\t\t\tfor (let i = 0; i < hooks.transform.length; i++) {\n\t\t\t\t\tconst hook = hooks.transform[i]\n\t\t\t\t\tlet response = hook.fn(context)\n\n\t\t\t\t\tif (response instanceof Promise) response = await response\n\n\t\t\t\t\t// @ts-ignore jusut in case\n\t\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\t\tconst result = mapEarlyResponse(response, context.set)\n\t\t\t\t\t\tif (result)\n\t\t\t\t\t\t\treturn (context.response = result) as Response\n\t\t\t\t\t}\n\n\t\t\t\t\tif (hook.subType === 'derive')\n\t\t\t\t\t\tObject.assign(context, response)\n\t\t\t\t}\n\n\t\t\tif (validator) {\n\t\t\t\tif (headerValidator) {\n\t\t\t\t\tconst _header = structuredClone(context.headers)\n\t\t\t\t\tfor (const [key, value] of request.headers)\n\t\t\t\t\t\t_header[key] = value\n\n\t\t\t\t\tif (validator.headers!.Check(_header) === false)\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\t'header',\n\t\t\t\t\t\t\tvalidator.headers!,\n\t\t\t\t\t\t\t_header\n\t\t\t\t\t\t)\n\t\t\t\t} else if (validator.headers?.Decode)\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tcontext.headers = validator.headers.Decode(context.headers)\n\n\t\t\t\tif (paramsValidator?.Check(context.params) === false) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t'params',\n\t\t\t\t\t\tvalidator.params!,\n\t\t\t\t\t\tcontext.params\n\t\t\t\t\t)\n\t\t\t\t} else if (validator.params?.Decode)\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tcontext.params = validator.params.Decode(context.params)\n\n\t\t\t\tif (validator.query?.schema) {\n\t\t\t\t\tlet schema = validator.query.schema\n\t\t\t\t\tif (schema.$defs?.[schema.$ref])\n\t\t\t\t\t\tschema = schema.$defs[schema.$ref]\n\n\t\t\t\t\tconst properties = schema.properties\n\n\t\t\t\t\tfor (const property of Object.keys(properties)) {\n\t\t\t\t\t\tconst value = properties[property]\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(value.type === 'array' ||\n\t\t\t\t\t\t\t\tvalue.items?.type === 'string') &&\n\t\t\t\t\t\t\ttypeof context.query[property] === 'string' &&\n\t\t\t\t\t\t\tcontext.query[property]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcontext.query[property] =\n\t\t\t\t\t\t\t\tcontext.query[property].split(',')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (queryValidator?.Check(context.query) === false)\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t'query',\n\t\t\t\t\t\tvalidator.query!,\n\t\t\t\t\t\tcontext.query\n\t\t\t\t\t)\n\t\t\t\telse if (validator.query?.Decode)\n\t\t\t\t\tcontext.query = validator.query.Decode(context.query) as any\n\n\t\t\t\tif (validator.createCookie?.()) {\n\t\t\t\t\tlet cookieValue: Record<string, unknown> = {}\n\t\t\t\t\tfor (const [key, value] of Object.entries(context.cookie))\n\t\t\t\t\t\tcookieValue[key] = value.value\n\n\t\t\t\t\tif (validator.cookie!.Check(cookieValue) === false)\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\t'cookie',\n\t\t\t\t\t\t\tvalidator.cookie!,\n\t\t\t\t\t\t\tcookieValue\n\t\t\t\t\t\t)\n\t\t\t\t\telse if (validator.cookie?.Decode)\n\t\t\t\t\t\tcookieValue = validator.cookie.Decode(\n\t\t\t\t\t\t\tcookieValue\n\t\t\t\t\t\t) as any\n\t\t\t\t}\n\n\t\t\t\tif (validator.createBody?.()?.Check(body) === false)\n\t\t\t\t\tthrow new ValidationError('body', validator.body!, body)\n\t\t\t\telse if (validator.body?.Decode)\n\t\t\t\t\tcontext.body = validator.body.Decode(body) as any\n\t\t\t}\n\n\t\t\tif (hooks.beforeHandle)\n\t\t\t\tfor (let i = 0; i < hooks.beforeHandle.length; i++) {\n\t\t\t\t\tconst hook = hooks.beforeHandle[i]\n\t\t\t\t\tlet response = hook.fn(context)\n\t\t\t\t\tif (response instanceof Promise) response = await response\n\n\t\t\t\t\tif (response instanceof ElysiaCustomStatusResponse) {\n\t\t\t\t\t\tconst result = mapEarlyResponse(response, context.set)\n\t\t\t\t\t\tif (result)\n\t\t\t\t\t\t\treturn (context.response = result) as Response\n\t\t\t\t\t}\n\n\t\t\t\t\tif (hook.subType === 'resolve') {\n\t\t\t\t\t\tObject.assign(context, response)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\t// `false` is a falsey value, check for undefined instead\n\t\t\t\t\tif (response !== undefined) {\n\t\t\t\t\t\t;(\n\t\t\t\t\t\t\tcontext as Context & {\n\t\t\t\t\t\t\t\tresponse: unknown\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t).response = response\n\n\t\t\t\t\t\tif (hooks.afterHandle)\n\t\t\t\t\t\t\tfor (let i = 0; i < hooks.afterHandle.length; i++) {\n\t\t\t\t\t\t\t\tlet newResponse = hooks.afterHandle[i].fn(\n\t\t\t\t\t\t\t\t\tcontext as Context & {\n\t\t\t\t\t\t\t\t\t\tresponse: unknown\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (newResponse instanceof Promise)\n\t\t\t\t\t\t\t\t\tnewResponse = await newResponse\n\n\t\t\t\t\t\t\t\tif (newResponse) response = newResponse\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst result = mapEarlyResponse(response, context.set)\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tif (result) return (context.response = result)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tlet response =\n\t\t\t\ttypeof handle === 'function' ? handle(context) : handle\n\t\t\tif (response instanceof Promise) response = await response\n\n\t\t\tif (!hooks.afterHandle?.length) {\n\t\t\t\tconst isCustomStatuResponse =\n\t\t\t\t\tresponse instanceof ElysiaCustomStatusResponse\n\n\t\t\t\tconst status = isCustomStatuResponse\n\t\t\t\t\t? response.code\n\t\t\t\t\t: set.status\n\t\t\t\t\t\t? typeof set.status === 'string'\n\t\t\t\t\t\t\t? StatusMap[set.status]\n\t\t\t\t\t\t\t: set.status\n\t\t\t\t\t\t: 200\n\n\t\t\t\tif (isCustomStatuResponse) {\n\t\t\t\t\tset.status = status\n\t\t\t\t\tresponse = response.response\n\t\t\t\t}\n\n\t\t\t\tconst responseValidator =\n\t\t\t\t\tvalidator?.createResponse?.()?.[status]\n\n\t\t\t\tif (responseValidator?.Check(response) === false) {\n\t\t\t\t\tif (responseValidator?.Clean) {\n\t\t\t\t\t\tconst temp = responseValidator.Clean(response)\n\t\t\t\t\t\tif (responseValidator?.Check(temp) === false)\n\t\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\t\t'response',\n\t\t\t\t\t\t\t\tresponseValidator,\n\t\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\tresponse = temp\n\t\t\t\t\t} else\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\t'response',\n\t\t\t\t\t\t\tresponseValidator,\n\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tif (responseValidator?.Encode)\n\t\t\t\t\tresponse = responseValidator.Encode(response)\n\n\t\t\t\tif (responseValidator?.Clean)\n\t\t\t\t\tresponse = responseValidator.Clean(response)\n\t\t\t} else {\n\t\t\t\t;(\n\t\t\t\t\tcontext as Context & {\n\t\t\t\t\t\tresponse: unknown\n\t\t\t\t\t}\n\t\t\t\t).response = response\n\n\t\t\t\tfor (let i = 0; i < hooks.afterHandle.length; i++) {\n\t\t\t\t\tlet response: unknown = hooks.afterHandle[i].fn(\n\t\t\t\t\t\tcontext as Context & {\n\t\t\t\t\t\t\tresponse: unknown\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\t\t\t\t\tif (response instanceof Promise) response = await response\n\n\t\t\t\t\tconst isCustomStatuResponse =\n\t\t\t\t\t\tresponse instanceof ElysiaCustomStatusResponse\n\n\t\t\t\t\tconst status = isCustomStatuResponse\n\t\t\t\t\t\t? (response as ElysiaCustomStatusResponse<any>).code\n\t\t\t\t\t\t: set.status\n\t\t\t\t\t\t\t? typeof set.status === 'string'\n\t\t\t\t\t\t\t\t? StatusMap[set.status]\n\t\t\t\t\t\t\t\t: set.status\n\t\t\t\t\t\t\t: 200\n\n\t\t\t\t\tif (isCustomStatuResponse) {\n\t\t\t\t\t\tset.status = status\n\t\t\t\t\t\tresponse = (response as ElysiaCustomStatusResponse<any>)\n\t\t\t\t\t\t\t.response\n\t\t\t\t\t}\n\n\t\t\t\t\tconst responseValidator =\n\t\t\t\t\t\tvalidator?.createResponse?.()?.[status]\n\n\t\t\t\t\tif (responseValidator?.Check(response) === false) {\n\t\t\t\t\t\tif (responseValidator?.Clean) {\n\t\t\t\t\t\t\tconst temp = responseValidator.Clean(response)\n\t\t\t\t\t\t\tif (responseValidator?.Check(temp) === false)\n\t\t\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\t\t\t'response',\n\t\t\t\t\t\t\t\t\tresponseValidator,\n\t\t\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tresponse = temp\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\t\t'response',\n\t\t\t\t\t\t\t\tresponseValidator,\n\t\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (responseValidator?.Encode)\n\t\t\t\t\t\tcontext.response = response =\n\t\t\t\t\t\t\tresponseValidator.Encode(response)\n\n\t\t\t\t\tif (responseValidator?.Clean)\n\t\t\t\t\t\tcontext.response = response =\n\t\t\t\t\t\t\tresponseValidator.Clean(response)\n\n\t\t\t\t\tconst result = mapEarlyResponse(response, context.set)\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (result !== undefined) return (context.response = result)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (context.set.cookie && cookieMeta?.sign) {\n\t\t\t\tconst secret = !cookieMeta.secrets\n\t\t\t\t\t? undefined\n\t\t\t\t\t: typeof cookieMeta.secrets === 'string'\n\t\t\t\t\t\t? cookieMeta.secrets\n\t\t\t\t\t\t: cookieMeta.secrets[0]\n\n\t\t\t\tif (cookieMeta.sign === true) {\n\t\t\t\t\tif (secret)\n\t\t\t\t\t\tfor (const [key, cookie] of Object.entries(\n\t\t\t\t\t\t\tcontext.set.cookie\n\t\t\t\t\t\t))\n\t\t\t\t\t\t\tcontext.set.cookie[key].value = await signCookie(\n\t\t\t\t\t\t\t\tcookie.value as any,\n\t\t\t\t\t\t\t\tsecret\n\t\t\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tconst properties = validator?.cookie?.schema?.properties\n\n\t\t\t\t\tif (secret)\n\t\t\t\t\t\tfor (const name of cookieMeta.sign) {\n\t\t\t\t\t\t\tif (!(name in properties)) continue\n\n\t\t\t\t\t\t\tif (context.set.cookie[name]?.value) {\n\t\t\t\t\t\t\t\tcontext.set.cookie[name].value =\n\t\t\t\t\t\t\t\t\tawait signCookie(\n\t\t\t\t\t\t\t\t\t\tcontext.set.cookie[name].value as any,\n\t\t\t\t\t\t\t\t\t\tsecret\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// @ts-expect-error\n\t\t\treturn mapResponse((context.response = response), context.set)\n\t\t} catch (error) {\n\t\t\tconst reportedError =\n\t\t\t\terror instanceof TransformDecodeError && error.error\n\t\t\t\t\t? error.error\n\t\t\t\t\t: error\n\n\t\t\t// ? Since error is reconciled in mergeResponseWithHeaders, this is not needed (if I'm not drunk)\n\t\t\t// if ((reportedError as ElysiaErrors).status)\n\t\t\t// \tset.status = (reportedError as ElysiaErrors).status\n\n\t\t\t// @ts-expect-error private\n\t\t\treturn app.handleError(context, reportedError)\n\t\t} finally {\n\t\t\tif (app.event.afterResponse)\n\t\t\t\tsetImmediate(async () => {\n\t\t\t\t\tfor (const afterResponse of app.event.afterResponse!)\n\t\t\t\t\t\tawait afterResponse.fn(context as any)\n\t\t\t\t})\n\t\t}\n\t}\n}\n\nexport const createDynamicErrorHandler = (app: AnyElysia) => {\n\tconst { mapResponse } = app['~adapter'].handler\n\n\treturn async (\n\t\tcontext: Context & {\n\t\t\tresponse: unknown\n\t\t},\n\t\terror: ElysiaErrors\n\t) => {\n\t\tconst errorContext = Object.assign(context, { error, code: error.code })\n\t\terrorContext.set = context.set\n\n\t\tif (app.event.error)\n\t\t\tfor (let i = 0; i < app.event.error.length; i++) {\n\t\t\t\tconst hook = app.event.error[i]\n\t\t\t\tlet response = hook.fn(errorContext as any)\n\t\t\t\tif (response instanceof Promise) response = await response\n\t\t\t\tif (response !== undefined && response !== null)\n\t\t\t\t\treturn (context.response = mapResponse(\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tcontext.set\n\t\t\t\t\t))\n\t\t\t}\n\n\t\treturn new Response(\n\t\t\ttypeof error.cause === 'string' ? error.cause : error.message,\n\t\t\t{\n\t\t\t\theaders: context.set.headers as any,\n\t\t\t\tstatus: error.status ?? 500\n\t\t\t}\n\t\t)\n\t}\n}\n"
|
|
33
33
|
],
|
|
34
|
-
"mappings": ";0qBAEA,IA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