Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elysia

Package Overview
Dependencies
Maintainers
0
Versions
429
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elysia - npm Package Compare versions

Comparing version 1.2.0-exp.18 to 1.2.0-exp.19

dist/cjs/universal/file.js

4

dist/adapter/node/handler.d.ts

@@ -1,3 +0,3 @@

import { type IncomingMessage, type ServerResponse } from 'node:http';
import { Readable } from 'node:stream';
import { type IncomingMessage, type ServerResponse } from 'http';
import { Readable } from 'stream';
import type { Context } from '../../context';

@@ -4,0 +4,0 @@ import type { HTTPHeaders } from '../../types';

@@ -1,2 +0,2 @@

import { type IncomingMessage } from 'node:http';
import { type IncomingMessage } from 'http';
import type { ElysiaAdapter } from '../types';

@@ -3,0 +3,0 @@ export declare const ElysiaNodeContext: unique symbol;

@@ -1,1 +0,1 @@

"use strict";var b=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(t,a)=>{for(var n in a)b(t,n,{get:a[n],enumerable:!0})},N=(t,a,n,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of E(a))!p.call(t,e)&&e!==n&&b(t,e,{get:()=>a[e],enumerable:!(i=x(a,e))||i.enumerable});return t};var B=t=>N(b({},"__esModule",{value:!0}),t);var F={};v(F,{errorToResponse:()=>d,handleStreamResponse:()=>C,mapCompactResponse:()=>h,mapEarlyResponse:()=>c,mapResponse:()=>o,readableStreamToReadable:()=>S,responseToValue:()=>f,serializeCookie:()=>k,streamResponse:()=>g});module.exports=B(F);var H=require("cookie"),w=require("node:stream"),s=require("../../utils"),y=require("../../cookies"),R=require("../../error");const m=(t,a)=>{const n=t.size;if(!a&&n||n&&a&&a.status!==206&&a.status!==304&&a.status!==412&&a.status!==416){if(a&&(0,s.isNotEmpty)(a.headers)){if(a.headers instanceof Headers)for(const[i,e]of a.headers.entries())i in a.headers&&(a.headers[i]=e);return new Response(t,{status:a.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`},a.headers)})}return new Response(t,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`,"transfer-encoding":"chunked"}})}return new Response(t)},k=t=>{if(!t||!(0,s.isNotEmpty)(t))return;const a=[];for(const[n,i]of Object.entries(t)){if(!n||!i)continue;const e=i.value;e!=null&&a.push((0,H.serialize)(n,typeof e=="object"?JSON.stringify(e):e+"",i))}if(a.length!==0)return a.length===1?a[0]:a},r=(t,a,n)=>(a?(a.headers["transfer-encoding"]="chunked",a.headers["content-type"]="text/event-stream;charset=utf8"):a={status:200,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream;charset=utf8"}},n&&n.writeHead(a.status,a.headers),[C(t,a,n),a]),C=(t,a,n)=>{const i=new w.Readable({read(){}});return n&&i.pipe(n),(async()=>{let e=t.next();if(e instanceof Promise&&(e=await e),e.done)return a?o(e.value,a,n):h(e.value,n);if(e.value!==void 0&&e.value!==null)if(typeof e.value=="object")try{i.push(Buffer.from(JSON.stringify(e.value)))}catch{i.push(Buffer.from(e.value.toString()))}else i.push(Buffer.from(e.value.toString()));for await(const u of t)if(u!=null){if(typeof u=="object")try{i.push(Buffer.from(JSON.stringify(u)))}catch{i.push(Buffer.from(u.toString()))}else i.push(Buffer.from(u.toString()));await new Promise(l=>setTimeout(()=>l(),0))}i.push(null)})(),i};async function*g(t){const a=t.body;if(!a)return;const n=a.getReader(),i=new TextDecoder;try{for(;;){const{done:e,value:u}=await n.read();if(e)break;yield i.decode(u)}}finally{n.releaseLock()}}const o=(t,a,n)=>{if((0,s.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=s.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,s.isNotEmpty)(a.cookie)){const i=k(a.cookie);i&&(a.headers["set-cookie"]=i)}switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",n&&(a.headers["content-length"]=t.length,n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Blob":return a.headers["content-length"]=t.size,t=m(t),n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"ElysiaCustomStatusResponse":return a.status=t.code,o(t.response,a,n);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream;charset=utf8"),n&&(n.writeHead(a.status,a.headers),S(t).pipe(n)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t?.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]):(n&&(a.headers["content-length"]=0,n.writeHead(a.status,a.headers),n.end("")),["",a]);case"Response":let i=!1;if(a.headers instanceof Headers)for(const e of a.headers.keys())if(e==="set-cookie"){if(i)continue;i=!0;for(const u of a.headers.getSetCookie())t.headers.append("set-cookie",u)}else t.headers.append(e,a.headers?.get(e)??"");else for(const e in a.headers)t.headers.append(e,a.headers[e]);return t.status!==a.status&&(a.status=t.status),t.headers.get("transfer-encoding")==="chunked"?r(g(t),a,n):(n&&f(t,n),[t,a]);case"Error":return d(t,a,n);case"Promise":return t.then(e=>o(e,a,n));case"Function":return o(t(),a,n);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Cookie":return t instanceof y.Cookie?o(t.value,a,n):o(t?.toString(),a,n);case"FormData":return n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];default:if(t instanceof Response){let e=!1;if(a.headers instanceof Headers)for(const u of a.headers.keys())if(u==="set-cookie"){if(e)continue;e=!0;for(const l of a.headers.getSetCookie())t.headers.append("set-cookie",l)}else t.headers.append(u,a.headers?.get(u)??"");else for(const u in a.headers)t.headers.append(u,a.headers[u]);for(const[u,l]of t.headers.entries())u in a.headers&&(a.headers[u]=l);return n&&f(t,n),[t,a]}if(t instanceof Promise)return t.then(e=>o(e,a,n));if(t instanceof Error)return d(t,a,n);if(t instanceof R.ElysiaCustomStatusResponse)return a.status=t.code,o(t.response,a,n);if(typeof t?.next=="function")return r(t,a,n);if("toResponse"in t)return o(t.toResponse(),a,n);if("charCodeAt"in t){const e=t.charCodeAt(0);if(e===123||e===91)return a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),t=JSON.stringify(t),a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]}}else switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a];case"Blob":return a.headers["content-length"]=t.size,t=m(t),n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a];case"ElysiaCustomStatusResponse":return a.status=t.code,o(t.response,a,n);case"ReadableStream":return a.headers["content-type"]="text/event-stream;charset=utf8",n&&(n.writeHead(200,a.headers),S(t).pipe(n)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a]):(n&&(a.headers["content-length"]=0,n.writeHead(a.status,a.headers),n.end(t)),["",a]);case"Response":return t.headers.get("transfer-encoding")==="chunked"?r(g(t),a,n):(n&&f(t,n),[t,a]);case"Error":return d(t,a,n);case"Promise":return t.then(i=>{const e=h(i,n);return e!==void 0?[e,a]:["",a]});case"Function":return h(t(),n);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a];case"Cookie":return t instanceof y.Cookie?o(t.value,a,n):o(t?.toString(),a,n);case"FormData":return n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];default:if(t instanceof Response)return n&&f(t,n),[t,a];if(t instanceof Promise)return t.then(i=>o(i,a,n));if(t instanceof Error)return t=d(t,a,n),t;if(t instanceof R.ElysiaCustomStatusResponse)return a.status=t.code,o(t.response,a,n);if(typeof t?.next=="function")return r(t,a,n);if("toResponse"in t)return o(t.toResponse(),a,n);if("charCodeAt"in t){const i=t.charCodeAt(0);if(i===123||i===91)return t=JSON.stringify(t),a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a]}},c=(t,a,n)=>{if(t!=null)if((0,s.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=s.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,s.isNotEmpty)(a.cookie)){const i=k(a.cookie);i&&(a.headers["set-cookie"]=i)}switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Blob":return a.headers["content-length"]=t.size,t=m(t),n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"ElysiaCustomStatusResponse":return a.status=t.code,c(t.response,a,n);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream;charset=utf8"),n&&(n.writeHead(a.status,a.headers),S(t).pipe(n)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,[t,a]):(a.headers["content-length"]=0,n&&(n.writeHead(a.status,a.headers),n.end(t)),["",a]);case"Response":let i=!1;if(a.headers instanceof Headers)for(const e of a.headers.keys())if(e==="set-cookie"){if(i)continue;i=!0;for(const u of a.headers.getSetCookie())t.headers.append("set-cookie",u)}else t.headers.append(e,a.headers?.get(e)??"");else for(const e in a.headers)t.headers.append(e,a.headers[e]);return t.status!==a.status&&(a.status=t.status),t.headers.get("transfer-encoding")==="chunked"?r(g(t),a,n):(n&&f(t,n),[t,a]);case"Error":return d(t,a,n);case"Promise":return t.then(e=>{const u=c(e,a,n);if(u!==void 0)return[u,a]});case"Function":return c(t(),a,n);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Cookie":return t instanceof y.Cookie?c(t.value,a,n):c(t?.toString(),a,n);case"FormData":return n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];default:if(t instanceof Response){let e=!1;if(a.headers instanceof Headers)for(const u of a.headers.keys())if(u==="set-cookie"){if(e)continue;e=!0;for(const l of a.headers.getSetCookie())t.headers.append("set-cookie",l)}else t.headers.append(u,a.headers?.get(u)??"");else for(const u in a.headers)t.headers.append(u,a.headers[u]);return t.status!==a.status&&(a.status=t.status),n&&f(t,n),[t,a]}if(t instanceof Promise)return t.then(e=>c(e,a,n));if(t instanceof Error)return d(t,a,n);if(t instanceof R.ElysiaCustomStatusResponse)return a.status=t.code,c(t.response,a,n);if(typeof t?.next=="function")return r(t,a,n);if("toResponse"in t)return c(t.toResponse(),a,n);if("charCodeAt"in t){const e=t.charCodeAt(0);if(e===123||e===91)return t=JSON.stringify(t),a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]}}else switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a];case"Blob":return a.headers["content-length"]=t.size,t=m(t),n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a];case"ElysiaCustomStatusResponse":return a.status=t.code,c(t.response,a,n);case"ReadableStream":return a.headers["content-type"]="text/event-stream;charset=utf8",n&&(n.writeHead(200,a.headers),S(t).pipe(n)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a]):(a.headers["content-length"]=0,n&&(n.writeHead(a.status,a.headers),n.end(t)),["",a]);case"Response":return t.headers.get("transfer-encoding")==="chunked"?r(g(t),a,n):(n&&f(t,n),[t,a]);case"Error":return d(t,a,n);case"Promise":return t.then(i=>{const e=c(i,a,n);if(e!==void 0)return e});case"Function":return h(t(),n);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a];case"Cookie":return t instanceof y.Cookie?c(t.value,a,n):c(t?.toString(),a,n);case"FormData":return n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a];default:if(t instanceof Response)return n&&f(t,n),[t,a];if(t instanceof Promise)return t.then(i=>c(i,a,n));if(t instanceof Error)return d(t,a,n);if(t instanceof R.ElysiaCustomStatusResponse)return a.status=t.code,c(t.response,a,n);if(typeof t?.next=="function")return r(t,a,n);if("toResponse"in t)return c(t.toResponse(),a,n);if("charCodeAt"in t){const i=t.charCodeAt(0);if(i===123||i===91)return t=JSON.stringify(t),a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),a.headers["content-length"]=t.length,n&&(n.writeHead(a.status,a.headers),n.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,n&&(n.writeHead(200,a.headers),n.end(t)),[t,a]}},h=(t,a)=>{switch(t?.constructor?.name){case"String":return a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}];case"Array":case"Object":return t=JSON.stringify(t),a&&(a.writeHead(200,{"content-type":"application/json;charset=utf8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"application/json;charset=utf8"}}];case"Blob":return a&&(a.writeHead(200),a.end(t)),[t,{status:200}];case"ElysiaCustomStatusResponse":return o(t.response,{status:t.code,headers:{}},a);case"ReadableStream":return a&&(a.writeHead(200,{"content-type":"text/event-stream;charset=utf8"}),S(t).pipe(a)),[t,{status:200,headers:{"Content-Type":"text/event-stream;charset=utf8"}}];case void 0:return t?(t=JSON.stringify(t),a?.writeHead(200,{"content-type":"application/json;charset=utf-8","content-length":t.length}),[t,{status:200,headers:{"content-type":"application/json;charset=utf-8"}}]):(a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":0}),a.end("")),["",{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}]);case"Response":return t.headers.get("transfer-encoding")==="chunked"?r(g(t),void 0,a):(a&&f(t,a),[t,{status:200}]);case"Error":return d(t,void 0,a);case"Promise":return t.then(n=>h(n,a));case"Function":return h(t(),a);case"Number":case"Boolean":return t=t.toString(),a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}];case"Cookie":return t instanceof y.Cookie?h(t.value,a):(a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t?.toString()}),a.end(t?.toString())),[t?.toString(),{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}]);case"FormData":return a&&(a.writeHead(200),a.end(t)),[t,{status:200}];default:if(t instanceof Response)return a&&f(t,a),[t,{status:200}];if(t instanceof Promise)return t.then(n=>h(n,a));if(t instanceof Error)return d(t,void 0,a);if(t instanceof R.ElysiaCustomStatusResponse)return o(t.response,{status:t.code,headers:{}},a);if(typeof t?.next=="function")return r(t,void 0,a);if("toResponse"in t)return h(t.toResponse());if("charCodeAt"in t){const n=t.charCodeAt(0);if(n===123||n===91)return t=JSON.stringify(t),a&&(a.writeHead(200,{"content-type":"application/json;charset=utf8","content-length":t.length}),a.end(t)),[t,{status:200}]}return a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}]}},d=(t,a,n)=>{const i=JSON.stringify({name:t?.name,message:t?.message,cause:t?.cause});let e=a?.status;e||(e=500),a?.status===200&&(e=500);let u=a?.headers;return u?(u["content-length"]=i.length,u["content-type"]="application/json;charset=utf-8"):u={"content-length":i.length,"content-type":"application/json;charset=utf-8"},n&&(console.log(200,u),n.writeHead(200,u),n.end(i)),[i,{status:e,headers:u}]},S=t=>new w.Readable({async read(){const a=t.getReader();try{for(;;){const{done:n,value:i}=await a.read();if(n)break;this.push(Buffer.from(i))}}catch(n){this.destroy(n)}}}),f=(t,a)=>{for(const[n,i]of Object.entries(t.headers))a.setHeader(n,i);a.statusCode=t.status,t.arrayBuffer().then(a.end).catch(n=>d(n,void 0,a))};0&&(module.exports={errorToResponse,handleStreamResponse,mapCompactResponse,mapEarlyResponse,mapResponse,readableStreamToReadable,responseToValue,serializeCookie,streamResponse});
"use strict";var b=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var v=(t,a)=>{for(var e in a)b(t,e,{get:a[e],enumerable:!0})},N=(t,a,e,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of x(a))!F.call(t,n)&&n!==e&&b(t,n,{get:()=>a[n],enumerable:!(i=C(a,n))||i.enumerable});return t};var j=t=>N(b({},"__esModule",{value:!0}),t);var O={};v(O,{errorToResponse:()=>d,handleStreamResponse:()=>H,mapCompactResponse:()=>h,mapEarlyResponse:()=>u,mapResponse:()=>o,readableStreamToReadable:()=>y,responseToValue:()=>r,serializeCookie:()=>p,streamResponse:()=>S});module.exports=j(O);var w=require("cookie"),k=require("stream"),s=require("../../utils"),R=require("../../cookies"),g=require("../../error");const E=(t,a,e)=>{const i=t.size;if(a){let n;if(a.headers instanceof Headers){n={"accept-ranges":"bytes","content-range":`bytes 0-${i-1}/${i}`,"transfer-encoding":"chunked"};for(const[c,l]of a.headers.entries())c in a.headers&&(n[c]=l)}else(0,s.isNotEmpty)(a.headers)&&(Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${i-1}/${i}`,"transfer-encoding":"chunked"},a.headers),n=a.headers)}return e&&y(t.stream()).pipe(e),[t,a]},m=(t,a,e)=>{let i,n;return a?(Object.assign(a.headers,{"accept-range":"bytes","content-type":t.type,"content-range":`bytes 0-${t.length-1}/${t.length}`}),e&&e.writeHead(a.status,a.headers),n=a.status,i=a.headers):(i={"accept-range":"bytes","content-type":t.type,"content-range":`bytes 0-${t.length-1}/${t.length}`},e&&e.writeHead(200,i),n=200),e&&t.value.pipe(e),[t,{status:n,headers:i}]},p=t=>{if(!t||!(0,s.isNotEmpty)(t))return;const a=[];for(const[e,i]of Object.entries(t)){if(!e||!i)continue;const n=i.value;n!=null&&a.push((0,w.serialize)(e,typeof n=="object"?JSON.stringify(n):n+"",i))}if(a.length!==0)return a.length===1?a[0]:a},f=(t,a,e)=>(a?(a.headers["transfer-encoding"]="chunked",a.headers["content-type"]="text/event-stream;charset=utf8"):a={status:200,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream;charset=utf8"}},e&&e.writeHead(a.status,a.headers),[H(t,a,e),a]),H=(t,a,e)=>{const i=new k.Readable({read(){}});return e&&i.pipe(e),(async()=>{let n=t.next();if(n instanceof Promise&&(n=await n),n.done)return a?o(n.value,a,e):h(n.value,e);if(n.value!==void 0&&n.value!==null)if(typeof n.value=="object")try{i.push(Buffer.from(JSON.stringify(n.value)))}catch{i.push(Buffer.from(n.value.toString()))}else i.push(Buffer.from(n.value.toString()));for await(const c of t)if(c!=null){if(typeof c=="object")try{i.push(Buffer.from(JSON.stringify(c)))}catch{i.push(Buffer.from(c.toString()))}else i.push(Buffer.from(c.toString()));await new Promise(l=>setTimeout(()=>l(),0))}i.push(null)})(),i};async function*S(t){const a=t.body;if(!a)return;const e=a.getReader(),i=new TextDecoder;try{for(;;){const{done:n,value:c}=await e.read();if(n)break;yield i.decode(c)}}finally{e.releaseLock()}}const o=(t,a,e)=>{if((0,s.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=s.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,s.isNotEmpty)(a.cookie)){const i=p(a.cookie);i&&(a.headers["set-cookie"]=i)}switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",e&&(a.headers["content-length"]=t.length,e.writeHead(a.status,a.headers),e.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];case"ElysiaFile":return m(t,a,e);case"Blob":return a.headers["content-length"]=t.size,E(t,a,e);case"ElysiaCustomStatusResponse":return a.status=t.code,o(t.response,a,e);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream;charset=utf8"),e&&(e.writeHead(a.status,a.headers),y(t).pipe(e)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t?.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]):(e&&(a.headers["content-length"]=0,e.writeHead(a.status,a.headers),e.end("")),["",a]);case"Response":let i=!1;if(a.headers instanceof Headers)for(const n of a.headers.keys())if(n==="set-cookie"){if(i)continue;i=!0;for(const c of a.headers.getSetCookie())t.headers.append("set-cookie",c)}else t.headers.append(n,a.headers?.get(n)??"");else for(const n in a.headers)t.headers.append(n,a.headers[n]);return t.status!==a.status&&(a.status=t.status),t.headers.get("transfer-encoding")==="chunked"?f(S(t),a,e):(e&&r(t,e),[t,a]);case"Error":return d(t,a,e);case"Promise":return t.then(n=>o(n,a,e));case"Function":return o(t(),a,e);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];case"Cookie":return t instanceof R.Cookie?o(t.value,a,e):o(t?.toString(),a,e);case"FormData":return e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];default:if(t instanceof Response){let n=!1;if(a.headers instanceof Headers)for(const c of a.headers.keys())if(c==="set-cookie"){if(n)continue;n=!0;for(const l of a.headers.getSetCookie())t.headers.append("set-cookie",l)}else t.headers.append(c,a.headers?.get(c)??"");else for(const c in a.headers)t.headers.append(c,a.headers[c]);for(const[c,l]of t.headers.entries())c in a.headers&&(a.headers[c]=l);return e&&r(t,e),[t,a]}if(t instanceof Promise)return t.then(n=>o(n,a,e));if(t instanceof Error)return d(t,a,e);if(t instanceof g.ElysiaCustomStatusResponse)return a.status=t.code,o(t.response,a,e);if(typeof t?.next=="function")return f(t,a,e);if("toResponse"in t)return o(t.toResponse(),a,e);if("charCodeAt"in t){const n=t.charCodeAt(0);if(n===123||n===91)return a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),t=JSON.stringify(t),a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]}}else switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a];case"ElysiaFile":return m(t,a,e);case"Blob":return a.headers["content-length"]=t.size,E(t,a,e);case"ElysiaCustomStatusResponse":return a.status=t.code,o(t.response,a,e);case"ReadableStream":return a.headers["content-type"]="text/event-stream;charset=utf8",e&&(e.writeHead(200,a.headers),y(t).pipe(e)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a]):(e&&(a.headers["content-length"]=0,e.writeHead(a.status,a.headers),e.end(t)),["",a]);case"Response":return t.headers.get("transfer-encoding")==="chunked"?f(S(t),a,e):(e&&r(t,e),[t,a]);case"Error":return d(t,a,e);case"Promise":return t.then(i=>{const n=h(i,e);return n!==void 0?[n,a]:["",a]});case"Function":return h(t(),e);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a];case"Cookie":return t instanceof R.Cookie?o(t.value,a,e):o(t?.toString(),a,e);case"FormData":return e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];default:if(t instanceof Response)return e&&r(t,e),[t,a];if(t instanceof Promise)return t.then(i=>o(i,a,e));if(t instanceof Error)return t=d(t,a,e),t;if(t instanceof g.ElysiaCustomStatusResponse)return a.status=t.code,o(t.response,a,e);if(typeof t?.next=="function")return f(t,a,e);if("toResponse"in t)return o(t.toResponse(),a,e);if("charCodeAt"in t){const i=t.charCodeAt(0);if(i===123||i===91)return t=JSON.stringify(t),a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a]}},u=(t,a,e)=>{if(t!=null)if((0,s.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=s.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,s.isNotEmpty)(a.cookie)){const i=p(a.cookie);i&&(a.headers["set-cookie"]=i)}switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];case"ElysiaFile":return m(t,a,e);case"Blob":return E(t,a,e);case"ElysiaCustomStatusResponse":return a.status=t.code,u(t.response,a,e);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream;charset=utf8"),e&&(e.writeHead(a.status,a.headers),y(t).pipe(e)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,[t,a]):(a.headers["content-length"]=0,e&&(e.writeHead(a.status,a.headers),e.end(t)),["",a]);case"Response":let i=!1;if(a.headers instanceof Headers)for(const n of a.headers.keys())if(n==="set-cookie"){if(i)continue;i=!0;for(const c of a.headers.getSetCookie())t.headers.append("set-cookie",c)}else t.headers.append(n,a.headers?.get(n)??"");else for(const n in a.headers)t.headers.append(n,a.headers[n]);return t.status!==a.status&&(a.status=t.status),t.headers.get("transfer-encoding")==="chunked"?f(S(t),a,e):(e&&r(t,e),[t,a]);case"Error":return d(t,a,e);case"Promise":return t.then(n=>{const c=u(n,a,e);if(c!==void 0)return[c,a]});case"Function":return u(t(),a,e);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];case"Cookie":return t instanceof R.Cookie?u(t.value,a,e):u(t?.toString(),a,e);case"FormData":return e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];default:if(t instanceof Response){let n=!1;if(a.headers instanceof Headers)for(const c of a.headers.keys())if(c==="set-cookie"){if(n)continue;n=!0;for(const l of a.headers.getSetCookie())t.headers.append("set-cookie",l)}else t.headers.append(c,a.headers?.get(c)??"");else for(const c in a.headers)t.headers.append(c,a.headers[c]);return t.status!==a.status&&(a.status=t.status),e&&r(t,e),[t,a]}if(t instanceof Promise)return t.then(n=>u(n,a,e));if(t instanceof Error)return d(t,a,e);if(t instanceof g.ElysiaCustomStatusResponse)return a.status=t.code,u(t.response,a,e);if(typeof t?.next=="function")return f(t,a,e);if("toResponse"in t)return u(t.toResponse(),a,e);if("charCodeAt"in t){const n=t.charCodeAt(0);if(n===123||n===91)return t=JSON.stringify(t),a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]}}else switch(t?.constructor?.name){case"String":return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a];case"Array":case"Object":return t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a];case"ElysiaFile":return m(t,a,e);case"Blob":return E(t,a,e);case"ElysiaCustomStatusResponse":return a.status=t.code,u(t.response,a,e);case"ReadableStream":return a.headers["content-type"]="text/event-stream;charset=utf8",e&&(e.writeHead(200,a.headers),y(t).pipe(e)),[t,a];case void 0:return t?(t=JSON.stringify(t),a.headers["content-type"]="application/json;charset=utf8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a]):(a.headers["content-length"]=0,e&&(e.writeHead(a.status,a.headers),e.end(t)),["",a]);case"Response":return t.headers.get("transfer-encoding")==="chunked"?f(S(t),a,e):(e&&r(t,e),[t,a]);case"Error":return d(t,a,e);case"Promise":return t.then(i=>{const n=u(i,a,e);if(n!==void 0)return n});case"Function":return h(t(),e);case"Number":case"Boolean":return t=t.toString(),a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a];case"Cookie":return t instanceof R.Cookie?u(t.value,a,e):u(t?.toString(),a,e);case"FormData":return e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a];default:if(t instanceof Response)return e&&r(t,e),[t,a];if(t instanceof Promise)return t.then(i=>u(i,a,e));if(t instanceof Error)return d(t,a,e);if(t instanceof g.ElysiaCustomStatusResponse)return a.status=t.code,u(t.response,a,e);if(typeof t?.next=="function")return f(t,a,e);if("toResponse"in t)return u(t.toResponse(),a,e);if("charCodeAt"in t){const i=t.charCodeAt(0);if(i===123||i===91)return t=JSON.stringify(t),a.headers["Content-Type"]||(a.headers["content-type"]="application/json;charset=utf8"),a.headers["content-length"]=t.length,e&&(e.writeHead(a.status,a.headers),e.end(t)),[t,a]}return a.headers["content-type"]="text/plain;charset=utf-8",a.headers["content-length"]=t.length,e&&(e.writeHead(200,a.headers),e.end(t)),[t,a]}},h=(t,a)=>{switch(t?.constructor?.name){case"String":return a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}];case"Array":case"Object":return t=JSON.stringify(t),a&&(a.writeHead(200,{"content-type":"application/json;charset=utf8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"application/json;charset=utf8"}}];case"ElysiaFile":return m(t,void 0,a);case"Blob":return a&&(a.writeHead(200),a.end(t)),[t,{status:200}];case"ElysiaCustomStatusResponse":return o(t.response,{status:t.code,headers:{}},a);case"ReadableStream":return a&&(a.writeHead(200,{"content-type":"text/event-stream;charset=utf8"}),y(t).pipe(a)),[t,{status:200,headers:{"Content-Type":"text/event-stream;charset=utf8"}}];case void 0:return t?(t=JSON.stringify(t),a?.writeHead(200,{"content-type":"application/json;charset=utf-8","content-length":t.length}),[t,{status:200,headers:{"content-type":"application/json;charset=utf-8"}}]):(a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":0}),a.end("")),["",{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}]);case"Response":return t.headers.get("transfer-encoding")==="chunked"?f(S(t),void 0,a):(a&&r(t,a),[t,{status:200}]);case"Error":return d(t,void 0,a);case"Promise":return t.then(e=>h(e,a));case"Function":return h(t(),a);case"Number":case"Boolean":return t=t.toString(),a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}];case"Cookie":return t instanceof R.Cookie?h(t.value,a):(a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t?.toString()}),a.end(t?.toString())),[t?.toString(),{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}]);case"FormData":return a&&(a.writeHead(200),a.end(t)),[t,{status:200}];default:if(t instanceof Response)return a&&r(t,a),[t,{status:200}];if(t instanceof Promise)return t.then(e=>h(e,a));if(t instanceof Error)return d(t,void 0,a);if(t instanceof g.ElysiaCustomStatusResponse)return o(t.response,{status:t.code,headers:{}},a);if(typeof t?.next=="function")return f(t,void 0,a);if("toResponse"in t)return h(t.toResponse());if("charCodeAt"in t){const e=t.charCodeAt(0);if(e===123||e===91)return t=JSON.stringify(t),a&&(a.writeHead(200,{"content-type":"application/json;charset=utf8","content-length":t.length}),a.end(t)),[t,{status:200}]}return a&&(a.writeHead(200,{"content-type":"text/plain;charset=utf-8","content-length":t.length}),a.end(t)),[t,{status:200,headers:{"content-type":"text/plain;charset=utf-8"}}]}},d=(t,a,e)=>{const i=JSON.stringify({name:t?.name,message:t?.message,cause:t?.cause});let n=a?.status;n||(n=500),a?.status===200&&(n=500);let c=a?.headers;return c?(c["content-length"]=i.length,c["content-type"]="application/json;charset=utf-8"):c={"content-length":i.length,"content-type":"application/json;charset=utf-8"},e&&(console.log(200,c),e.writeHead(200,c),e.end(i)),[i,{status:n,headers:c}]},y=t=>new k.Readable({async read(){const a=t.getReader();try{for(;;){const{done:e,value:i}=await a.read();if(e)break;this.push(Buffer.from(i))}}catch(e){this.destroy(e)}}}),r=(t,a)=>{for(const[e,i]of Object.entries(t.headers))a.setHeader(e,i);a.statusCode=t.status,t.arrayBuffer().then(a.end).catch(e=>d(e,void 0,a))};0&&(module.exports={errorToResponse,handleStreamResponse,mapCompactResponse,mapEarlyResponse,mapResponse,readableStreamToReadable,responseToValue,serializeCookie,streamResponse});

@@ -1,2 +0,2 @@

"use strict";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},g=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of h(t))!b.call(e,n)&&n!==r&&d(e,n,{get:()=>t[n],enumerable:!(s=y(t,n))||s.enumerable});return e};var p=e=>g(d({},"__esModule",{value:!0}),e);var k={};m(k,{ElysiaNodeContext:()=>a,NodeAdapter:()=>x,nodeRequestToWebstand:()=>c});module.exports=p(k);var i=require("node:http"),u=require("node:stream"),o=require("./handler"),f=require("../../utils");const a=Symbol("ElysiaNodeContext"),E=e=>e.headers.host?`http://${e.headers.host}${e.url}`:e.socket?.localPort?`http://localhost:${e.socket?.localPort}${e.url}`:`http://localhost${e.url}`,c=(e,t)=>{let r;return new Request(E(e),{method:e.method,headers:e.headers,get body(){return e.method==="GET"||e.method==="HEAD"?void 0:u.Readable.toWeb(e)},get signal(){if(r)return r;const s=t??new AbortController;return r=s.signal,e.once("close",()=>{s.abort()}),r}})},x={name:"node",handler:{mapResponse:o.mapResponse,mapEarlyResponse:o.mapEarlyResponse,mapCompactResponse:o.mapCompactResponse,createStaticHandler:(e,t,r)=>(0,o.mapResponse)(e,{status:200,headers:r??{}})},composeHandler:{declare(e){if(e.request)return`Object.defineProperty(c,'request',{get(){return nodeRequestToWebstand(c[ElysiaNodeContext].req)}})
"use strict";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},g=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of h(t))!b.call(e,n)&&n!==r&&d(e,n,{get:()=>t[n],enumerable:!(s=y(t,n))||s.enumerable});return e};var p=e=>g(d({},"__esModule",{value:!0}),e);var k={};m(k,{ElysiaNodeContext:()=>a,NodeAdapter:()=>x,nodeRequestToWebstand:()=>c});module.exports=p(k);var i=require("http"),u=require("stream"),o=require("./handler"),f=require("../../utils");const a=Symbol("ElysiaNodeContext"),E=e=>e.headers.host?`http://${e.headers.host}${e.url}`:e.socket?.localPort?`http://localhost:${e.socket?.localPort}${e.url}`:`http://localhost${e.url}`,c=(e,t)=>{let r;return new Request(E(e),{method:e.method,headers:e.headers,get body(){return e.method==="GET"||e.method==="HEAD"?void 0:u.Readable.toWeb(e)},get signal(){if(r)return r;const s=t??new AbortController;return r=s.signal,e.once("close",()=>{s.abort()}),r}})},x={name:"node",handler:{mapResponse:o.mapResponse,mapEarlyResponse:o.mapEarlyResponse,mapCompactResponse:o.mapCompactResponse,createStaticHandler:(e,t,r)=>(0,o.mapResponse)(e,{status:200,headers:r??{}})},composeHandler:{declare(e){if(e.request)return`Object.defineProperty(c,'request',{get(){return nodeRequestToWebstand(c[ElysiaNodeContext].req)}})
`},mapResponseContext:"c[ElysiaNodeContext].res",headers:`c.headers=c[ElysiaNodeContext].req.headers

@@ -3,0 +3,0 @@ `,inject:{ElysiaNodeContext:a,nodeRequestToWebstand:c},parser:{declare:`const req=c[ElysiaNodeContext].req

@@ -1,1 +0,1 @@

"use strict";var S=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(e,a)=>{for(var n in a)S(e,n,{get:a[n],enumerable:!0})},x=(e,a,n,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of b(a))!g.call(e,t)&&t!==n&&S(e,t,{get:()=>a[t],enumerable:!(s=E(a,t))||s.enumerable});return e};var j=e=>x(S({},"__esModule",{value:!0}),e);var B={};v(B,{createStaticHandler:()=>F,errorToResponse:()=>f,mapCompactResponse:()=>R,mapEarlyResponse:()=>c,mapResponse:()=>o,parseSetCookies:()=>p,serializeCookie:()=>k,streamResponse:()=>h});module.exports=j(B);var w=require("cookie"),i=require("../../utils"),m=require("../../cookies"),y=require("../../error");const l=(e,a)=>{const n=e.size;if(!a&&n||n&&a&&a.status!==206&&a.status!==304&&a.status!==412&&a.status!==416){if(a&&(0,i.isNotEmpty)(a.headers)){if(a.headers instanceof Headers)if(i.hasHeaderShorthand)a.headers=a.headers.toJSON();else for(const[s,t]of a.headers.entries())s in a.headers&&(a.headers[s]=t);return new Response(e,{status:a.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`},a.headers)})}return new Response(e,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`,"transfer-encoding":"chunked"}})}return new Response(e)},p=(e,a)=>{if(!e)return e;e.delete("set-cookie");for(let n=0;n<a.length;n++){const s=a[n].indexOf("=");e.append("set-cookie",`${a[n].slice(0,s)}=${a[n].slice(s+1)||""}`)}return e},k=e=>{if(!e||!(0,i.isNotEmpty)(e))return;const a=[];for(const[n,s]of Object.entries(e)){if(!n||!s)continue;const t=s.value;t!=null&&a.push((0,w.serialize)(n,typeof t=="object"?JSON.stringify(t):t+"",s))}if(a.length!==0)return a.length===1?a[0]:a},d=async(e,a,n)=>{let s=e.next();return s instanceof Promise&&(s=await s),s.done?a?o(s.value,a,n):R(s.value,n):new Response(new ReadableStream({async start(t){let r=!1;if(n?.addEventListener("abort",()=>{r=!0;try{t.close()}catch{}}),s.value!==void 0&&s.value!==null)if(typeof s.value=="object")try{t.enqueue(Buffer.from(JSON.stringify(s.value)))}catch{t.enqueue(Buffer.from(s.value.toString()))}else t.enqueue(Buffer.from(s.value.toString()));for await(const u of e){if(r)break;if(u!=null){if(typeof u=="object")try{t.enqueue(Buffer.from(JSON.stringify(u)))}catch{t.enqueue(Buffer.from(u.toString()))}else t.enqueue(Buffer.from(u.toString()));await new Promise(C=>setTimeout(()=>C(),0))}}try{t.close()}catch{}}}),{...a,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...a?.headers}})};async function*h(e){const a=e.body;if(!a)return;const n=a.getReader(),s=new TextDecoder;try{for(;;){const{done:t,value:r}=await n.read();if(t)break;yield s.decode(r)}}finally{n.releaseLock()}}const o=(e,a,n)=>{if((0,i.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=i.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,i.isNotEmpty)(a.cookie)){const s=k(a.cookie);s&&(a.headers["set-cookie"]=s)}switch(a.headers["set-cookie"]&&Array.isArray(a.headers["set-cookie"])&&(a.headers=p(new Headers(a.headers),a.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,a);case"Blob":return l(e,a);case"Array":return Response.json(e,a);case"Object":return Response.json(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,o(e.response,a,n);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream; charset=utf-8"),n?.addEventListener("abort",{handleEvent(){n.aborted||e.cancel()}},{once:!0}),new Response(e,a);case void 0:return e?Response.json(e,a):new Response("",a);case"Response":let s=!1;if(a.headers instanceof Headers)for(const t of a.headers.keys())if(t==="set-cookie"){if(s)continue;s=!0;for(const r of a.headers.getSetCookie())e.headers.append("set-cookie",r)}else e.headers.append(t,a.headers?.get(t)??"");else for(const t in a.headers)e.headers.append(t,a.headers[t]);return e.status!==a.status&&(a.status=e.status),e.headers.get("transfer-encoding")==="chunked"?d(h(e),a,n):e;case"Error":return f(e,a);case"Promise":return e.then(t=>o(t,a));case"Function":return o(e(),a);case"Number":case"Boolean":return new Response(e.toString(),a);case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e,a);default:if(e instanceof Response){let t=!1;if(a.headers instanceof Headers)for(const r of a.headers.keys())if(r==="set-cookie"){if(t)continue;t=!0;for(const u of a.headers.getSetCookie())e.headers.append("set-cookie",u)}else e.headers.append(r,a.headers?.get(r)??"");else for(const r in a.headers)e.headers.append(r,a.headers[r]);if(i.hasHeaderShorthand)a.headers=e.headers.toJSON();else for(const[r,u]of e.headers.entries())r in a.headers&&(a.headers[r]=u);return e}if(e instanceof Promise)return e.then(t=>o(t,a));if(e instanceof Error)return f(e,a);if(e instanceof y.ElysiaCustomStatusResponse)return a.status=e.code,o(e.response,a,n);if(typeof e?.next=="function")return d(e,a,n);if("toResponse"in e)return o(e.toResponse(),a);if("charCodeAt"in e){const t=e.charCodeAt(0);if(t===123||t===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e,a)}}else switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return l(e,a);case"Array":return Response.json(e);case"Object":return Response.json(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,o(e.response,a,n);case"ReadableStream":return n?.addEventListener("abort",{handleEvent(){n?.aborted||e.cancel()}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?d(h(e),a,n):e;case"Error":return f(e,a);case"Promise":return e.then(s=>{const t=R(s,n);return t!==void 0?t:new Response("")});case"Function":return R(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e,a);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(s=>o(s,a));if(e instanceof Error)return f(e,a);if(e instanceof y.ElysiaCustomStatusResponse)return a.status=e.code,o(e.response,a,n);if(typeof e?.next=="function")return d(e,a,n);if("toResponse"in e)return o(e.toResponse(),a);if("charCodeAt"in e){const s=e.charCodeAt(0);if(s===123||s===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e)}},c=(e,a,n)=>{if(e!=null)if((0,i.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=i.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,i.isNotEmpty)(a.cookie)){const s=k(a.cookie);s&&(a.headers["set-cookie"]=s)}switch(a.headers["set-cookie"]&&Array.isArray(a.headers["set-cookie"])&&(a.headers=p(new Headers(a.headers),a.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,a);case"Blob":return l(e,a);case"Array":return Response.json(e,a);case"Object":return Response.json(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,c(e.response,a,n);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream; charset=utf-8"),n?.addEventListener("abort",{handleEvent(){n?.aborted||e.cancel()}},{once:!0}),new Response(e,a);case void 0:return e?Response.json(e,a):void 0;case"Response":let s=!1;if(a.headers instanceof Headers)for(const t of a.headers.keys())if(t==="set-cookie"){if(s)continue;s=!0;for(const r of a.headers.getSetCookie())e.headers.append("set-cookie",r)}else e.headers.append(t,a.headers?.get(t)??"");else for(const t in a.headers)e.headers.append(t,a.headers[t]);return e.status!==a.status&&(a.status=e.status),e.headers.get("transfer-encoding")==="chunked"?d(h(e),a,n):e;case"Promise":return e.then(t=>{const r=c(t,a);if(r!==void 0)return r});case"Error":return f(e,a);case"Function":return c(e(),a);case"Number":case"Boolean":return new Response(e.toString(),a);case"FormData":return new Response(e);case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);default:if(e instanceof Response){let t=!1;if(a.headers instanceof Headers)for(const r of a.headers.keys())if(r==="set-cookie"){if(t)continue;t=!0;for(const u of a.headers.getSetCookie())e.headers.append("set-cookie",u)}else e.headers.append(r,a.headers?.get(r)??"");else for(const r in a.headers)e.headers.append(r,a.headers[r]);return e.status!==a.status&&(a.status=e.status),e}if(e instanceof Promise)return e.then(t=>c(t,a));if(e instanceof Error)return f(e,a);if(e instanceof y.ElysiaCustomStatusResponse)return a.status=e.code,c(e.response,a,n);if(typeof e?.next=="function")return d(e,a,n);if("toResponse"in e)return c(e.toResponse(),a);if("charCodeAt"in e){const t=e.charCodeAt(0);if(t===123||t===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e,a)}}else switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return l(e,a);case"Array":return Response.json(e);case"Object":return Response.json(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,c(e.response,a,n);case"ReadableStream":return n?.addEventListener("abort",{handleEvent(){n?.aborted||e.cancel()}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?d(h(e)):e;case"Promise":return e.then(s=>{const t=c(s,a);if(t!==void 0)return t});case"Error":return f(e,a);case"Function":return R(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(s=>c(s,a));if(e instanceof Error)return f(e,a);if(e instanceof y.ElysiaCustomStatusResponse)return a.status=e.code,c(e.response,a,n);if(typeof e?.next=="function")return d(e,a,n);if("toResponse"in e)return c(e.toResponse(),a);if("charCodeAt"in e){const s=e.charCodeAt(0);if(s===123||s===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e)}},R=(e,a)=>{switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return l(e);case"Array":return Response.json(e);case"Object":return Response.json(e);case"ElysiaCustomStatusResponse":return o(e.response,{status:e.code,headers:{}});case"ReadableStream":return a?.addEventListener("abort",{handleEvent(){a?.aborted||e.cancel()}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?d(h(e)):e;case"Error":return f(e);case"Promise":return e.then(n=>R(n,a));case"Function":return R(e(),a);case"Number":case"Boolean":return new Response(e.toString());case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(n=>R(n,a));if(e instanceof Error)return f(e);if(e instanceof y.ElysiaCustomStatusResponse)return o(e.response,{status:e.code,headers:{}});if(typeof e?.next=="function")return d(e,void 0,a);if("toResponse"in e)return R(e.toResponse());if("charCodeAt"in e){const n=e.charCodeAt(0);if(n===123||n===91)return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}})}return new Response(e)}},f=(e,a)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:a?.status!==200?a?.status??500:500,headers:a?.headers}),F=(e,a,n={})=>{if(typeof e=="function")return;const s=o(e,{headers:n});if(a.parse.length===0&&a.transform.length===0&&a.beforeHandle.length===0&&a.afterHandle.length===0)return s.clone.bind(s)};0&&(module.exports={createStaticHandler,errorToResponse,mapCompactResponse,mapEarlyResponse,mapResponse,parseSetCookies,serializeCookie,streamResponse});
"use strict";var S=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(e,a)=>{for(var n in a)S(e,n,{get:a[n],enumerable:!0})},F=(e,a,n,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of b(a))!g.call(e,t)&&t!==n&&S(e,t,{get:()=>a[t],enumerable:!(s=C(a,t))||s.enumerable});return e};var x=e=>F(S({},"__esModule",{value:!0}),e);var j={};v(j,{createStaticHandler:()=>B,errorToResponse:()=>f,mapCompactResponse:()=>y,mapEarlyResponse:()=>c,mapResponse:()=>o,parseSetCookies:()=>p,serializeCookie:()=>k,streamResponse:()=>h});module.exports=x(j);var w=require("cookie"),i=require("../../utils"),m=require("../../cookies"),l=require("../../error");const d=(e,a)=>{const n=e.size;if(!a&&n||n&&a&&a.status!==206&&a.status!==304&&a.status!==412&&a.status!==416){if(a){if(a.headers instanceof Headers){let s={"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`,"transfer-encoding":"chunked"};if(i.hasHeaderShorthand)s=a.headers.toJSON();else{s={};for(const[t,r]of a.headers.entries())t in a.headers&&(s[t]=r)}return new Response(e,{status:a.status,headers:s})}if((0,i.isNotEmpty)(a.headers))return new Response(e,{status:a.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`,"transfer-encoding":"chunked"},a.headers)})}return new Response(e,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`,"transfer-encoding":"chunked"}})}return new Response(e)},p=(e,a)=>{if(!e)return e;e.delete("set-cookie");for(let n=0;n<a.length;n++){const s=a[n].indexOf("=");e.append("set-cookie",`${a[n].slice(0,s)}=${a[n].slice(s+1)||""}`)}return e},k=e=>{if(!e||!(0,i.isNotEmpty)(e))return;const a=[];for(const[n,s]of Object.entries(e)){if(!n||!s)continue;const t=s.value;t!=null&&a.push((0,w.serialize)(n,typeof t=="object"?JSON.stringify(t):t+"",s))}if(a.length!==0)return a.length===1?a[0]:a},R=async(e,a,n)=>{let s=e.next();return s instanceof Promise&&(s=await s),s.done?a?o(s.value,a,n):y(s.value,n):new Response(new ReadableStream({async start(t){let r=!1;if(n?.addEventListener("abort",()=>{r=!0;try{t.close()}catch{}}),s.value!==void 0&&s.value!==null)if(typeof s.value=="object")try{t.enqueue(Buffer.from(JSON.stringify(s.value)))}catch{t.enqueue(Buffer.from(s.value.toString()))}else t.enqueue(Buffer.from(s.value.toString()));for await(const u of e){if(r)break;if(u!=null){if(typeof u=="object")try{t.enqueue(Buffer.from(JSON.stringify(u)))}catch{t.enqueue(Buffer.from(u.toString()))}else t.enqueue(Buffer.from(u.toString()));await new Promise(E=>setTimeout(()=>E(),0))}}try{t.close()}catch{}}}),{...a,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...a?.headers}})};async function*h(e){const a=e.body;if(!a)return;const n=a.getReader(),s=new TextDecoder;try{for(;;){const{done:t,value:r}=await n.read();if(t)break;yield s.decode(r)}}finally{n.releaseLock()}}const o=(e,a,n)=>{if((0,i.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=i.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,i.isNotEmpty)(a.cookie)){const s=k(a.cookie);s&&(a.headers["set-cookie"]=s)}switch(a.headers["set-cookie"]&&Array.isArray(a.headers["set-cookie"])&&(a.headers=p(new Headers(a.headers),a.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,a);case"Array":case"Object":return Response.json(e,a);case"ElysiaFile":return d(e.value);case"Blob":return d(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,o(e.response,a,n);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream; charset=utf-8"),n?.addEventListener("abort",{handleEvent(){n.aborted||e.cancel()}},{once:!0}),new Response(e,a);case void 0:return e?Response.json(e,a):new Response("",a);case"Response":let s=!1;if(a.headers instanceof Headers)for(const t of a.headers.keys())if(t==="set-cookie"){if(s)continue;s=!0;for(const r of a.headers.getSetCookie())e.headers.append("set-cookie",r)}else e.headers.append(t,a.headers?.get(t)??"");else for(const t in a.headers)e.headers.append(t,a.headers[t]);return e.status!==a.status&&(a.status=e.status),e.headers.get("transfer-encoding")==="chunked"?R(h(e),a,n):e;case"Error":return f(e,a);case"Promise":return e.then(t=>o(t,a));case"Function":return o(e(),a);case"Number":case"Boolean":return new Response(e.toString(),a);case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e,a);default:if(e instanceof Response){let t=!1;if(a.headers instanceof Headers)for(const r of a.headers.keys())if(r==="set-cookie"){if(t)continue;t=!0;for(const u of a.headers.getSetCookie())e.headers.append("set-cookie",u)}else e.headers.append(r,a.headers?.get(r)??"");else for(const r in a.headers)e.headers.append(r,a.headers[r]);if(i.hasHeaderShorthand)a.headers=e.headers.toJSON();else for(const[r,u]of e.headers.entries())r in a.headers&&(a.headers[r]=u);return e}if(e instanceof Promise)return e.then(t=>o(t,a));if(e instanceof Error)return f(e,a);if(e instanceof l.ElysiaCustomStatusResponse)return a.status=e.code,o(e.response,a,n);if(typeof e?.next=="function")return R(e,a,n);if("toResponse"in e)return o(e.toResponse(),a);if("charCodeAt"in e){const t=e.charCodeAt(0);if(t===123||t===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e,a)}}else switch(e?.constructor?.name){case"String":return new Response(e);case"Array":case"Object":return Response.json(e,a);case"ElysiaFile":return d(e.value);case"Blob":return d(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,o(e.response,a,n);case"ReadableStream":return n?.addEventListener("abort",{handleEvent(){n?.aborted||e.cancel()}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?R(h(e),a,n):e;case"Error":return f(e,a);case"Promise":return e.then(s=>{const t=y(s,n);return t!==void 0?t:new Response("")});case"Function":return y(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e,a);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(s=>o(s,a));if(e instanceof Error)return f(e,a);if(e instanceof l.ElysiaCustomStatusResponse)return a.status=e.code,o(e.response,a,n);if(typeof e?.next=="function")return R(e,a,n);if("toResponse"in e)return o(e.toResponse(),a);if("charCodeAt"in e){const s=e.charCodeAt(0);if(s===123||s===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e)}},c=(e,a,n)=>{if(e!=null)if((0,i.isNotEmpty)(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=i.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&(0,i.isNotEmpty)(a.cookie)){const s=k(a.cookie);s&&(a.headers["set-cookie"]=s)}switch(a.headers["set-cookie"]&&Array.isArray(a.headers["set-cookie"])&&(a.headers=p(new Headers(a.headers),a.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,a);case"Array":case"Object":return Response.json(e,a);case"ElysiaFile":return d(e.value);case"Blob":return d(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,c(e.response,a,n);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream; charset=utf-8"),n?.addEventListener("abort",{handleEvent(){n?.aborted||e.cancel()}},{once:!0}),new Response(e,a);case void 0:return e?Response.json(e,a):void 0;case"Response":let s=!1;if(a.headers instanceof Headers)for(const t of a.headers.keys())if(t==="set-cookie"){if(s)continue;s=!0;for(const r of a.headers.getSetCookie())e.headers.append("set-cookie",r)}else e.headers.append(t,a.headers?.get(t)??"");else for(const t in a.headers)e.headers.append(t,a.headers[t]);return e.status!==a.status&&(a.status=e.status),e.headers.get("transfer-encoding")==="chunked"?R(h(e),a,n):e;case"Promise":return e.then(t=>{const r=c(t,a);if(r!==void 0)return r});case"Error":return f(e,a);case"Function":return c(e(),a);case"Number":case"Boolean":return new Response(e.toString(),a);case"FormData":return new Response(e);case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);default:if(e instanceof Response){let t=!1;if(a.headers instanceof Headers)for(const r of a.headers.keys())if(r==="set-cookie"){if(t)continue;t=!0;for(const u of a.headers.getSetCookie())e.headers.append("set-cookie",u)}else e.headers.append(r,a.headers?.get(r)??"");else for(const r in a.headers)e.headers.append(r,a.headers[r]);return e.status!==a.status&&(a.status=e.status),e}if(e instanceof Promise)return e.then(t=>c(t,a));if(e instanceof Error)return f(e,a);if(e instanceof l.ElysiaCustomStatusResponse)return a.status=e.code,c(e.response,a,n);if(typeof e?.next=="function")return R(e,a,n);if("toResponse"in e)return c(e.toResponse(),a);if("charCodeAt"in e){const t=e.charCodeAt(0);if(t===123||t===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e,a)}}else switch(e?.constructor?.name){case"String":return new Response(e);case"Array":case"Object":return Response.json(e,a);case"ElysiaFile":return d(e.value);case"Blob":return d(e,a);case"ElysiaCustomStatusResponse":return a.status=e.code,c(e.response,a,n);case"ReadableStream":return n?.addEventListener("abort",{handleEvent(){n?.aborted||e.cancel()}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?R(h(e)):e;case"Promise":return e.then(s=>{const t=c(s,a);if(t!==void 0)return t});case"Error":return f(e,a);case"Function":return y(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof m.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(s=>c(s,a));if(e instanceof Error)return f(e,a);if(e instanceof l.ElysiaCustomStatusResponse)return a.status=e.code,c(e.response,a,n);if(typeof e?.next=="function")return R(e,a,n);if("toResponse"in e)return c(e.toResponse(),a);if("charCodeAt"in e){const s=e.charCodeAt(0);if(s===123||s===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e)}},y=(e,a)=>{switch(e?.constructor?.name){case"String":return new Response(e);case"Object":case"Array":return Response.json(e);case"ElysiaFile":return d(e.value);case"Blob":return d(e);case"ElysiaCustomStatusResponse":return o(e.response,{status:e.code,headers:{}});case"ReadableStream":return a?.addEventListener("abort",{handleEvent(){a?.aborted||e.cancel()}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?R(h(e)):e;case"Error":return f(e);case"Promise":return e.then(n=>y(n,a));case"Function":return y(e(),a);case"Number":case"Boolean":return new Response(e.toString());case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(n=>y(n,a));if(e instanceof Error)return f(e);if(e instanceof l.ElysiaCustomStatusResponse)return o(e.response,{status:e.code,headers:{}});if(typeof e?.next=="function")return R(e,void 0,a);if("toResponse"in e)return y(e.toResponse());if("charCodeAt"in e){const n=e.charCodeAt(0);if(n===123||n===91)return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}})}return new Response(e)}},f=(e,a)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:a?.status!==200?a?.status??500:500,headers:a?.headers}),B=(e,a,n={})=>{if(typeof e=="function")return;const s=o(e,{headers:n});if(a.parse.length===0&&a.transform.length===0&&a.beforeHandle.length===0&&a.afterHandle.length===0)return s.clone.bind(s)};0&&(module.exports={createStaticHandler,errorToResponse,mapCompactResponse,mapEarlyResponse,mapResponse,parseSetCookies,serializeCookie,streamResponse});

@@ -1,4 +0,4 @@

"use strict";var N=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Y=(P,e)=>{for(var a in e)N(P,a,{get:e[a],enumerable:!0})},X=(P,e,a,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of K(e))!Q.call(P,r)&&r!==a&&N(P,r,{get:()=>e[r],enumerable:!(t=G(e,r))||t.enumerable});return P};var Z=P=>X(N({},"__esModule",{value:!0}),P);var ee={};Y(ee,{Cookie:()=>U.Cookie,ELYSIA_FORM_DATA:()=>y.ELYSIA_FORM_DATA,ELYSIA_REQUEST_ID:()=>y.ELYSIA_REQUEST_ID,ELYSIA_TRACE:()=>j.ELYSIA_TRACE,ERROR_CODE:()=>v.ERROR_CODE,Elysia:()=>u,InternalServerError:()=>v.InternalServerError,InvalidCookieSignature:()=>v.InvalidCookieSignature,InvertedStatusMap:()=>y.InvertedStatusMap,NotFoundError:()=>v.NotFoundError,ParseError:()=>v.ParseError,StatusMap:()=>y.StatusMap,TypeSystemPolicy:()=>z.TypeSystemPolicy,ValidationError:()=>v.ValidationError,checksum:()=>y.checksum,cloneInference:()=>y.cloneInference,deduplicateChecksum:()=>y.deduplicateChecksum,default:()=>u,error:()=>v.error,form:()=>y.form,getResponseSchemaValidator:()=>y.getResponseSchemaValidator,getSchemaValidator:()=>y.getSchemaValidator,mapValueError:()=>v.mapValueError,mergeHook:()=>y.mergeHook,mergeObjectArray:()=>y.mergeObjectArray,redirect:()=>y.redirect,replaceSchemaType:()=>y.replaceSchemaType,replaceUrlPath:()=>y.replaceUrlPath,t:()=>O.t});module.exports=Z(ee);var B=require("memoirist"),q=require("./sucrose"),T=require("./ws/index"),_=require("./adapter/bun/index"),W=require("./adapter/web-standard/index"),n=require("./utils"),M=require("./compose"),J=require("./trace"),i=require("./utils"),C=require("./dynamic-handle"),R=require("./error"),O=require("./type-system"),U=require("./cookies"),j=require("./trace"),y=require("./utils"),v=require("./error"),z=require("@sinclair/typebox/system");class u{constructor(e={}){this.server=null;this.dependencies={};this._routes={};this._types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};this._ephemeral={};this._volatile={};this.singleton={decorator:{},store:{},derive:{},resolve:{}};this.definitions={type:{},error:{}};this.extender={macros:[],higherOrderFunctions:[]};this.validator={global:null,scoped:null,local:null,getCandidate(){return(0,n.mergeSchemaValidator)((0,n.mergeSchemaValidator)(this.global,this.scoped),this.local)}};this.event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]};this.telemetry={stack:void 0};this.router={http:new B.Memoirist,ws:new B.Memoirist,dynamic:new B.Memoirist,static:{http:{static:{},map:{},all:""},ws:{}},history:[]};this.routeTree=new Map;this.inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};this.handle=async e=>this.fetch(e);this.fetch=e=>(this.fetch=this.config.aot?(0,M.composeGeneralHandler)(this):(0,C.createDynamicHandler)(this))(e);this.handleError=async(e,a)=>(this.handleError=this.config.aot?(0,M.composeErrorHandler)(this):(0,C.createDynamicErrorHandler)(this))(e,a);this.outerErrorHandler=e=>new Response(e.message||e.name||"Error",{status:e?.status??500});this.listen=(e,a)=>(this["~adapter"].listen(this)(e,a),this);this.stop=async e=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server&&(this.server.stop(e),this.server=null,this.event.stop.length))for(let a=0;a<this.event.stop.length;a++)this.event.stop[a].fn(this)};e.tags&&(e.detail?e.detail.tags=e.tags:e.detail={tags:e.tags}),e.nativeStaticResponse===void 0&&(e.nativeStaticResponse=!0),this.config={},this.applyConfig(e??{}),this["~adapter"]=e.adapter??(typeof Bun<"u"?_.BunAdapter:W.WebStandardAdapter),e?.analytic&&(e?.name||e?.seed!==void 0)&&(this.telemetry.stack=new Error().stack)}get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}getServer(){return this.server}get promisedModules(){return this._promisedModules||(this._promisedModules=new n.PromiseGroup),this._promisedModules}env(e,a=Bun?.env??process.env){if((0,i.getSchemaValidator)(e,{dynamic:!0,additionalProperties:!0,coerce:!0}).Check(a)===!1){const r=new R.ValidationError("env",e,a);throw new Error(r.all.map(s=>s.summary).join(`
`))}return this}wrap(e){return this.extender.higherOrderFunctions.push({checksum:(0,i.checksum)(JSON.stringify({name:this.config.name,seed:this.config.seed,content:e.toString()})),fn:e}),this}applyMacro(e){if(this.extender.macros.length){const a=(0,i.createMacroManager)({globalHook:this.event,localHook:e}),t={events:{global:this.event,local:e},get onParse(){return a("parse")},get onTransform(){return a("transform")},get onBeforeHandle(){return a("beforeHandle")},get onAfterHandle(){return a("afterHandle")},get mapResponse(){return a("mapResponse")},get onAfterResponse(){return a("afterResponse")},get onError(){return a("error")}};for(const r of this.extender.macros)(0,i.traceBackMacro)(r.fn(t),e,a)}}applyConfig(e){return this.config={prefix:"",aot:process.env.ELYSIA_AOT!=="false",normalize:!0,...e,cookie:{path:"/",...e?.cookie},experimental:e?.experimental??{},seed:e?.seed===void 0?"":e?.seed},this}get models(){const e={};for(const[a,t]of Object.entries(this.definitions.type))e[a]=(0,i.getSchemaValidator)(t);return e}add(e,a,t,r,{allowMeta:s=!1,skipPrefix:o=!1}={allowMeta:!1,skipPrefix:!1}){if(r=(0,n.localHookToLifeCycleStore)(r),a!==""&&a.charCodeAt(0)!==47&&(a="/"+a),this.config.prefix&&!o&&(a=this.config.prefix+a),r?.type)switch(r.type){case"text":r.type="text/plain";break;case"json":r.type="application/json";break;case"formdata":r.type="multipart/form-data";break;case"urlencoded":r.type="application/x-www-form-urlencoded";break;case"arrayBuffer":r.type="application/octet-stream";break;default:break}const d=this.definitions.type,l=!this.config.aot,h={...this.validator.getCandidate()},c={body:r?.body??h?.body,headers:r?.headers??h?.headers,params:r?.params??h?.params,query:r?.query??h?.query,cookie:r?.cookie??h?.cookie,response:r?.response??h?.response},m=()=>c.cookie?(0,i.getCookieValidator)({validator:c.cookie,defaultConfig:this.config.cookie,config:c.cookie?.config??{},dynamic:l,models:d}):void 0,f=this.config.normalize,A=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.schema===!0?{body:(0,i.getSchemaValidator)(c.body,{dynamic:l,models:d,normalize:f,additionalCoerce:(0,n.coercePrimitiveRoot)()}),headers:(0,i.getSchemaValidator)(c.headers,{dynamic:l,models:d,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()}),params:(0,i.getSchemaValidator)(c.params,{dynamic:l,models:d,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()}),query:(0,i.getSchemaValidator)(c.query,{dynamic:l,models:d,normalize:f,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()}),cookie:m(),response:(0,i.getResponseSchemaValidator)(c.response,{dynamic:l,models:d,normalize:f})}:{createBody(){return this.body?this.body:this.body=(0,i.getSchemaValidator)(c.body,{dynamic:l,models:d,normalize:f,additionalCoerce:(0,n.coercePrimitiveRoot)()})},createHeaders(){return this.headers?this.headers:this.headers=(0,i.getSchemaValidator)(c.headers,{dynamic:l,models:d,additionalProperties:!f,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()})},createParams(){return this.params?this.params:this.params=(0,i.getSchemaValidator)(c.params,{dynamic:l,models:d,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()})},createQuery(){return this.query?this.query:this.query=(0,i.getSchemaValidator)(c.query,{dynamic:l,models:d,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()})},createCookie(){return this.cookie?this.cookie:this.cookie=m()},createResponse(){return this.response?this.response:this.response=(0,i.getResponseSchemaValidator)(c.response,{dynamic:l,models:d,normalize:f})}};r=(0,i.mergeHook)(r,h),r.tags&&(r.detail?r.detail.tags=r.tags:r.detail={tags:r.tags}),(0,n.isNotEmpty)(this.config.detail)&&(r.detail=(0,n.mergeDeep)(Object.assign({},this.config.detail),r.detail)),this.applyMacro(r);const g=(0,i.mergeHook)(this.event,r);if(this.config.aot===!1){this.router.dynamic.add(e,a,{validator:A,hooks:g,content:r?.type,handle:t}),this.config.strictPath===!1&&this.router.dynamic.add(e,(0,n.getLoosePath)(a),{validator:A,hooks:g,content:r?.type,handle:t}),this.router.history.push({method:e,path:a,composed:null,handler:t,hooks:g,compile:t});return}const S=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.compose===!0,x=(0,n.cloneInference)(this.inference),E=this["~adapter"].handler,k=typeof t!="function"?E.createStaticHandler(t,g,this.setHeaders):void 0,D=typeof t!="function"?E.createNativeStaticHandler?.(t,g,this.setHeaders):void 0;this.config.nativeStaticResponse===!0&&D&&(e==="GET"||e==="ALL")&&(this.router.static.http.static[a]=D());const w=(p=!1)=>(0,M.composeHandler)({app:this,path:a,method:e,localHook:(0,i.mergeHook)(r),hooks:g,validator:A,handler:t,allowMeta:s,inference:x,asManifest:p});if(this.routeTree.has(e+a))for(let p=0;p<this.router.history.length;p++){const I=this.router.history[p];if(I.path===a&&I.method===e){const b=this.router.history.splice(p,1)[0];b&&this.routeTree.has(b?.method+b?.path)&&this.routeTree.delete(b.method+b.path)}}else this.routeTree.set(e+a,this.router.history.length);const $=this.router.history,H=this.router.history.length,F=S?w():p=>($[H].composed=w())(p);this.router.history.push({method:e,path:a,composed:F,handler:t,hooks:g,compile:()=>w()});const V=this.router.static.http,L={handler:S?F:void 0,compile:w};if(e==="$INTERNALWS"){const p=(0,n.getLoosePath)(a);a.indexOf(":")===-1&&a.indexOf("*")===-1?this.router.static.ws[a]=H:(this.router.ws.add("ws",a,L),p&&this.router.ws.add("ws",p,L));return}if(a.indexOf(":")===-1&&a.indexOf("*")===-1){V.map[a]||(V.map[a]={code:""});const p=k?"":"c";e==="ALL"?V.map[a].all=`default:return ht[${H}].composed(${p})
"use strict";var N=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var X=(P,e)=>{for(var a in e)N(P,a,{get:e[a],enumerable:!0})},Z=(P,e,a,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Q(e))!Y.call(P,r)&&r!==a&&N(P,r,{get:()=>e[r],enumerable:!(t=K(e,r))||t.enumerable});return P};var ee=P=>Z(N({},"__esModule",{value:!0}),P);var ae={};X(ae,{Cookie:()=>U.Cookie,ELYSIA_FORM_DATA:()=>y.ELYSIA_FORM_DATA,ELYSIA_REQUEST_ID:()=>y.ELYSIA_REQUEST_ID,ELYSIA_TRACE:()=>j.ELYSIA_TRACE,ERROR_CODE:()=>v.ERROR_CODE,Elysia:()=>u,InternalServerError:()=>v.InternalServerError,InvalidCookieSignature:()=>v.InvalidCookieSignature,InvertedStatusMap:()=>y.InvertedStatusMap,NotFoundError:()=>v.NotFoundError,ParseError:()=>v.ParseError,StatusMap:()=>y.StatusMap,TypeSystemPolicy:()=>$.TypeSystemPolicy,ValidationError:()=>v.ValidationError,checksum:()=>y.checksum,cloneInference:()=>y.cloneInference,deduplicateChecksum:()=>y.deduplicateChecksum,default:()=>u,error:()=>v.error,file:()=>z.file,form:()=>y.form,getResponseSchemaValidator:()=>y.getResponseSchemaValidator,getSchemaValidator:()=>y.getSchemaValidator,mapValueError:()=>v.mapValueError,mergeHook:()=>y.mergeHook,mergeObjectArray:()=>y.mergeObjectArray,redirect:()=>y.redirect,replaceSchemaType:()=>y.replaceSchemaType,replaceUrlPath:()=>y.replaceUrlPath,t:()=>O.t});module.exports=ee(ae);var B=require("memoirist"),q=require("./sucrose"),T=require("./ws/index"),_=require("./adapter/bun/index"),W=require("./adapter/web-standard/index"),n=require("./utils"),M=require("./compose"),J=require("./trace"),i=require("./utils"),C=require("./dynamic-handle"),R=require("./error"),O=require("./type-system"),U=require("./cookies"),j=require("./trace"),y=require("./utils"),v=require("./error"),z=require("./universal/file"),$=require("@sinclair/typebox/system");class u{constructor(e={}){this.server=null;this.dependencies={};this._routes={};this._types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};this._ephemeral={};this._volatile={};this.singleton={decorator:{},store:{},derive:{},resolve:{}};this.definitions={type:{},error:{}};this.extender={macros:[],higherOrderFunctions:[]};this.validator={global:null,scoped:null,local:null,getCandidate(){return(0,n.mergeSchemaValidator)((0,n.mergeSchemaValidator)(this.global,this.scoped),this.local)}};this.event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]};this.telemetry={stack:void 0};this.router={http:new B.Memoirist,ws:new B.Memoirist,dynamic:new B.Memoirist,static:{http:{static:{},map:{},all:""},ws:{}},history:[]};this.routeTree=new Map;this.inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};this.handle=async e=>this.fetch(e);this.fetch=e=>(this.fetch=this.config.aot?(0,M.composeGeneralHandler)(this):(0,C.createDynamicHandler)(this))(e);this.handleError=async(e,a)=>(this.handleError=this.config.aot?(0,M.composeErrorHandler)(this):(0,C.createDynamicErrorHandler)(this))(e,a);this.outerErrorHandler=e=>new Response(e.message||e.name||"Error",{status:e?.status??500});this.listen=(e,a)=>(this["~adapter"].listen(this)(e,a),this);this.stop=async e=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server&&(this.server.stop(e),this.server=null,this.event.stop.length))for(let a=0;a<this.event.stop.length;a++)this.event.stop[a].fn(this)};e.tags&&(e.detail?e.detail.tags=e.tags:e.detail={tags:e.tags}),e.nativeStaticResponse===void 0&&(e.nativeStaticResponse=!0),this.config={},this.applyConfig(e??{}),this["~adapter"]=e.adapter??(typeof Bun<"u"?_.BunAdapter:W.WebStandardAdapter),e?.analytic&&(e?.name||e?.seed!==void 0)&&(this.telemetry.stack=new Error().stack)}get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}getServer(){return this.server}get promisedModules(){return this._promisedModules||(this._promisedModules=new n.PromiseGroup),this._promisedModules}env(e,a=Bun?.env??process.env){if((0,i.getSchemaValidator)(e,{dynamic:!0,additionalProperties:!0,coerce:!0}).Check(a)===!1){const r=new R.ValidationError("env",e,a);throw new Error(r.all.map(s=>s.summary).join(`
`))}return this}wrap(e){return this.extender.higherOrderFunctions.push({checksum:(0,i.checksum)(JSON.stringify({name:this.config.name,seed:this.config.seed,content:e.toString()})),fn:e}),this}applyMacro(e){if(this.extender.macros.length){const a=(0,i.createMacroManager)({globalHook:this.event,localHook:e}),t={events:{global:this.event,local:e},get onParse(){return a("parse")},get onTransform(){return a("transform")},get onBeforeHandle(){return a("beforeHandle")},get onAfterHandle(){return a("afterHandle")},get mapResponse(){return a("mapResponse")},get onAfterResponse(){return a("afterResponse")},get onError(){return a("error")}};for(const r of this.extender.macros)(0,i.traceBackMacro)(r.fn(t),e,a)}}applyConfig(e){return this.config={prefix:"",aot:process.env.ELYSIA_AOT!=="false",normalize:!0,...e,cookie:{path:"/",...e?.cookie},experimental:e?.experimental??{},seed:e?.seed===void 0?"":e?.seed},this}get models(){const e={};for(const[a,t]of Object.entries(this.definitions.type))e[a]=(0,i.getSchemaValidator)(t);return e}add(e,a,t,r,{allowMeta:s=!1,skipPrefix:o=!1}={allowMeta:!1,skipPrefix:!1}){if(r=(0,n.localHookToLifeCycleStore)(r),a!==""&&a.charCodeAt(0)!==47&&(a="/"+a),this.config.prefix&&!o&&(a=this.config.prefix+a),r?.type)switch(r.type){case"text":r.type="text/plain";break;case"json":r.type="application/json";break;case"formdata":r.type="multipart/form-data";break;case"urlencoded":r.type="application/x-www-form-urlencoded";break;case"arrayBuffer":r.type="application/octet-stream";break;default:break}const d=this.definitions.type,l=!this.config.aot,h={...this.validator.getCandidate()},c={body:r?.body??h?.body,headers:r?.headers??h?.headers,params:r?.params??h?.params,query:r?.query??h?.query,cookie:r?.cookie??h?.cookie,response:r?.response??h?.response},m=()=>c.cookie?(0,i.getCookieValidator)({validator:c.cookie,defaultConfig:this.config.cookie,config:c.cookie?.config??{},dynamic:l,models:d}):void 0,f=this.config.normalize,A=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.schema===!0?{body:(0,i.getSchemaValidator)(c.body,{dynamic:l,models:d,normalize:f,additionalCoerce:(0,n.coercePrimitiveRoot)()}),headers:(0,i.getSchemaValidator)(c.headers,{dynamic:l,models:d,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()}),params:(0,i.getSchemaValidator)(c.params,{dynamic:l,models:d,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()}),query:(0,i.getSchemaValidator)(c.query,{dynamic:l,models:d,normalize:f,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()}),cookie:m(),response:(0,i.getResponseSchemaValidator)(c.response,{dynamic:l,models:d,normalize:f})}:{createBody(){return this.body?this.body:this.body=(0,i.getSchemaValidator)(c.body,{dynamic:l,models:d,normalize:f,additionalCoerce:(0,n.coercePrimitiveRoot)()})},createHeaders(){return this.headers?this.headers:this.headers=(0,i.getSchemaValidator)(c.headers,{dynamic:l,models:d,additionalProperties:!f,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()})},createParams(){return this.params?this.params:this.params=(0,i.getSchemaValidator)(c.params,{dynamic:l,models:d,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()})},createQuery(){return this.query?this.query:this.query=(0,i.getSchemaValidator)(c.query,{dynamic:l,models:d,coerce:!0,additionalCoerce:(0,n.stringToStructureCoercions)()})},createCookie(){return this.cookie?this.cookie:this.cookie=m()},createResponse(){return this.response?this.response:this.response=(0,i.getResponseSchemaValidator)(c.response,{dynamic:l,models:d,normalize:f})}};r=(0,i.mergeHook)(r,h),r.tags&&(r.detail?r.detail.tags=r.tags:r.detail={tags:r.tags}),(0,n.isNotEmpty)(this.config.detail)&&(r.detail=(0,n.mergeDeep)(Object.assign({},this.config.detail),r.detail)),this.applyMacro(r);const g=(0,i.mergeHook)(this.event,r);if(this.config.aot===!1){this.router.dynamic.add(e,a,{validator:A,hooks:g,content:r?.type,handle:t}),this.config.strictPath===!1&&this.router.dynamic.add(e,(0,n.getLoosePath)(a),{validator:A,hooks:g,content:r?.type,handle:t}),this.router.history.push({method:e,path:a,composed:null,handler:t,hooks:g,compile:t});return}const S=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.compose===!0,x=(0,n.cloneInference)(this.inference),E=this["~adapter"].handler,k=typeof t!="function"?E.createStaticHandler(t,g,this.setHeaders):void 0,D=typeof t!="function"?E.createNativeStaticHandler?.(t,g,this.setHeaders):void 0;this.config.nativeStaticResponse===!0&&D&&(e==="GET"||e==="ALL")&&(this.router.static.http.static[a]=D());const w=(p=!1)=>(0,M.composeHandler)({app:this,path:a,method:e,localHook:(0,i.mergeHook)(r),hooks:g,validator:A,handler:t,allowMeta:s,inference:x,asManifest:p});if(this.routeTree.has(e+a))for(let p=0;p<this.router.history.length;p++){const I=this.router.history[p];if(I.path===a&&I.method===e){const b=this.router.history.splice(p,1)[0];b&&this.routeTree.has(b?.method+b?.path)&&this.routeTree.delete(b.method+b.path)}}else this.routeTree.set(e+a,this.router.history.length);const G=this.router.history,H=this.router.history.length,F=S?w():p=>(G[H].composed=w())(p);this.router.history.push({method:e,path:a,composed:F,handler:t,hooks:g,compile:()=>w()});const V=this.router.static.http,L={handler:S?F:void 0,compile:w};if(e==="$INTERNALWS"){const p=(0,n.getLoosePath)(a);a.indexOf(":")===-1&&a.indexOf("*")===-1?this.router.static.ws[a]=H:(this.router.ws.add("ws",a,L),p&&this.router.ws.add("ws",p,L));return}if(a.indexOf(":")===-1&&a.indexOf("*")===-1){V.map[a]||(V.map[a]={code:""});const p=k?"":"c";e==="ALL"?V.map[a].all=`default:return ht[${H}].composed(${p})
`:V.map[a].code=`case '${e}':return ht[${H}].composed(${p})
${V.map[a].code}`,!this.config.strictPath&&this.config.nativeStaticResponse===!0&&D&&(e==="GET"||e==="ALL")&&(this.router.static.http.static[(0,n.getLoosePath)(a)]=D())}else if(this.router.http.add(e,a,L),!this.config.strictPath){const p=(0,n.getLoosePath)(a);this.config.nativeStaticResponse===!0&&k&&(e==="GET"||e==="ALL")&&(this.router.static.http.static[p]=k()),this.router.http.add(e,p,L)}}headers(e){return e?(this.setHeaders||(this.setHeaders={}),this.setHeaders=(0,n.mergeDeep)(this.setHeaders,e),this):this}onStart(e){return this.on("start",e),this}onRequest(e){return this.on("request",e),this}onParse(e,a){return a?this.on(e,"parse",a):this.on("parse",e)}onTransform(e,a){return a?this.on(e,"transform",a):this.on("transform",e)}resolve(e,a){a||(a=e,e={as:"local"});const t={subType:"resolve",fn:a};return this.onBeforeHandle(e,t)}mapResolve(e,a){a||(a=e,e={as:"local"});const t={subType:"mapResolve",fn:a};return this.onBeforeHandle(e,t)}onBeforeHandle(e,a){return a?this.on(e,"beforeHandle",a):this.on("beforeHandle",e)}onAfterHandle(e,a){return a?this.on(e,"afterHandle",a):this.on("afterHandle",e)}mapResponse(e,a){return a?this.on(e,"mapResponse",a):this.on("mapResponse",e)}onAfterResponse(e,a){return a?this.on(e,"afterResponse",a):this.on("afterResponse",e)}trace(e,a){a||(a=e,e={as:"local"}),Array.isArray(a)||(a=[a]);for(const t of a)this.on(e,"trace",(0,J.createTracer)(t));return this}error(e,a){switch(typeof e){case"string":return a.prototype[R.ERROR_CODE]=e,this.definitions.error[e]=a,this;case"function":return this.definitions.error=e(this.definitions.error),this}for(const[t,r]of Object.entries(e))r.prototype[R.ERROR_CODE]=t,this.definitions.error[t]=r;return this}onError(e,a){return a?this.on(e,"error",a):this.on("error",e)}onStop(e){return this.on("stop",e),this}on(e,a,t){let r;switch(typeof e){case"string":r=e,t=a;break;case"object":r=a,!Array.isArray(a)&&typeof a=="object"&&(t=a);break}Array.isArray(t)?t=(0,n.fnToContainer)(t):typeof t=="function"?t=[{fn:t}]:t=[t];const s=t;for(const o of s)o.scope=typeof e=="string"?"local":e?.as??"local",(r==="resolve"||r==="derive")&&(o.subType=r);r!=="trace"&&(0,q.sucrose)({[r]:s.map(o=>o.fn)},this.inference);for(const o of s){const d=(0,i.asHookType)(o,"global",{skipIfHasType:!0});switch(r){case"start":this.event.start.push(d);break;case"request":this.event.request.push(d);break;case"parse":this.event.parse.push(d);break;case"transform":this.event.transform.push(d);break;case"derive":this.event.transform.push((0,n.fnToContainer)(d,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(d);break;case"resolve":this.event.beforeHandle.push((0,n.fnToContainer)(d,"resolve"));break;case"afterHandle":this.event.afterHandle.push(d);break;case"mapResponse":this.event.mapResponse.push(d);break;case"afterResponse":this.event.afterResponse.push(d);break;case"trace":this.event.trace.push(d);break;case"error":this.event.error.push(d);break;case"stop":this.event.stop.push(d);break}}return this}propagate(){return(0,n.promoteEvent)(this.event.parse),(0,n.promoteEvent)(this.event.transform),(0,n.promoteEvent)(this.event.beforeHandle),(0,n.promoteEvent)(this.event.afterHandle),(0,n.promoteEvent)(this.event.mapResponse),(0,n.promoteEvent)(this.event.afterResponse),(0,n.promoteEvent)(this.event.trace),(0,n.promoteEvent)(this.event.error),this}as(e){const a={plugin:"scoped",global:"global"}[e];return(0,n.promoteEvent)(this.event.parse,a),(0,n.promoteEvent)(this.event.transform,a),(0,n.promoteEvent)(this.event.beforeHandle,a),(0,n.promoteEvent)(this.event.afterHandle,a),(0,n.promoteEvent)(this.event.mapResponse,a),(0,n.promoteEvent)(this.event.afterResponse,a),(0,n.promoteEvent)(this.event.trace,a),(0,n.promoteEvent)(this.event.error,a),e==="plugin"?(this.validator.scoped=(0,n.mergeSchemaValidator)(this.validator.scoped,this.validator.local),this.validator.local=null):e==="global"&&(this.validator.global=(0,n.mergeSchemaValidator)(this.validator.global,(0,n.mergeSchemaValidator)(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null),this}group(e,a,t){const r=new u({...this.config,prefix:""});r.singleton={...this.singleton},r.definitions={...this.definitions},r.getServer=()=>this.getServer(),r.inference=(0,n.cloneInference)(this.inference),r.extender={...this.extender};const s=typeof a=="object",o=(s?t:a)(r);return this.singleton=(0,n.mergeDeep)(this.singleton,r.singleton),this.definitions=(0,n.mergeDeep)(this.definitions,r.definitions),o.event.request.length&&(this.event.request=[...this.event.request||[],...o.event.request||[]]),o.event.mapResponse.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...o.event.mapResponse||[]]),this.model(o.definitions.type),Object.values(r.router.history).forEach(({method:d,path:l,handler:h,hooks:c})=>{if(l=(s?"":this.config.prefix)+e+l,s){const m=a,f=c;this.add(d,l,h,(0,i.mergeHook)(m,{...f||{},error:f.error?Array.isArray(f.error)?[...f.error||{},...o.event.error||{}]:[f.error,...o.event.error||{}]:o.event.error}))}else this.add(d,l,h,(0,i.mergeHook)(c,{error:o.event.error}),{skipPrefix:!0})}),this}guard(e,a){if(!a){if(typeof e=="object"){this.applyMacro(e);const s=e.as??"local";return this.validator[s]={body:e.body??this.validator[s]?.body,headers:e.headers??this.validator[s]?.headers,params:e.params??this.validator[s]?.params,query:e.query??this.validator[s]?.query,response:e.response??this.validator[s]?.response,cookie:e.cookie??this.validator[s]?.cookie},e.parse&&this.on({as:s},"parse",e.parse),e.transform&&this.on({as:s},"transform",e.transform),e.derive&&this.on({as:s},"derive",e.derive),e.beforeHandle&&this.on({as:s},"beforeHandle",e.beforeHandle),e.resolve&&this.on({as:s},"resolve",e.resolve),e.afterHandle&&this.on({as:s},"afterHandle",e.afterHandle),e.mapResponse&&this.on({as:s},"mapResponse",e.mapResponse),e.afterResponse&&this.on({as:s},"afterResponse",e.afterResponse),e.error&&this.on({as:s},"error",e.error),e.detail&&(this.config.detail?this.config.detail=(0,n.mergeDeep)(Object.assign({},this.config.detail),e.detail):this.config.detail=e.detail),e?.tags&&(this.config.detail?this.config.detail.tags=e.tags:this.config.detail={tags:e.tags}),this}return this.guard({},e)}const t=new u({...this.config,prefix:""});t.singleton={...this.singleton},t.definitions={...this.definitions},t.inference=(0,n.cloneInference)(this.inference),t.extender={...this.extender};const r=a(t);return this.singleton=(0,n.mergeDeep)(this.singleton,t.singleton),this.definitions=(0,n.mergeDeep)(this.definitions,t.definitions),r.getServer=()=>this.server,r.event.request.length&&(this.event.request=[...this.event.request||[],...r.event.request||[]]),r.event.mapResponse.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...r.event.mapResponse||[]]),this.model(r.definitions.type),Object.values(t.router.history).forEach(({method:s,path:o,handler:d,hooks:l})=>{this.add(s,o,d,(0,i.mergeHook)(e,{...l||{},error:l.error?Array.isArray(l.error)?[...l.error||{},...r.event.error||[]]:[l.error,...r.event.error||[]]:r.event.error}))}),this}use(e,a){if(Array.isArray(e)){let t=this;for(const r of e)t=t.use(r);return t}if(a?.scoped)return this.guard({},t=>t.use(e));if(Array.isArray(e)){let t=this;for(const r of e)t=this.use(r);return t}return e instanceof Promise?(this.promisedModules.add(e.then(t=>{if(typeof t=="function")return t(this);if(t instanceof u)return this._use(t).compile();if(typeof t.default=="function")return t.default(this);if(t.default instanceof u)return this._use(t.default);throw new Error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.')}).then(t=>t.compile())),this):this._use(e)}_use(e){if(typeof e=="function"){const s=e(this);return s instanceof Promise?(this.promisedModules.add(s.then(o=>{if(o instanceof u){o.getServer=()=>this.getServer(),o.getGlobalRoutes=()=>this.getGlobalRoutes(),o.model(this.definitions.type),o.error(this.definitions.error);for(const{method:d,path:l,handler:h,hooks:c}of Object.values(o.router.history))this.add(d,l,h,(0,i.mergeHook)(c,{error:o.event.error}));return o.compile(),o}return typeof o=="function"?o(this):typeof o.default=="function"?o.default(this):this._use(o)}).then(o=>o.compile())),this):s}const{name:a,seed:t}=e.config;if(e.getServer=()=>this.getServer(),e.getGlobalRoutes=()=>this.getGlobalRoutes(),e.model(this.definitions.type),e.error(this.definitions.error),this.headers(e.setHeaders),a){a in this.dependencies||(this.dependencies[a]=[]);const s=t!==void 0?(0,i.checksum)(a+JSON.stringify(t)):0;this.dependencies[a].some(({checksum:o})=>s===o)||(this.extender.macros=this.extender.macros.concat(e.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(e.extender.higherOrderFunctions))}else this.extender.macros=this.extender.macros.concat(e.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(e.extender.higherOrderFunctions);(0,n.deduplicateChecksum)(this.extender.macros),(0,n.deduplicateChecksum)(this.extender.higherOrderFunctions);const r=[];for(let s=0;s<this.extender.higherOrderFunctions.length;s++){const o=this.extender.higherOrderFunctions[s];o.checksum&&(r.includes(o.checksum)&&(this.extender.higherOrderFunctions.splice(s,1),s--),r.push(o.checksum))}this.inference={body:this.inference.body||e.inference.body,cookie:this.inference.cookie||e.inference.cookie,headers:this.inference.headers||e.inference.headers,query:this.inference.query||e.inference.query,set:this.inference.set||e.inference.set,server:this.inference.server||e.inference.server,request:this.inference.request||e.inference.request,route:this.inference.route||e.inference.route},this.decorate(e.singleton.decorator),this.state(e.singleton.store),this.model(e.definitions.type),this.error(e.definitions.error),e.extender.macros=this.extender.macros.concat(e.extender.macros);for(const{method:s,path:o,handler:d,hooks:l}of Object.values(e.router.history))this.add(s,o,d,(0,i.mergeHook)(l,{error:e.event.error}));if(a){a in this.dependencies||(this.dependencies[a]=[]);const s=t!==void 0?(0,i.checksum)(a+JSON.stringify(t)):0;if(this.dependencies[a].some(({checksum:o})=>s===o))return this;this.dependencies[a].push(this.config?.analytic?{name:e.config.name,seed:e.config.seed,checksum:s,dependencies:e.dependencies,stack:e.telemetry.stack,routes:e.router.history,decorators:e.singleton,store:e.singleton.store,type:e.definitions.type,error:e.definitions.error,derive:e.event.transform.filter(o=>o?.subType==="derive").map(o=>({fn:o.toString(),stack:new Error().stack??""})),resolve:e.event.transform.filter(o=>o?.subType==="resolve").map(o=>({fn:o.toString(),stack:new Error().stack??""}))}:{name:e.config.name,seed:e.config.seed,checksum:s,dependencies:e.dependencies}),this.event=(0,i.mergeLifeCycle)(this.event,(0,i.filterGlobalHook)(e.event),s)}else this.event=(0,i.mergeLifeCycle)(this.event,(0,i.filterGlobalHook)(e.event));return this.validator.global=(0,i.mergeHook)(this.validator.global,{...e.validator.global}),this.validator.local=(0,i.mergeHook)(this.validator.local,{...e.validator.scoped}),this}macro(e){if(typeof e=="function"){const a={checksum:(0,i.checksum)(JSON.stringify({name:this.config.name,seed:this.config.seed,content:e.toString()})),fn:e};this.extender.macros.push(a)}else if(typeof e=="object"){const a={checksum:(0,i.checksum)(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(e).map(([t,r])=>`${t}+${r}`).join(",")})),fn:()=>e};this.extender.macros.push(a)}return this}mount(e,a){if(e instanceof u||typeof e=="function"||e.length===0||e==="/"){const s=typeof e=="function"?e:e instanceof u?e.compile().fetch:a instanceof u?a.compile().fetch:a,o=async({request:d,path:l})=>d.method==="GET"||d.method==="HEAD"||!d.headers.get("content-type")?s(new Request((0,i.replaceUrlPath)(d.url,l||"/"),d)):s(new Request((0,i.replaceUrlPath)(d.url,l||"/"),{...d,body:await d.arrayBuffer()}));return this.all("/*",o,{type:"none"}),this}const t=e.length;a instanceof u&&(a=a.compile().fetch);const r=async({request:s,path:o})=>s.method==="GET"||s.method==="HEAD"||!s.headers.get("content-type")?a(new Request((0,i.replaceUrlPath)(s.url,o.slice(t)||"/"),s)):a(new Request((0,i.replaceUrlPath)(s.url,o.slice(t)||"/"),{...s,body:await s.arrayBuffer()}));return this.all(e,r,{type:"none"}),this.all(e+(e.endsWith("/")?"*":"/*"),r,{type:"none"}),this}get(e,a,t){return this.add("GET",e,a,t),this}post(e,a,t){return this.add("POST",e,a,t),this}put(e,a,t){return this.add("PUT",e,a,t),this}patch(e,a,t){return this.add("PATCH",e,a,t),this}delete(e,a,t){return this.add("DELETE",e,a,t),this}options(e,a,t){return this.add("OPTIONS",e,a,t),this}all(e,a,t){return this.add("ALL",e,a,t),this}head(e,a,t){return this.add("HEAD",e,a,t),this}connect(e,a,t){return this.add("CONNECT",e,a,t),this}route(e,a,t,r){return this.add(e.toUpperCase(),a,t,r,r?.config),this}ws(e,a){const t=a.transformMessage?Array.isArray(a.transformMessage)?a.transformMessage:[a.transformMessage]:void 0;let r=null;const s=(0,i.getSchemaValidator)(a?.body,{models:this.definitions.type,normalize:this.config.normalize}),o=(0,i.getSchemaValidator)(a?.response,{models:this.definitions.type,normalize:this.config.normalize}),d=l=>{if(typeof l=="string"){const h=l?.charCodeAt(0);if(h===47||h===123)try{l=JSON.parse(l)}catch{}else(0,i.isNumericString)(l)&&(l=+l)}if(t?.length)for(let h=0;h<t.length;h++){const c=t[h](l);c!==void 0&&(l=c)}return l};return this.route("$INTERNALWS",e,l=>{const{set:h,path:c,qi:m,headers:f,query:A,params:g}=l;if(r===null&&(r=this.getServer()),!r?.upgrade(l.request,{headers:typeof a.upgrade=="function"?a.upgrade(l):a.upgrade,data:{validator:o,open(S){a.open?.(new T.ElysiaWS(S,l))},message:(S,x)=>{const E=d(x);if(s?.Check(E)===!1)return void S.send(new R.ValidationError("message",s,E).message);a.message?.(new T.ElysiaWS(S,l),E)},drain(S){a.drain?.(new T.ElysiaWS(S,l))},close(S,x,E){a.close?.(new T.ElysiaWS(S,l),x,E)}}}))return h.status=400,"Expected a websocket connection"},{beforeHandle:a.beforeHandle,transform:a.transform,headers:a.headers,params:a.params,query:a.query}),this}state(e,a,t){a===void 0?(t=e,e={as:"append"},a=""):t===void 0&&(typeof e=="string"?(t=a,a=e,e={as:"append"}):typeof e=="object"&&(t=a,a=""));const{as:r}=e;if(typeof a!="string")return this;switch(typeof t){case"object":return a?(a in this.singleton.store?this.singleton.store[a]=(0,n.mergeDeep)(this.singleton.store[a],t,{override:r==="override"}):this.singleton.store[a]=t,this):t===null?this:(this.singleton.store=(0,n.mergeDeep)(this.singleton.store,t,{override:r==="override"}),this);case"function":return a?(r==="override"||!(a in this.singleton.store))&&(this.singleton.store[a]=t):this.singleton.store=t(this.singleton.store),this;default:return(r==="override"||!(a in this.singleton.store))&&(this.singleton.store[a]=t),this}}decorate(e,a,t){a===void 0?(t=e,e={as:"append"},a=""):t===void 0&&(typeof e=="string"?(t=a,a=e,e={as:"append"}):typeof e=="object"&&(t=a,a=""));const{as:r}=e;if(typeof a!="string")return this;switch(typeof t){case"object":return a?(a in this.singleton.decorator?this.singleton.decorator[a]=(0,n.mergeDeep)(this.singleton.decorator[a],t,{override:r==="override"}):this.singleton.decorator[a]=t,this):t===null?this:(this.singleton.decorator=(0,n.mergeDeep)(this.singleton.decorator,t,{override:r==="override"}),this);case"function":return a?(r==="override"||!(a in this.singleton.decorator))&&(this.singleton.decorator[a]=t):this.singleton.decorator=t(this.singleton.decorator),this;default:return(r==="override"||!(a in this.singleton.decorator))&&(this.singleton.decorator[a]=t),this}}derive(e,a){a||(a=e,e={as:"local"});const t={subType:"derive",fn:a};return this.onTransform(e,t)}model(e,a){switch(typeof e){case"object":return Object.entries(e).forEach(([t,r])=>{t in this.definitions.type||(this.definitions.type[t]=r)}),this;case"function":return this.definitions.type=e(this.definitions.type),this}return this.definitions.type[e]=a,this}mapDerive(e,a){a||(a=e,e={as:"local"});const t={subType:"mapDerive",fn:a};return this.onTransform(e,t)}affix(e,a,t){if(t==="")return this;const r=["_","-"," "],s=h=>h[0].toUpperCase()+h.slice(1),o=e==="prefix"?(h,c)=>r.includes(h.at(-1)??"")?h+c:h+s(c):r.includes(t.at(-1)??"")?(h,c)=>c+h:(h,c)=>c+s(h),d=h=>{const c={};switch(h){case"decorator":for(const m in this.singleton.decorator)c[o(t,m)]=this.singleton.decorator[m];this.singleton.decorator=c;break;case"state":for(const m in this.singleton.store)c[o(t,m)]=this.singleton.store[m];this.singleton.store=c;break;case"model":for(const m in this.definitions.type)c[o(t,m)]=this.definitions.type[m];this.definitions.type=c;break;case"error":for(const m in this.definitions.error)c[o(t,m)]=this.definitions.error[m];this.definitions.error=c;break}},l=Array.isArray(a)?a:[a];for(const h of l.some(c=>c==="all")?["decorator","state","model","error"]:l)d(h);return this}prefix(e,a){return this.affix("prefix",e,a)}suffix(e,a){return this.affix("suffix",e,a)}compile(){return this["~adapter"].isWebStandard?(this.fetch=this.config.aot?(0,M.composeGeneralHandler)(this):(0,C.createDynamicHandler)(this),typeof this.server?.reload=="function"&&this.server.reload({...this.server||{},fetch:this.fetch}),this):(this._handle=(0,M.composeGeneralHandler)(this),this)}get modules(){return Promise.all(this.promisedModules.promises)}}0&&(module.exports={Cookie,ELYSIA_FORM_DATA,ELYSIA_REQUEST_ID,ELYSIA_TRACE,ERROR_CODE,Elysia,InternalServerError,InvalidCookieSignature,InvertedStatusMap,NotFoundError,ParseError,StatusMap,TypeSystemPolicy,ValidationError,checksum,cloneInference,deduplicateChecksum,error,form,getResponseSchemaValidator,getSchemaValidator,mapValueError,mergeHook,mergeObjectArray,redirect,replaceSchemaType,replaceUrlPath,t});
${V.map[a].code}`,!this.config.strictPath&&this.config.nativeStaticResponse===!0&&D&&(e==="GET"||e==="ALL")&&(this.router.static.http.static[(0,n.getLoosePath)(a)]=D())}else if(this.router.http.add(e,a,L),!this.config.strictPath){const p=(0,n.getLoosePath)(a);this.config.nativeStaticResponse===!0&&k&&(e==="GET"||e==="ALL")&&(this.router.static.http.static[p]=k()),this.router.http.add(e,p,L)}}headers(e){return e?(this.setHeaders||(this.setHeaders={}),this.setHeaders=(0,n.mergeDeep)(this.setHeaders,e),this):this}onStart(e){return this.on("start",e),this}onRequest(e){return this.on("request",e),this}onParse(e,a){return a?this.on(e,"parse",a):this.on("parse",e)}onTransform(e,a){return a?this.on(e,"transform",a):this.on("transform",e)}resolve(e,a){a||(a=e,e={as:"local"});const t={subType:"resolve",fn:a};return this.onBeforeHandle(e,t)}mapResolve(e,a){a||(a=e,e={as:"local"});const t={subType:"mapResolve",fn:a};return this.onBeforeHandle(e,t)}onBeforeHandle(e,a){return a?this.on(e,"beforeHandle",a):this.on("beforeHandle",e)}onAfterHandle(e,a){return a?this.on(e,"afterHandle",a):this.on("afterHandle",e)}mapResponse(e,a){return a?this.on(e,"mapResponse",a):this.on("mapResponse",e)}onAfterResponse(e,a){return a?this.on(e,"afterResponse",a):this.on("afterResponse",e)}trace(e,a){a||(a=e,e={as:"local"}),Array.isArray(a)||(a=[a]);for(const t of a)this.on(e,"trace",(0,J.createTracer)(t));return this}error(e,a){switch(typeof e){case"string":return a.prototype[R.ERROR_CODE]=e,this.definitions.error[e]=a,this;case"function":return this.definitions.error=e(this.definitions.error),this}for(const[t,r]of Object.entries(e))r.prototype[R.ERROR_CODE]=t,this.definitions.error[t]=r;return this}onError(e,a){return a?this.on(e,"error",a):this.on("error",e)}onStop(e){return this.on("stop",e),this}on(e,a,t){let r;switch(typeof e){case"string":r=e,t=a;break;case"object":r=a,!Array.isArray(a)&&typeof a=="object"&&(t=a);break}Array.isArray(t)?t=(0,n.fnToContainer)(t):typeof t=="function"?t=[{fn:t}]:t=[t];const s=t;for(const o of s)o.scope=typeof e=="string"?"local":e?.as??"local",(r==="resolve"||r==="derive")&&(o.subType=r);r!=="trace"&&(0,q.sucrose)({[r]:s.map(o=>o.fn)},this.inference);for(const o of s){const d=(0,i.asHookType)(o,"global",{skipIfHasType:!0});switch(r){case"start":this.event.start.push(d);break;case"request":this.event.request.push(d);break;case"parse":this.event.parse.push(d);break;case"transform":this.event.transform.push(d);break;case"derive":this.event.transform.push((0,n.fnToContainer)(d,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(d);break;case"resolve":this.event.beforeHandle.push((0,n.fnToContainer)(d,"resolve"));break;case"afterHandle":this.event.afterHandle.push(d);break;case"mapResponse":this.event.mapResponse.push(d);break;case"afterResponse":this.event.afterResponse.push(d);break;case"trace":this.event.trace.push(d);break;case"error":this.event.error.push(d);break;case"stop":this.event.stop.push(d);break}}return this}propagate(){return(0,n.promoteEvent)(this.event.parse),(0,n.promoteEvent)(this.event.transform),(0,n.promoteEvent)(this.event.beforeHandle),(0,n.promoteEvent)(this.event.afterHandle),(0,n.promoteEvent)(this.event.mapResponse),(0,n.promoteEvent)(this.event.afterResponse),(0,n.promoteEvent)(this.event.trace),(0,n.promoteEvent)(this.event.error),this}as(e){const a={plugin:"scoped",global:"global"}[e];return(0,n.promoteEvent)(this.event.parse,a),(0,n.promoteEvent)(this.event.transform,a),(0,n.promoteEvent)(this.event.beforeHandle,a),(0,n.promoteEvent)(this.event.afterHandle,a),(0,n.promoteEvent)(this.event.mapResponse,a),(0,n.promoteEvent)(this.event.afterResponse,a),(0,n.promoteEvent)(this.event.trace,a),(0,n.promoteEvent)(this.event.error,a),e==="plugin"?(this.validator.scoped=(0,n.mergeSchemaValidator)(this.validator.scoped,this.validator.local),this.validator.local=null):e==="global"&&(this.validator.global=(0,n.mergeSchemaValidator)(this.validator.global,(0,n.mergeSchemaValidator)(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null),this}group(e,a,t){const r=new u({...this.config,prefix:""});r.singleton={...this.singleton},r.definitions={...this.definitions},r.getServer=()=>this.getServer(),r.inference=(0,n.cloneInference)(this.inference),r.extender={...this.extender};const s=typeof a=="object",o=(s?t:a)(r);return this.singleton=(0,n.mergeDeep)(this.singleton,r.singleton),this.definitions=(0,n.mergeDeep)(this.definitions,r.definitions),o.event.request.length&&(this.event.request=[...this.event.request||[],...o.event.request||[]]),o.event.mapResponse.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...o.event.mapResponse||[]]),this.model(o.definitions.type),Object.values(r.router.history).forEach(({method:d,path:l,handler:h,hooks:c})=>{if(l=(s?"":this.config.prefix)+e+l,s){const m=a,f=c;this.add(d,l,h,(0,i.mergeHook)(m,{...f||{},error:f.error?Array.isArray(f.error)?[...f.error||{},...o.event.error||{}]:[f.error,...o.event.error||{}]:o.event.error}))}else this.add(d,l,h,(0,i.mergeHook)(c,{error:o.event.error}),{skipPrefix:!0})}),this}guard(e,a){if(!a){if(typeof e=="object"){this.applyMacro(e);const s=e.as??"local";return this.validator[s]={body:e.body??this.validator[s]?.body,headers:e.headers??this.validator[s]?.headers,params:e.params??this.validator[s]?.params,query:e.query??this.validator[s]?.query,response:e.response??this.validator[s]?.response,cookie:e.cookie??this.validator[s]?.cookie},e.parse&&this.on({as:s},"parse",e.parse),e.transform&&this.on({as:s},"transform",e.transform),e.derive&&this.on({as:s},"derive",e.derive),e.beforeHandle&&this.on({as:s},"beforeHandle",e.beforeHandle),e.resolve&&this.on({as:s},"resolve",e.resolve),e.afterHandle&&this.on({as:s},"afterHandle",e.afterHandle),e.mapResponse&&this.on({as:s},"mapResponse",e.mapResponse),e.afterResponse&&this.on({as:s},"afterResponse",e.afterResponse),e.error&&this.on({as:s},"error",e.error),e.detail&&(this.config.detail?this.config.detail=(0,n.mergeDeep)(Object.assign({},this.config.detail),e.detail):this.config.detail=e.detail),e?.tags&&(this.config.detail?this.config.detail.tags=e.tags:this.config.detail={tags:e.tags}),this}return this.guard({},e)}const t=new u({...this.config,prefix:""});t.singleton={...this.singleton},t.definitions={...this.definitions},t.inference=(0,n.cloneInference)(this.inference),t.extender={...this.extender};const r=a(t);return this.singleton=(0,n.mergeDeep)(this.singleton,t.singleton),this.definitions=(0,n.mergeDeep)(this.definitions,t.definitions),r.getServer=()=>this.server,r.event.request.length&&(this.event.request=[...this.event.request||[],...r.event.request||[]]),r.event.mapResponse.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...r.event.mapResponse||[]]),this.model(r.definitions.type),Object.values(t.router.history).forEach(({method:s,path:o,handler:d,hooks:l})=>{this.add(s,o,d,(0,i.mergeHook)(e,{...l||{},error:l.error?Array.isArray(l.error)?[...l.error||{},...r.event.error||[]]:[l.error,...r.event.error||[]]:r.event.error}))}),this}use(e,a){if(Array.isArray(e)){let t=this;for(const r of e)t=t.use(r);return t}if(a?.scoped)return this.guard({},t=>t.use(e));if(Array.isArray(e)){let t=this;for(const r of e)t=this.use(r);return t}return e instanceof Promise?(this.promisedModules.add(e.then(t=>{if(typeof t=="function")return t(this);if(t instanceof u)return this._use(t).compile();if(typeof t.default=="function")return t.default(this);if(t.default instanceof u)return this._use(t.default);throw new Error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.')}).then(t=>t.compile())),this):this._use(e)}_use(e){if(typeof e=="function"){const s=e(this);return s instanceof Promise?(this.promisedModules.add(s.then(o=>{if(o instanceof u){o.getServer=()=>this.getServer(),o.getGlobalRoutes=()=>this.getGlobalRoutes(),o.model(this.definitions.type),o.error(this.definitions.error);for(const{method:d,path:l,handler:h,hooks:c}of Object.values(o.router.history))this.add(d,l,h,(0,i.mergeHook)(c,{error:o.event.error}));return o.compile(),o}return typeof o=="function"?o(this):typeof o.default=="function"?o.default(this):this._use(o)}).then(o=>o.compile())),this):s}const{name:a,seed:t}=e.config;if(e.getServer=()=>this.getServer(),e.getGlobalRoutes=()=>this.getGlobalRoutes(),e.model(this.definitions.type),e.error(this.definitions.error),this.headers(e.setHeaders),a){a in this.dependencies||(this.dependencies[a]=[]);const s=t!==void 0?(0,i.checksum)(a+JSON.stringify(t)):0;this.dependencies[a].some(({checksum:o})=>s===o)||(this.extender.macros=this.extender.macros.concat(e.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(e.extender.higherOrderFunctions))}else this.extender.macros=this.extender.macros.concat(e.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(e.extender.higherOrderFunctions);(0,n.deduplicateChecksum)(this.extender.macros),(0,n.deduplicateChecksum)(this.extender.higherOrderFunctions);const r=[];for(let s=0;s<this.extender.higherOrderFunctions.length;s++){const o=this.extender.higherOrderFunctions[s];o.checksum&&(r.includes(o.checksum)&&(this.extender.higherOrderFunctions.splice(s,1),s--),r.push(o.checksum))}this.inference={body:this.inference.body||e.inference.body,cookie:this.inference.cookie||e.inference.cookie,headers:this.inference.headers||e.inference.headers,query:this.inference.query||e.inference.query,set:this.inference.set||e.inference.set,server:this.inference.server||e.inference.server,request:this.inference.request||e.inference.request,route:this.inference.route||e.inference.route},this.decorate(e.singleton.decorator),this.state(e.singleton.store),this.model(e.definitions.type),this.error(e.definitions.error),e.extender.macros=this.extender.macros.concat(e.extender.macros);for(const{method:s,path:o,handler:d,hooks:l}of Object.values(e.router.history))this.add(s,o,d,(0,i.mergeHook)(l,{error:e.event.error}));if(a){a in this.dependencies||(this.dependencies[a]=[]);const s=t!==void 0?(0,i.checksum)(a+JSON.stringify(t)):0;if(this.dependencies[a].some(({checksum:o})=>s===o))return this;this.dependencies[a].push(this.config?.analytic?{name:e.config.name,seed:e.config.seed,checksum:s,dependencies:e.dependencies,stack:e.telemetry.stack,routes:e.router.history,decorators:e.singleton,store:e.singleton.store,type:e.definitions.type,error:e.definitions.error,derive:e.event.transform.filter(o=>o?.subType==="derive").map(o=>({fn:o.toString(),stack:new Error().stack??""})),resolve:e.event.transform.filter(o=>o?.subType==="resolve").map(o=>({fn:o.toString(),stack:new Error().stack??""}))}:{name:e.config.name,seed:e.config.seed,checksum:s,dependencies:e.dependencies}),this.event=(0,i.mergeLifeCycle)(this.event,(0,i.filterGlobalHook)(e.event),s)}else this.event=(0,i.mergeLifeCycle)(this.event,(0,i.filterGlobalHook)(e.event));return this.validator.global=(0,i.mergeHook)(this.validator.global,{...e.validator.global}),this.validator.local=(0,i.mergeHook)(this.validator.local,{...e.validator.scoped}),this}macro(e){if(typeof e=="function"){const a={checksum:(0,i.checksum)(JSON.stringify({name:this.config.name,seed:this.config.seed,content:e.toString()})),fn:e};this.extender.macros.push(a)}else if(typeof e=="object"){const a={checksum:(0,i.checksum)(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(e).map(([t,r])=>`${t}+${r}`).join(",")})),fn:()=>e};this.extender.macros.push(a)}return this}mount(e,a){if(e instanceof u||typeof e=="function"||e.length===0||e==="/"){const s=typeof e=="function"?e:e instanceof u?e.compile().fetch:a instanceof u?a.compile().fetch:a,o=async({request:d,path:l})=>d.method==="GET"||d.method==="HEAD"||!d.headers.get("content-type")?s(new Request((0,i.replaceUrlPath)(d.url,l||"/"),d)):s(new Request((0,i.replaceUrlPath)(d.url,l||"/"),{...d,body:await d.arrayBuffer()}));return this.all("/*",o,{type:"none"}),this}const t=e.length;a instanceof u&&(a=a.compile().fetch);const r=async({request:s,path:o})=>s.method==="GET"||s.method==="HEAD"||!s.headers.get("content-type")?a(new Request((0,i.replaceUrlPath)(s.url,o.slice(t)||"/"),s)):a(new Request((0,i.replaceUrlPath)(s.url,o.slice(t)||"/"),{...s,body:await s.arrayBuffer()}));return this.all(e,r,{type:"none"}),this.all(e+(e.endsWith("/")?"*":"/*"),r,{type:"none"}),this}get(e,a,t){return this.add("GET",e,a,t),this}post(e,a,t){return this.add("POST",e,a,t),this}put(e,a,t){return this.add("PUT",e,a,t),this}patch(e,a,t){return this.add("PATCH",e,a,t),this}delete(e,a,t){return this.add("DELETE",e,a,t),this}options(e,a,t){return this.add("OPTIONS",e,a,t),this}all(e,a,t){return this.add("ALL",e,a,t),this}head(e,a,t){return this.add("HEAD",e,a,t),this}connect(e,a,t){return this.add("CONNECT",e,a,t),this}route(e,a,t,r){return this.add(e.toUpperCase(),a,t,r,r?.config),this}ws(e,a){const t=a.transformMessage?Array.isArray(a.transformMessage)?a.transformMessage:[a.transformMessage]:void 0;let r=null;const s=(0,i.getSchemaValidator)(a?.body,{models:this.definitions.type,normalize:this.config.normalize}),o=(0,i.getSchemaValidator)(a?.response,{models:this.definitions.type,normalize:this.config.normalize}),d=l=>{if(typeof l=="string"){const h=l?.charCodeAt(0);if(h===47||h===123)try{l=JSON.parse(l)}catch{}else(0,i.isNumericString)(l)&&(l=+l)}if(t?.length)for(let h=0;h<t.length;h++){const c=t[h](l);c!==void 0&&(l=c)}return l};return this.route("$INTERNALWS",e,l=>{const{set:h,path:c,qi:m,headers:f,query:A,params:g}=l;if(r===null&&(r=this.getServer()),!r?.upgrade(l.request,{headers:typeof a.upgrade=="function"?a.upgrade(l):a.upgrade,data:{validator:o,open(S){a.open?.(new T.ElysiaWS(S,l))},message:(S,x)=>{const E=d(x);if(s?.Check(E)===!1)return void S.send(new R.ValidationError("message",s,E).message);a.message?.(new T.ElysiaWS(S,l),E)},drain(S){a.drain?.(new T.ElysiaWS(S,l))},close(S,x,E){a.close?.(new T.ElysiaWS(S,l),x,E)}}}))return h.status=400,"Expected a websocket connection"},{beforeHandle:a.beforeHandle,transform:a.transform,headers:a.headers,params:a.params,query:a.query}),this}state(e,a,t){a===void 0?(t=e,e={as:"append"},a=""):t===void 0&&(typeof e=="string"?(t=a,a=e,e={as:"append"}):typeof e=="object"&&(t=a,a=""));const{as:r}=e;if(typeof a!="string")return this;switch(typeof t){case"object":return a?(a in this.singleton.store?this.singleton.store[a]=(0,n.mergeDeep)(this.singleton.store[a],t,{override:r==="override"}):this.singleton.store[a]=t,this):t===null?this:(this.singleton.store=(0,n.mergeDeep)(this.singleton.store,t,{override:r==="override"}),this);case"function":return a?(r==="override"||!(a in this.singleton.store))&&(this.singleton.store[a]=t):this.singleton.store=t(this.singleton.store),this;default:return(r==="override"||!(a in this.singleton.store))&&(this.singleton.store[a]=t),this}}decorate(e,a,t){a===void 0?(t=e,e={as:"append"},a=""):t===void 0&&(typeof e=="string"?(t=a,a=e,e={as:"append"}):typeof e=="object"&&(t=a,a=""));const{as:r}=e;if(typeof a!="string")return this;switch(typeof t){case"object":return a?(a in this.singleton.decorator?this.singleton.decorator[a]=(0,n.mergeDeep)(this.singleton.decorator[a],t,{override:r==="override"}):this.singleton.decorator[a]=t,this):t===null?this:(this.singleton.decorator=(0,n.mergeDeep)(this.singleton.decorator,t,{override:r==="override"}),this);case"function":return a?(r==="override"||!(a in this.singleton.decorator))&&(this.singleton.decorator[a]=t):this.singleton.decorator=t(this.singleton.decorator),this;default:return(r==="override"||!(a in this.singleton.decorator))&&(this.singleton.decorator[a]=t),this}}derive(e,a){a||(a=e,e={as:"local"});const t={subType:"derive",fn:a};return this.onTransform(e,t)}model(e,a){switch(typeof e){case"object":return Object.entries(e).forEach(([t,r])=>{t in this.definitions.type||(this.definitions.type[t]=r)}),this;case"function":return this.definitions.type=e(this.definitions.type),this}return this.definitions.type[e]=a,this}mapDerive(e,a){a||(a=e,e={as:"local"});const t={subType:"mapDerive",fn:a};return this.onTransform(e,t)}affix(e,a,t){if(t==="")return this;const r=["_","-"," "],s=h=>h[0].toUpperCase()+h.slice(1),o=e==="prefix"?(h,c)=>r.includes(h.at(-1)??"")?h+c:h+s(c):r.includes(t.at(-1)??"")?(h,c)=>c+h:(h,c)=>c+s(h),d=h=>{const c={};switch(h){case"decorator":for(const m in this.singleton.decorator)c[o(t,m)]=this.singleton.decorator[m];this.singleton.decorator=c;break;case"state":for(const m in this.singleton.store)c[o(t,m)]=this.singleton.store[m];this.singleton.store=c;break;case"model":for(const m in this.definitions.type)c[o(t,m)]=this.definitions.type[m];this.definitions.type=c;break;case"error":for(const m in this.definitions.error)c[o(t,m)]=this.definitions.error[m];this.definitions.error=c;break}},l=Array.isArray(a)?a:[a];for(const h of l.some(c=>c==="all")?["decorator","state","model","error"]:l)d(h);return this}prefix(e,a){return this.affix("prefix",e,a)}suffix(e,a){return this.affix("suffix",e,a)}compile(){return this["~adapter"].isWebStandard?(this.fetch=this.config.aot?(0,M.composeGeneralHandler)(this):(0,C.createDynamicHandler)(this),typeof this.server?.reload=="function"&&this.server.reload({...this.server||{},fetch:this.fetch}),this):(this._handle=(0,M.composeGeneralHandler)(this),this)}get modules(){return Promise.all(this.promisedModules.promises)}}0&&(module.exports={Cookie,ELYSIA_FORM_DATA,ELYSIA_REQUEST_ID,ELYSIA_TRACE,ERROR_CODE,Elysia,InternalServerError,InvalidCookieSignature,InvertedStatusMap,NotFoundError,ParseError,StatusMap,TypeSystemPolicy,ValidationError,checksum,cloneInference,deduplicateChecksum,error,file,form,getResponseSchemaValidator,getSchemaValidator,mapValueError,mergeHook,mergeObjectArray,redirect,replaceSchemaType,replaceUrlPath,t});

@@ -1,1 +0,1 @@

"use strict";
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var a=(f,e)=>{for(var r in e)i(f,r,{get:e[r],enumerable:!0})},b=(f,e,r,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of t(e))!x.call(f,o)&&o!==r&&i(f,o,{get:()=>e[o],enumerable:!(l=p(e,o))||l.enumerable});return f};var c=f=>b(i({},"__esModule",{value:!0}),f);var d={};a(d,{file:()=>m.file});module.exports=c(d);var m=require("./file");0&&(module.exports={file});

@@ -1,1 +0,1 @@

"use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of d(e))!u.call(t,s)&&s!==r&&n(t,s,{get:()=>e[s],enumerable:!(a=f(e,s))||a.enumerable});return t};var y=t=>l(n({},"__esModule",{value:!0}),t);var c={};h(c,{ElysiaRequest:()=>i});module.exports=y(c);class i{constructor(e,r){this.input=e;this.init=r;this.cache="default";this.credentials="omit";this.destination="";this.integrity="";this.method="GET";this.mode="no-cors";this.redirect="manual";this.referrerPolicy="";this.keepalive=!1;this.duplex="half";this.bodyUsed=!1;if(console.log("Init"),typeof e=="string")this.url=e;else if(e instanceof URL)this.url=e.href;else if(e instanceof Request)this.url=e.url;else throw new TypeError("Invalid url");r&&(r.method&&(this.method=r.method),r.keepalive&&(this.keepalive=r.keepalive),r.redirect&&(this.redirect=r.redirect),r.integrity&&(this.integrity=r.integrity),r.signal&&(this._signal=r.signal),r.credentials&&(this.credentials=r.credentials),r.mode&&(this.mode=r.mode),r.referrerPolicy&&(this.referrerPolicy=r.referrerPolicy),r.duplex&&(this.duplex=r.duplex))}get headers(){if(this._headers)return this._headers;if(!this.init?.headers)return this._headers=new Headers;const e=this.init.headers;return Array.isArray(e)?this._headers=new Headers(e):e instanceof Headers?this._headers=e:e?this._headers=new Headers(e):this._headers=new Headers}get signal(){return this._signal?this._signal:this._signal=new AbortController().signal}get body(){if(this.method==="GET"||this.method==="HEAD"||!this.init?.body)return null;const e=this.init.body;return e instanceof ReadableStream?e:e instanceof ArrayBuffer?new ReadableStream({start(r){r.enqueue(e),r.close()}}):e instanceof Blob?e.stream():typeof e=="string"?new ReadableStream({start(r){r.enqueue(new TextEncoder().encode(e)),r.close()}}):e instanceof URLSearchParams||e instanceof FormData?new ReadableStream({start(r){r.enqueue(new TextEncoder().encode(e.toString())),r.close()}}):e instanceof DataView?new ReadableStream({start(r){r.enqueue(e.buffer),r.close()}}):Symbol.iterator in e?new ReadableStream({start(r){for(const a of e)r.enqueue(a);r.close()}}):Symbol.asyncIterator in e?new ReadableStream({async start(r){for await(const a of e)r.enqueue(a);r.close()}}):null}async arrayBuffer(){if(this.init?.body instanceof ArrayBuffer)return this.init.body;if(!this.body)return new ArrayBuffer(0);const e=[];for await(const r of this.body)e.push(r);return Buffer.concat(e)}async blob(){if(this.init?.body instanceof Blob)return this.init.body;const e=await this.arrayBuffer();return new Blob([e])}async formData(){if(this.init?.body instanceof FormData)return this.init.body;throw new Error("Unable to parse body as FormData")}async json(){return this.init?.body instanceof ReadableStream?JSON.parse(await o(this.init.body)):typeof this.init?.body=="string"?JSON.parse(this.init.body):this.init?.body instanceof ArrayBuffer?JSON.parse(Buffer.from(this.init.body).toString()):JSON.parse(Buffer.from(await this.arrayBuffer()).toString())}async text(){if(this.init?.body instanceof ReadableStream)return o(this.init.body);if(typeof this.init?.body=="string")return this.init.body;if(this.init?.body instanceof ArrayBuffer)return Buffer.from(this.init.body).toString();const e=await this.arrayBuffer();return Buffer.from(e).toString()}clone(){return new i(this.input,this.init)}}async function o(t){const e=[];for await(const r of t)e.push(r);return Buffer.from(Buffer.concat(e)).toString()}0&&(module.exports={ElysiaRequest});
"use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of d(e))!u.call(t,s)&&s!==r&&n(t,s,{get:()=>e[s],enumerable:!(a=f(e,s))||a.enumerable});return t};var y=t=>l(n({},"__esModule",{value:!0}),t);var c={};h(c,{ElysiaRequest:()=>i});module.exports=y(c);class i{constructor(e,r){this.input=e;this.init=r;this.cache="default";this.credentials="omit";this.destination="";this.integrity="";this.method="GET";this.mode="no-cors";this.redirect="manual";this.referrerPolicy="";this.keepalive=!1;this.duplex="half";this.bodyUsed=!1;if(typeof e=="string")this.url=e;else if(e instanceof URL)this.url=e.href;else if(e instanceof Request)this.url=e.url;else throw new TypeError("Invalid url");r&&(r.method&&(this.method=r.method),r.keepalive&&(this.keepalive=r.keepalive),r.redirect&&(this.redirect=r.redirect),r.integrity&&(this.integrity=r.integrity),r.signal&&(this._signal=r.signal),r.credentials&&(this.credentials=r.credentials),r.mode&&(this.mode=r.mode),r.referrerPolicy&&(this.referrerPolicy=r.referrerPolicy),r.duplex&&(this.duplex=r.duplex))}get headers(){if(this._headers)return this._headers;if(!this.init?.headers)return this._headers=new Headers;const e=this.init.headers;return Array.isArray(e)?this._headers=new Headers(e):e instanceof Headers?this._headers=e:e?this._headers=new Headers(e):this._headers=new Headers}get signal(){return this._signal?this._signal:this._signal=new AbortController().signal}get body(){if(this.method==="GET"||this.method==="HEAD"||!this.init?.body)return null;const e=this.init.body;return e instanceof ReadableStream?e:e instanceof ArrayBuffer?new ReadableStream({start(r){r.enqueue(e),r.close()}}):e instanceof Blob?e.stream():typeof e=="string"?new ReadableStream({start(r){r.enqueue(new TextEncoder().encode(e)),r.close()}}):e instanceof URLSearchParams||e instanceof FormData?new ReadableStream({start(r){r.enqueue(new TextEncoder().encode(e.toString())),r.close()}}):e instanceof DataView?new ReadableStream({start(r){r.enqueue(e.buffer),r.close()}}):Symbol.iterator in e?new ReadableStream({start(r){for(const a of e)r.enqueue(a);r.close()}}):Symbol.asyncIterator in e?new ReadableStream({async start(r){for await(const a of e)r.enqueue(a);r.close()}}):null}async arrayBuffer(){if(this.init?.body instanceof ArrayBuffer)return this.init.body;if(!this.body)return new ArrayBuffer(0);const e=[];for await(const r of this.body)e.push(r);return Buffer.concat(e)}async blob(){if(this.init?.body instanceof Blob)return this.init.body;const e=await this.arrayBuffer();return new Blob([e])}async formData(){if(this.init?.body instanceof FormData)return this.init.body;throw new Error("Unable to parse body as FormData")}async json(){return this.init?.body instanceof ReadableStream?JSON.parse(await o(this.init.body)):typeof this.init?.body=="string"?JSON.parse(this.init.body):this.init?.body instanceof ArrayBuffer?JSON.parse(Buffer.from(this.init.body).toString()):JSON.parse(Buffer.from(await this.arrayBuffer()).toString())}async text(){if(this.init?.body instanceof ReadableStream)return o(this.init.body);if(typeof this.init?.body=="string")return this.init.body;if(this.init?.body instanceof ArrayBuffer)return Buffer.from(this.init.body).toString();const e=await this.arrayBuffer();return Buffer.from(e).toString()}clone(){return new i(this.input,this.init)}}async function o(t){const e=[];for await(const r of t)e.push(r);return Buffer.from(Buffer.concat(e)).toString()}0&&(module.exports={ElysiaRequest});
{
"name": "elysia",
"description": "Ergonomic Framework for Human",
"version": "1.2.0-exp.18",
"version": "1.2.0-exp.19",
"author": {

@@ -6,0 +6,0 @@ "name": "saltyAom",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc