yinzerflow 0.2.10 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,22 +1,32 @@
1
- var M1=Object.create;var{getPrototypeOf:U1,defineProperty:u$,getOwnPropertyNames:j1}=Object;var F1=Object.prototype.hasOwnProperty;var F$=($,W,Y)=>{Y=$!=null?M1(U1($)):{};let Z=W||!$||!$.__esModule?u$(Y,"default",{value:$,enumerable:!0}):Y;for(let D of j1($))if(!F1.call(Z,D))u$(Z,D,{get:()=>$[D],enumerable:!0});return Z};var _1=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var D$=_1((_$,V$)=>{(function($,W){typeof _$=="object"&&typeof V$!="undefined"?V$.exports=W():typeof define=="function"&&define.amd?define(W):($=typeof globalThis!="undefined"?globalThis:$||self).dayjs=W()})(_$,function(){var $=1000,W=60000,Y=3600000,Z="millisecond",D="second",Q="minute",X="hour",O="day",V="week",B="month",w="quarter",z="year",L="date",o="Invalid Date",M$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,e=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,U$={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(U){var G=["th","st","nd","rd"],J=U%100;return"["+U+(G[(J-20)%10]||G[J]||G[0])+"]"}},s=function(U,G,J){var M=String(U);return!M||M.length>=G?U:""+Array(G+1-M.length).join(J)+U},$$={s,z:function(U){var G=-U.utcOffset(),J=Math.abs(G),M=Math.floor(J/60),K=J%60;return(G<=0?"+":"-")+s(M,2,"0")+":"+s(K,2,"0")},m:function U(G,J){if(G.date()<J.date())return-U(J,G);var M=12*(J.year()-G.year())+(J.month()-G.month()),K=G.clone().add(M,B),j=J-K<0,F=G.clone().add(M+(j?-1:1),B);return+(-(M+(J-K)/(j?K-F:F-K))||0)},a:function(U){return U<0?Math.ceil(U)||0:Math.floor(U)},p:function(U){return{M:B,y:z,w:V,d:O,D:L,h:X,m:Q,s:D,ms:Z,Q:w}[U]||String(U||"").toLowerCase().replace(/s$/,"")},u:function(U){return U===void 0}},m="en",f={};f[m]=U$;var C$="$isDayjsObject",j$=function(U){return U instanceof Y$||!(!U||!U[C$])},W$=function U(G,J,M){var K;if(!G)return m;if(typeof G=="string"){var j=G.toLowerCase();f[j]&&(K=j),J&&(f[j]=J,K=j);var F=G.split("-");if(!K&&F.length>1)return U(F[0])}else{var q=G.name;f[q]=G,K=q}return!M&&K&&(m=K),K||!M&&m},S=function(U,G){if(j$(U))return U.clone();var J=typeof G=="object"?G:{};return J.date=U,J.args=arguments,new Y$(J)},H=$$;H.l=W$,H.i=j$,H.w=function(U,G){return S(U,{locale:G.$L,utc:G.$u,x:G.$x,$offset:G.$offset})};var Y$=function(){function U(J){this.$L=W$(J.locale,null,!0),this.parse(J),this.$x=this.$x||J.x||{},this[C$]=!0}var G=U.prototype;return G.parse=function(J){this.$d=function(M){var{date:K,utc:j}=M;if(K===null)return new Date(NaN);if(H.u(K))return new Date;if(K instanceof Date)return new Date(K);if(typeof K=="string"&&!/Z$/i.test(K)){var F=K.match(M$);if(F){var q=F[2]-1||0,E=(F[7]||"0").substring(0,3);return j?new Date(Date.UTC(F[1],q,F[3]||1,F[4]||0,F[5]||0,F[6]||0,E)):new Date(F[1],q,F[3]||1,F[4]||0,F[5]||0,F[6]||0,E)}}return new Date(K)}(J),this.init()},G.init=function(){var J=this.$d;this.$y=J.getFullYear(),this.$M=J.getMonth(),this.$D=J.getDate(),this.$W=J.getDay(),this.$H=J.getHours(),this.$m=J.getMinutes(),this.$s=J.getSeconds(),this.$ms=J.getMilliseconds()},G.$utils=function(){return H},G.isValid=function(){return this.$d.toString()!==o},G.isSame=function(J,M){var K=S(J);return this.startOf(M)<=K&&K<=this.endOf(M)},G.isAfter=function(J,M){return S(J)<this.startOf(M)},G.isBefore=function(J,M){return this.endOf(M)<S(J)},G.$g=function(J,M,K){return H.u(J)?this[M]:this.set(K,J)},G.unix=function(){return Math.floor(this.valueOf()/1000)},G.valueOf=function(){return this.$d.getTime()},G.startOf=function(J,M){var K=this,j=!!H.u(M)||M,F=H.p(J),q=function(l,T){var h=H.w(K.$u?Date.UTC(K.$y,T,l):new Date(K.$y,T,l),K);return j?h:h.endOf(O)},E=function(l,T){return H.w(K.toDate()[l].apply(K.toDate("s"),(j?[0,0,0,0]:[23,59,59,999]).slice(T)),K)},k=this.$W,I=this.$M,R=this.$D,c="set"+(this.$u?"UTC":"");switch(F){case z:return j?q(1,0):q(31,11);case B:return j?q(1,I):q(0,I+1);case V:var p=this.$locale().weekStart||0,a=(k<p?k+7:k)-p;return q(j?R-a:R+(6-a),I);case O:case L:return E(c+"Hours",0);case X:return E(c+"Minutes",1);case Q:return E(c+"Seconds",2);case D:return E(c+"Milliseconds",3);default:return this.clone()}},G.endOf=function(J){return this.startOf(J,!1)},G.$set=function(J,M){var K,j=H.p(J),F="set"+(this.$u?"UTC":""),q=(K={},K[O]=F+"Date",K[L]=F+"Date",K[B]=F+"Month",K[z]=F+"FullYear",K[X]=F+"Hours",K[Q]=F+"Minutes",K[D]=F+"Seconds",K[Z]=F+"Milliseconds",K)[j],E=j===O?this.$D+(M-this.$W):M;if(j===B||j===z){var k=this.clone().set(L,1);k.$d[q](E),k.init(),this.$d=k.set(L,Math.min(this.$D,k.daysInMonth())).$d}else q&&this.$d[q](E);return this.init(),this},G.set=function(J,M){return this.clone().$set(J,M)},G.get=function(J){return this[H.p(J)]()},G.add=function(J,M){var K,j=this;J=Number(J);var F=H.p(M),q=function(I){var R=S(j);return H.w(R.date(R.date()+Math.round(I*J)),j)};if(F===B)return this.set(B,this.$M+J);if(F===z)return this.set(z,this.$y+J);if(F===O)return q(1);if(F===V)return q(7);var E=(K={},K[Q]=W,K[X]=Y,K[D]=$,K)[F]||1,k=this.$d.getTime()+J*E;return H.w(k,this)},G.subtract=function(J,M){return this.add(-1*J,M)},G.format=function(J){var M=this,K=this.$locale();if(!this.isValid())return K.invalidDate||o;var j=J||"YYYY-MM-DDTHH:mm:ssZ",F=H.z(this),q=this.$H,E=this.$m,k=this.$M,I=K.weekdays,R=K.months,c=K.meridiem,p=function(T,h,n,Z$){return T&&(T[h]||T(M,j))||n[h].slice(0,Z$)},a=function(T){return H.s(q%12||12,T,"0")},l=c||function(T,h,n){var Z$=T<12?"AM":"PM";return n?Z$.toLowerCase():Z$};return j.replace(e,function(T,h){return h||function(n){switch(n){case"YY":return String(M.$y).slice(-2);case"YYYY":return H.s(M.$y,4,"0");case"M":return k+1;case"MM":return H.s(k+1,2,"0");case"MMM":return p(K.monthsShort,k,R,3);case"MMMM":return p(R,k);case"D":return M.$D;case"DD":return H.s(M.$D,2,"0");case"d":return String(M.$W);case"dd":return p(K.weekdaysMin,M.$W,I,2);case"ddd":return p(K.weekdaysShort,M.$W,I,3);case"dddd":return I[M.$W];case"H":return String(q);case"HH":return H.s(q,2,"0");case"h":return a(1);case"hh":return a(2);case"a":return l(q,E,!0);case"A":return l(q,E,!1);case"m":return String(E);case"mm":return H.s(E,2,"0");case"s":return String(M.$s);case"ss":return H.s(M.$s,2,"0");case"SSS":return H.s(M.$ms,3,"0");case"Z":return F}return null}(T)||F.replace(":","")})},G.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},G.diff=function(J,M,K){var j,F=this,q=H.p(M),E=S(J),k=(E.utcOffset()-this.utcOffset())*W,I=this-E,R=function(){return H.m(F,E)};switch(q){case z:j=R()/12;break;case B:j=R();break;case w:j=R()/3;break;case V:j=(I-k)/604800000;break;case O:j=(I-k)/86400000;break;case X:j=I/Y;break;case Q:j=I/W;break;case D:j=I/$;break;default:j=I}return K?j:H.a(j)},G.daysInMonth=function(){return this.endOf(B).$D},G.$locale=function(){return f[this.$L]},G.locale=function(J,M){if(!J)return this.$L;var K=this.clone(),j=W$(J,M,!0);return j&&(K.$L=j),K},G.clone=function(){return H.w(this.$d,this)},G.toDate=function(){return new Date(this.valueOf())},G.toJSON=function(){return this.isValid()?this.toISOString():null},G.toISOString=function(){return this.$d.toISOString()},G.toString=function(){return this.$d.toUTCString()},U}(),b$=Y$.prototype;return S.prototype=b$,[["$ms",Z],["$s",D],["$m",Q],["$H",X],["$W",O],["$M",B],["$y",z],["$D",L]].forEach(function(U){b$[U[1]]=function(G){return this.$g(G,U[0],U[1])}}),S.extend=function(U,G){return U.$i||(U(G,Y$,S),U.$i=!0),S},S.locale=W$,S.isDayjs=j$,S.unix=function(U){return S(1000*U)},S.en=f[m],S.Ls=f,S.p={},S})});import{createServer as p0}from"net";var w$=F$(D$(),1);var Q$={ok:"OK",created:"Created",accepted:"Accepted",noContent:"No Content",movedPermanently:"Moved Permanently",found:"Found",notModified:"Not Modified",badRequest:"Bad Request",unauthorized:"Unauthorized",forbidden:"Forbidden",notFound:"Not Found",methodNotAllowed:"Method Not Allowed",conflict:"Conflict",unsupportedMediaType:"Unsupported Media Type",tooManyRequests:"Too Many Requests",internalServerError:"Internal Server Error"},b={ok:200,created:201,accepted:202,noContent:204,movedPermanently:301,found:302,notModified:304,badRequest:400,unauthorized:401,forbidden:403,notFound:404,methodNotAllowed:405,conflict:409,unsupportedMediaType:415,tooManyRequests:429,internalServerError:500},A={delete:"DELETE",get:"GET",head:"HEAD",post:"POST",put:"PUT",patch:"PATCH",options:"OPTIONS"},v={json:"application/json",html:"text/html",form:"application/x-www-form-urlencoded",multipart:"multipart/form-data",xml:"application/xml",text:"text/plain",csv:"text/csv",yamlApplication:"application/yaml",yamlText:"text/yaml",urlEncodedJson:"application/x-www-form-urlencoded+json"},u={authorization:"Authorization",proxyAuthorization:"Proxy-Authorization",wwwAuthenticate:"WWW-Authenticate",cacheControl:"Cache-Control",etag:"ETag",expires:"Expires",lastModified:"Last-Modified",ifMatch:"If-Match",ifNoneMatch:"If-None-Match",ifModifiedSince:"If-Modified-Since",ifUnmodifiedSince:"If-Unmodified-Since",ifRange:"If-Range",age:"Age",vary:"Vary",contentType:"Content-Type",contentLength:"Content-Length",contentEncoding:"Content-Encoding",contentLanguage:"Content-Language",contentDisposition:"Content-Disposition",contentLocation:"Content-Location",contentRange:"Content-Range",accessControlAllowCredentials:"Access-Control-Allow-Credentials",accessControlAllowHeaders:"Access-Control-Allow-Headers",accessControlAllowMethods:"Access-Control-Allow-Methods",accessControlAllowOrigin:"Access-Control-Allow-Origin",accessControlExposeHeaders:"Access-Control-Expose-Headers",accessControlMaxAge:"Access-Control-Max-Age",accessControlRequestHeaders:"Access-Control-Request-Headers",accessControlRequestMethod:"Access-Control-Request-Method",accept:"Accept",acceptEncoding:"Accept-Encoding",acceptLanguage:"Accept-Language",acceptRanges:"Accept-Ranges",host:"Host",userAgent:"User-Agent",referer:"Referer",origin:"Origin",from:"From",expect:"Expect",location:"Location",server:"Server",date:"Date",allow:"Allow",retryAfter:"Retry-After",range:"Range",contentSecurityPolicy:"Content-Security-Policy",contentSecurityPolicyReportOnly:"Content-Security-Policy-Report-Only",strictTransportSecurity:"Strict-Transport-Security",xContentTypeOptions:"X-Content-Type-Options",xFrameOptions:"X-Frame-Options",xXSSProtection:"X-XSS-Protection",referrerPolicy:"Referrer-Policy",permissionsPolicy:"Permissions-Policy",crossOriginEmbedderPolicy:"Cross-Origin-Embedder-Policy",crossOriginOpenerPolicy:"Cross-Origin-Opener-Policy",crossOriginResourcePolicy:"Cross-Origin-Resource-Policy",cookie:"Cookie",setCookie:"Set-Cookie",connection:"Connection",keepAlive:"Keep-Alive",upgrade:"Upgrade",upgradeInsecureRequests:"Upgrade-Insecure-Requests",transferEncoding:"Transfer-Encoding",te:"TE",trailer:"Trailer",forwarded:"Forwarded",xForwardedFor:"X-Forwarded-For",via:"Via",maxForwards:"Max-Forwards",altSvc:"Alt-Svc",altUsed:"Alt-Used",timingAllowOrigin:"Timing-Allow-Origin",serverTiming:"Server-Timing",refresh:"Refresh",link:"Link",xPoweredBy:"X-Powered-By",xPermittedCrossDomainPolicies:"X-Permitted-Cross-Domain-Policies",reportTo:"Report-To",serviceWorkerAllowed:"Service-Worker-Allowed",sourceMap:"SourceMap",priority:"Priority",secGPC:"Sec-GPC",clearSiteData:"Clear-Site-Data",noVarySearch:"No-Vary-Search"},r={base64:"base64",binary:"binary",utf8:"utf8"};var X$=($,W)=>{if(!W.enabled)return!1;if($.request.method==="OPTIONS"){if(!h$($,W))return $.response.setStatusCode(403),$._response._setBody({error:"CORS: Origin not allowed",origin:$.request.headers.origin}),!0;$.response.setStatusCode(W.optionsSuccessStatus);let D=y$($,W);if($._response._setHeadersIfNotSet({[u.accessControlAllowOrigin]:D,[u.accessControlAllowMethods]:W.methods.join(", "),[u.accessControlAllowHeaders]:typeof W.allowedHeaders==="string"?W.allowedHeaders:W.allowedHeaders.join(", "),[u.accessControlAllowCredentials]:W.credentials?"true":"false",[u.accessControlExposeHeaders]:W.exposedHeaders.join(", "),[u.accessControlMaxAge]:W.maxAge.toString()}),W.preflightContinue)return!1;return $._response._setBody(""),!0}if(h$($,W)){let Z=y$($,W);$._response._setHeadersIfNotSet({[u.accessControlAllowOrigin]:Z,[u.accessControlAllowCredentials]:W.credentials?"true":"false"})}return!1},y$=($,W)=>{if(W.origin==="*"){if(W.credentials)throw new Error('CORS Security Error: origin: "*" with credentials: true is forbidden by CORS spec and creates security vulnerabilities. Use specific origins instead.');return"*"}let Y=$.request.headers.origin;if(Y)return Y;if(typeof W.origin==="string")return W.origin;if(Array.isArray(W.origin)&&W.origin.length>0){let[Z]=W.origin;return Z??"null"}return"null"},h$=($,W)=>{if(W.origin==="*")return!0;let Y=$.request.headers.origin?.toLowerCase()??"";if(typeof W.origin==="function")return Boolean(W.origin(Y,$.request));if(typeof W.origin==="string")return Y===W.origin.toLowerCase();if(Array.isArray(W.origin))return W.origin.some((Z)=>Y===Z.toLowerCase());if(W.origin instanceof RegExp)return W.origin.test(Y);return!1};var m$=F$(D$(),1),y="YINZER",N={reset:"\x1B[0m",cyan:"\x1B[96m",yellow:"\x1B[93m",red:"\x1B[91m",green:"\x1B[92m",magenta:"\x1B[95m",gray:"\x1B[90m"},V1={positive:["n'at!","yinz are good!","that's the way!","right on!","lookin' good!","way to go!","keep it up!"],neutral:["n'at","yinz know","just sayin'","that's how it is","what can ya do","it happens"],negative:["aw jeez","that ain't right","what a jagoff move","that's terrible n'at","somebody messed up","this is bad news","yinz better fix this"]},d=!1,P=null,C=()=>m$.default().format("YYYY-MM-DD HH:mm:ss.SSS"),H$=($)=>{let W=V1[$];return W[Math.floor(Math.random()*W.length)]??""},H1=($)=>{if(typeof $==="string")return Buffer.byteLength($,"utf8");if(Buffer.isBuffer($))return $.length;if(typeof $==="object"&&$!==null)try{return Buffer.byteLength(JSON.stringify($),"utf8")}catch{return 0}return 0},q1=($)=>{if($>=200&&$<300)return"✅";if($>=300&&$<400)return"\uD83D\uDD04";if($>=400&&$<500)return"❌";if($>=500)return"\uD83D\uDCA5";return"❓"},w1=($)=>{if($<50)return{emoji:"⚡",phrase:Math.random()<0.5?"lightning quick n'at!":"faster than a Stillers touchdown!"};if($<100)return{emoji:"\uD83D\uDD25",phrase:Math.random()<0.5?"that's the way!":"smooth as butter n'at!"};if($<200)return{emoji:"✅",phrase:Math.random()<0.5?"not bad yinz!":"keepin' up just fine!"};if($<500)return{emoji:"⚠️",phrase:Math.random()<0.5?"eh, could be better":"slowin' down a bit there"};if($<1000)return{emoji:"\uD83D\uDC0C",phrase:Math.random()<0.5?"that's draggin' n'at":"c'mon, pick up the pace!"};return{emoji:"\uD83D\uDCA5",phrase:Math.random()<0.5?"what a jagoff response time!":"slower than traffic on the Parkway!"}},N1=($,W,Y)=>{if(!d)return;let Z=C(),D=W??"unknown",Q=Y?` - ${Y}`:"",X="",O="info";if($==="connect")X=`\uD83E\uDD1D [NETWORK] New visitor from ${D} - Welcome to the 'Burgh!`;else if($==="disconnect")X=`\uD83D\uDC4B [NETWORK] ${D} headed out - Thanks for stopping by, yinz come back now!`;else X=`\uD83D\uDCA5 [NETWORK] Connection trouble with ${D}${Q} - That's not good, n'at!`,O="error";if(P)P[O](X);else{let V=O==="error"?N.red:N.gray;console.log(`${V}[${y}] [${Z}] ${X}${N.reset}`)}},B1=($,W,Y)=>{if(!d)return;let{request:Z}=$,D=$._response,Q=(Y-W).toFixed(1),X=Z.ipAddress||"unknown",{method:O,path:V,protocol:B}=Z,w=D._statusCode,z=H1(D._body),L=Z.headers.referer?`"${Z.headers.referer}"`:'"-"',o=Z.headers["user-agent"]?`"${Z.headers["user-agent"]}"`:'"-"',M$=q1(w),e=`\uD83C\uDFE0 ${X} - - [${C()}] "${O} ${V} ${B}" ${w} ${z}b ${L} ${o} ${Q}ms ${M$}`,U$=parseFloat(Q),{emoji:s,phrase:$$}=w1(U$),m=`${s} [PERF] Response time: ${Q}ms - ${$$}`;if(P)P.info(`[NETWORK] ${e}`),P.info(`[PERF] ${m}`);else console.log(`${N.gray}[${y}] [${C()}] [NETWORK] ${e}${N.reset}`),console.log(`${N.magenta}[${y}] ${s} [${C()}] [PERF] Response time: ${Q}ms - ${$$}${N.reset}`)},E1=($,W)=>{if(!d)return;let Y=C(),Z=$&&W?`${W}:${$}`:"unknown",D=H$("positive"),Q=`\uD83D\uDE80 [NETWORK] YinzerFlow server is up and running at ${Z} - Ready to serve yinz all, ${D}!`;if(P)P.info(Q);else console.log(`${N.gray}[${y}] [${Y}] ${Q}${N.reset}`)},A1=($,W)=>{if(!d)return;let Y=C(),Z=$&&W?`${W}:${$}`:"unknown",D=H$("neutral"),Q=`\uD83D\uDED1 [NETWORK] YinzerFlow server at ${Z} is shutting down - See yinz later, ${D}!`;if(P)P.info(Q);else console.log(`${N.gray}[${y}] [${Y}] ${Q}${N.reset}`)},z1=($,W,Y)=>{if(!d)return;let Z=C(),D=$&&W?`${W}:${$}`:"unknown",Q=Y?` - ${Y}`:"",X=H$("negative"),O=`\uD83D\uDCA5 [NETWORK] Server error at ${D}${Q} - Something's not right, ${X}!`;if(P)P.error(O);else console.log(`${N.red}[${y}] [${Z}] ${O}${N.reset}`)},S1=($)=>{d=$},k1=($)=>{P=$},x={setEnabled:S1,setNetworkLogger:k1,connection:N1,request:B1,serverStart:E1,serverStop:A1,serverError:z1};var i={off:0,error:1,warn:2,info:3},I1={positive:["n'at!","yinz are good!","that's the way!","right on!","lookin' good!","way to go!","keep it up!"],neutral:["n'at","yinz know","just sayin'","that's how it is","what can ya do","it happens"],negative:["aw jeez","that ain't right","what a jagoff move","that's terrible n'at","somebody messed up","this is bad news","yinz better fix this"]},t=i.warn,g=null,L1=($)=>{let W=I1[$];return W[Math.floor(Math.random()*W.length)]??""},T1=(...$)=>{if(t<i.info)return;if(g)g.info(...$);else q$("info",...$)},R1=(...$)=>{if(t<i.warn)return;if(g)g.warn(...$);else q$("warn",...$)},v1=(...$)=>{if(t<i.error)return;if(g)g.error(...$);else q$("error",...$)},P1=($,W,Y)=>{if(t<i.info)return;let Z=C(),D="❓ ",Q="";if(W<50)D="⚡ ",Q=Math.random()<0.5?"lightning quick n'at!":"faster than a Stillers touchdown!";else if(W<100)D="\uD83D\uDD25 ",Q=Math.random()<0.5?"that's the way!":"smooth as butter n'at!";else if(W<200)D="✅ ",Q=Math.random()<0.5?"not bad yinz!":"keepin' up just fine!";else if(W<500)D="⚠️ ",Q=Math.random()<0.5?"eh, could be better":"slowin' down a bit there";else if(W<1000)D="\uD83D\uDC0C ",Q=Math.random()<0.5?"that's draggin' n'at":"c'mon, pick up the pace!";else D="\uD83D\uDCA5 ",Q=Math.random()<0.5?"what a jagoff response time!":"slower than traffic on the Parkway!";let X=`${N.magenta}[${y}] ${D} [${Z}] [PERF]${N.reset}`,O=Y?{...Y,executionTime:`${W}ms`}:{executionTime:`${W}ms`};console.log(`${X} ${$} -`,O,`- ${Q}`)},x1=($)=>{t={off:0,error:1,warn:2,info:3}[$]},C1=($)=>{g=$},q$=($,...W)=>{let Y=C(),Z="✅ ",D=N.cyan,Q="positive",X="info";if($==="error")Z="❌ ",D=N.red,Q="negative",X="error";else if($==="warn")Z="⚠️ ",D=N.yellow,Q="neutral",X="warn";else Z="✅ ",D=N.cyan,Q="positive",X="info";let O=L1(Q),V=`${D}[${y}] ${Z}[${Y}] [${$.toUpperCase()}]${N.reset}`;console[X](`${V}`,...W,`- ${O}`)},_={setLogLevel:x1,setCustomLogger:C1,info:T1,warn:R1,error:v1,perf:P1,levels:i};class N${setup;constructor($){this.setup=$}async handle($){try{if(X$($,this.setup._configuration.cors)){$._response._parseResponseIntoString();return}let Y=this.setup._routeRegistry._findRoute($.request.method,$.request.path);if(!Y){let w=await this.setup._hooks._onNotFound($);$._response._setBody(w),$._response._parseResponseIntoString();return}$.request.params=Y.params;let{handler:Z,options:D}=Y,{beforeHooks:Q,afterHooks:X}=D,O=this.setup._hooks._beforeAll;for(let w of O)await w.handler($);for(let w of Q)await w($);let V=null;try{V=await Z($)}catch(w){throw w}for(let w of X)await w($);let B=this.setup._hooks._afterAll;for(let w of B)await w.handler($);if($._response._setBody(V),$.request.method==="HEAD")$._response._setBody(null);$._response._parseResponseIntoString();return}catch(W){await this.handleError($,W)}}async handleError($,W){try{let Y=this.setup._hooks._onError,Z=await Y($,W);$._response._setBody(Z),X$($,this.setup._configuration.cors),$._response._parseResponseIntoString(),$._response._setHeadersIfNotSet({Date:w$.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":$._response._stringBody.split(`
1
+ var _0=Object.create;var{getPrototypeOf:w0,defineProperty:f$,getOwnPropertyNames:O0}=Object;var V0=Object.prototype.hasOwnProperty;var w$=($,W,Y)=>{Y=$!=null?_0(w0($)):{};let Z=W||!$||!$.__esModule?f$(Y,"default",{value:$,enumerable:!0}):Y;for(let D of O0($))if(!V0.call(Z,D))f$(Z,D,{get:()=>$[D],enumerable:!0});return Z};var N0=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var Q$=N0((O$,V$)=>{(function($,W){typeof O$=="object"&&typeof V$!="undefined"?V$.exports=W():typeof define=="function"&&define.amd?define(W):($=typeof globalThis!="undefined"?globalThis:$||self).dayjs=W()})(O$,function(){var $=1000,W=60000,Y=3600000,Z="millisecond",D="second",Q="minute",X="hour",G="day",V="week",A="month",q="quarter",z="year",L="date",e="Invalid Date",j$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,$$=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,H$={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(F){var M=["th","st","nd","rd"],J=F%100;return"["+F+(M[(J-20)%10]||M[J]||M[0])+"]"}},r=function(F,M,J){var U=String(F);return!U||U.length>=M?F:""+Array(M+1-U.length).join(J)+F},W$={s:r,z:function(F){var M=-F.utcOffset(),J=Math.abs(M),U=Math.floor(J/60),K=J%60;return(M<=0?"+":"-")+r(U,2,"0")+":"+r(K,2,"0")},m:function F(M,J){if(M.date()<J.date())return-F(J,M);var U=12*(J.year()-M.year())+(J.month()-M.month()),K=M.clone().add(U,A),j=J-K<0,H=M.clone().add(U+(j?-1:1),A);return+(-(U+(J-K)/(j?K-H:H-K))||0)},a:function(F){return F<0?Math.ceil(F)||0:Math.floor(F)},p:function(F){return{M:A,y:z,w:V,d:G,D:L,h:X,m:Q,s:D,ms:Z,Q:q}[F]||String(F||"").toLowerCase().replace(/s$/,"")},u:function(F){return F===void 0}},f="en",l={};l[f]=H$;var h$="$isDayjsObject",_$=function(F){return F instanceof Z$||!(!F||!F[h$])},Y$=function F(M,J,U){var K;if(!M)return f;if(typeof M=="string"){var j=M.toLowerCase();l[j]&&(K=j),J&&(l[j]=J,K=j);var H=M.split("-");if(!K&&H.length>1)return F(H[0])}else{var N=M.name;l[N]=M,K=N}return!U&&K&&(f=K),K||!U&&f},S=function(F,M){if(_$(F))return F.clone();var J=typeof M=="object"?M:{};return J.date=F,J.args=arguments,new Z$(J)},O=W$;O.l=Y$,O.i=_$,O.w=function(F,M){return S(F,{locale:M.$L,utc:M.$u,x:M.$x,$offset:M.$offset})};var Z$=function(){function F(J){this.$L=Y$(J.locale,null,!0),this.parse(J),this.$x=this.$x||J.x||{},this[h$]=!0}var M=F.prototype;return M.parse=function(J){this.$d=function(U){var{date:K,utc:j}=U;if(K===null)return new Date(NaN);if(O.u(K))return new Date;if(K instanceof Date)return new Date(K);if(typeof K=="string"&&!/Z$/i.test(K)){var H=K.match(j$);if(H){var N=H[2]-1||0,B=(H[7]||"0").substring(0,3);return j?new Date(Date.UTC(H[1],N,H[3]||1,H[4]||0,H[5]||0,H[6]||0,B)):new Date(H[1],N,H[3]||1,H[4]||0,H[5]||0,H[6]||0,B)}}return new Date(K)}(J),this.init()},M.init=function(){var J=this.$d;this.$y=J.getFullYear(),this.$M=J.getMonth(),this.$D=J.getDate(),this.$W=J.getDay(),this.$H=J.getHours(),this.$m=J.getMinutes(),this.$s=J.getSeconds(),this.$ms=J.getMilliseconds()},M.$utils=function(){return O},M.isValid=function(){return this.$d.toString()!==e},M.isSame=function(J,U){var K=S(J);return this.startOf(U)<=K&&K<=this.endOf(U)},M.isAfter=function(J,U){return S(J)<this.startOf(U)},M.isBefore=function(J,U){return this.endOf(U)<S(J)},M.$g=function(J,U,K){return O.u(J)?this[U]:this.set(K,J)},M.unix=function(){return Math.floor(this.valueOf()/1000)},M.valueOf=function(){return this.$d.getTime()},M.startOf=function(J,U){var K=this,j=!!O.u(U)||U,H=O.p(J),N=function(g,v){var m=O.w(K.$u?Date.UTC(K.$y,v,g):new Date(K.$y,v,g),K);return j?m:m.endOf(G)},B=function(g,v){return O.w(K.toDate()[g].apply(K.toDate("s"),(j?[0,0,0,0]:[23,59,59,999]).slice(v)),K)},k=this.$W,I=this.$M,T=this.$D,s="set"+(this.$u?"UTC":"");switch(H){case z:return j?N(1,0):N(31,11);case A:return j?N(1,I):N(0,I+1);case V:var p=this.$locale().weekStart||0,n=(k<p?k+7:k)-p;return N(j?T-n:T+(6-n),I);case G:case L:return B(s+"Hours",0);case X:return B(s+"Minutes",1);case Q:return B(s+"Seconds",2);case D:return B(s+"Milliseconds",3);default:return this.clone()}},M.endOf=function(J){return this.startOf(J,!1)},M.$set=function(J,U){var K,j=O.p(J),H="set"+(this.$u?"UTC":""),N=(K={},K[G]=H+"Date",K[L]=H+"Date",K[A]=H+"Month",K[z]=H+"FullYear",K[X]=H+"Hours",K[Q]=H+"Minutes",K[D]=H+"Seconds",K[Z]=H+"Milliseconds",K)[j],B=j===G?this.$D+(U-this.$W):U;if(j===A||j===z){var k=this.clone().set(L,1);k.$d[N](B),k.init(),this.$d=k.set(L,Math.min(this.$D,k.daysInMonth())).$d}else N&&this.$d[N](B);return this.init(),this},M.set=function(J,U){return this.clone().$set(J,U)},M.get=function(J){return this[O.p(J)]()},M.add=function(J,U){var K,j=this;J=Number(J);var H=O.p(U),N=function(I){var T=S(j);return O.w(T.date(T.date()+Math.round(I*J)),j)};if(H===A)return this.set(A,this.$M+J);if(H===z)return this.set(z,this.$y+J);if(H===G)return N(1);if(H===V)return N(7);var B=(K={},K[Q]=W,K[X]=Y,K[D]=$,K)[H]||1,k=this.$d.getTime()+J*B;return O.w(k,this)},M.subtract=function(J,U){return this.add(-1*J,U)},M.format=function(J){var U=this,K=this.$locale();if(!this.isValid())return K.invalidDate||e;var j=J||"YYYY-MM-DDTHH:mm:ssZ",H=O.z(this),N=this.$H,B=this.$m,k=this.$M,I=K.weekdays,T=K.months,s=K.meridiem,p=function(v,m,t,D$){return v&&(v[m]||v(U,j))||t[m].slice(0,D$)},n=function(v){return O.s(N%12||12,v,"0")},g=s||function(v,m,t){var D$=v<12?"AM":"PM";return t?D$.toLowerCase():D$};return j.replace($$,function(v,m){return m||function(t){switch(t){case"YY":return String(U.$y).slice(-2);case"YYYY":return O.s(U.$y,4,"0");case"M":return k+1;case"MM":return O.s(k+1,2,"0");case"MMM":return p(K.monthsShort,k,T,3);case"MMMM":return p(T,k);case"D":return U.$D;case"DD":return O.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return p(K.weekdaysMin,U.$W,I,2);case"ddd":return p(K.weekdaysShort,U.$W,I,3);case"dddd":return I[U.$W];case"H":return String(N);case"HH":return O.s(N,2,"0");case"h":return n(1);case"hh":return n(2);case"a":return g(N,B,!0);case"A":return g(N,B,!1);case"m":return String(B);case"mm":return O.s(B,2,"0");case"s":return String(U.$s);case"ss":return O.s(U.$s,2,"0");case"SSS":return O.s(U.$ms,3,"0");case"Z":return H}return null}(v)||H.replace(":","")})},M.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},M.diff=function(J,U,K){var j,H=this,N=O.p(U),B=S(J),k=(B.utcOffset()-this.utcOffset())*W,I=this-B,T=function(){return O.m(H,B)};switch(N){case z:j=T()/12;break;case A:j=T();break;case q:j=T()/3;break;case V:j=(I-k)/604800000;break;case G:j=(I-k)/86400000;break;case X:j=I/Y;break;case Q:j=I/W;break;case D:j=I/$;break;default:j=I}return K?j:O.a(j)},M.daysInMonth=function(){return this.endOf(A).$D},M.$locale=function(){return l[this.$L]},M.locale=function(J,U){if(!J)return this.$L;var K=this.clone(),j=Y$(J,U,!0);return j&&(K.$L=j),K},M.clone=function(){return O.w(this.$d,this)},M.toDate=function(){return new Date(this.valueOf())},M.toJSON=function(){return this.isValid()?this.toISOString():null},M.toISOString=function(){return this.$d.toISOString()},M.toString=function(){return this.$d.toUTCString()},F}(),m$=Z$.prototype;return S.prototype=m$,[["$ms",Z],["$s",D],["$m",Q],["$H",X],["$W",G],["$M",A],["$y",z],["$D",L]].forEach(function(F){m$[F[1]]=function(M){return this.$g(M,F[0],F[1])}}),S.extend=function(F,M){return F.$i||(F(M,Z$,S),F.$i=!0),S},S.locale=Y$,S.isDayjs=_$,S.unix=function(F){return S(1000*F)},S.en=l[f],S.Ls=l,S.p={},S})});import{createServer as r1}from"net";var B$=w$(Q$(),1);var X$={ok:"OK",created:"Created",accepted:"Accepted",noContent:"No Content",movedPermanently:"Moved Permanently",found:"Found",notModified:"Not Modified",badRequest:"Bad Request",unauthorized:"Unauthorized",forbidden:"Forbidden",notFound:"Not Found",methodNotAllowed:"Method Not Allowed",conflict:"Conflict",unsupportedMediaType:"Unsupported Media Type",tooManyRequests:"Too Many Requests",internalServerError:"Internal Server Error"},u={ok:200,created:201,accepted:202,noContent:204,movedPermanently:301,found:302,notModified:304,badRequest:400,unauthorized:401,forbidden:403,notFound:404,methodNotAllowed:405,conflict:409,unsupportedMediaType:415,tooManyRequests:429,internalServerError:500},E={delete:"DELETE",get:"GET",head:"HEAD",post:"POST",put:"PUT",patch:"PATCH",options:"OPTIONS"},R={json:"application/json",html:"text/html",form:"application/x-www-form-urlencoded",multipart:"multipart/form-data",xml:"application/xml",text:"text/plain",csv:"text/csv",yamlApplication:"application/yaml",yamlText:"text/yaml",urlEncodedJson:"application/x-www-form-urlencoded+json"},y={authorization:"Authorization",proxyAuthorization:"Proxy-Authorization",wwwAuthenticate:"WWW-Authenticate",cacheControl:"Cache-Control",etag:"ETag",expires:"Expires",lastModified:"Last-Modified",ifMatch:"If-Match",ifNoneMatch:"If-None-Match",ifModifiedSince:"If-Modified-Since",ifUnmodifiedSince:"If-Unmodified-Since",ifRange:"If-Range",age:"Age",vary:"Vary",contentType:"Content-Type",contentLength:"Content-Length",contentEncoding:"Content-Encoding",contentLanguage:"Content-Language",contentDisposition:"Content-Disposition",contentLocation:"Content-Location",contentRange:"Content-Range",accessControlAllowCredentials:"Access-Control-Allow-Credentials",accessControlAllowHeaders:"Access-Control-Allow-Headers",accessControlAllowMethods:"Access-Control-Allow-Methods",accessControlAllowOrigin:"Access-Control-Allow-Origin",accessControlExposeHeaders:"Access-Control-Expose-Headers",accessControlMaxAge:"Access-Control-Max-Age",accessControlRequestHeaders:"Access-Control-Request-Headers",accessControlRequestMethod:"Access-Control-Request-Method",accept:"Accept",acceptEncoding:"Accept-Encoding",acceptLanguage:"Accept-Language",acceptRanges:"Accept-Ranges",host:"Host",userAgent:"User-Agent",referer:"Referer",origin:"Origin",from:"From",expect:"Expect",location:"Location",server:"Server",date:"Date",allow:"Allow",retryAfter:"Retry-After",range:"Range",contentSecurityPolicy:"Content-Security-Policy",contentSecurityPolicyReportOnly:"Content-Security-Policy-Report-Only",strictTransportSecurity:"Strict-Transport-Security",xContentTypeOptions:"X-Content-Type-Options",xFrameOptions:"X-Frame-Options",xXSSProtection:"X-XSS-Protection",referrerPolicy:"Referrer-Policy",permissionsPolicy:"Permissions-Policy",crossOriginEmbedderPolicy:"Cross-Origin-Embedder-Policy",crossOriginOpenerPolicy:"Cross-Origin-Opener-Policy",crossOriginResourcePolicy:"Cross-Origin-Resource-Policy",cookie:"Cookie",setCookie:"Set-Cookie",connection:"Connection",keepAlive:"Keep-Alive",upgrade:"Upgrade",upgradeInsecureRequests:"Upgrade-Insecure-Requests",transferEncoding:"Transfer-Encoding",te:"TE",trailer:"Trailer",forwarded:"Forwarded",xForwardedFor:"X-Forwarded-For",via:"Via",maxForwards:"Max-Forwards",altSvc:"Alt-Svc",altUsed:"Alt-Used",timingAllowOrigin:"Timing-Allow-Origin",serverTiming:"Server-Timing",refresh:"Refresh",link:"Link",xPoweredBy:"X-Powered-By",xPermittedCrossDomainPolicies:"X-Permitted-Cross-Domain-Policies",reportTo:"Report-To",serviceWorkerAllowed:"Service-Worker-Allowed",sourceMap:"SourceMap",priority:"Priority",secGPC:"Sec-GPC",clearSiteData:"Clear-Site-Data",noVarySearch:"No-Vary-Search"},d={base64:"base64",binary:"binary",utf8:"utf8"};var J$=($,W)=>{if(!W.enabled)return!1;if($.request.method==="OPTIONS"){if(!p$($,W))return $.response.setStatusCode(403),$._response._setBody({error:"CORS: Origin not allowed",origin:$.request.headers.origin}),!0;$.response.setStatusCode(W.optionsSuccessStatus);let D=l$($,W);if($._response._setHeadersIfNotSet({[y.accessControlAllowOrigin]:D,[y.accessControlAllowMethods]:W.methods.join(", "),[y.accessControlAllowHeaders]:typeof W.allowedHeaders==="string"?W.allowedHeaders:W.allowedHeaders.join(", "),[y.accessControlAllowCredentials]:W.credentials?"true":"false",[y.accessControlExposeHeaders]:W.exposedHeaders.join(", "),[y.accessControlMaxAge]:W.maxAge.toString()}),W.preflightContinue)return!1;return $._response._setBody(""),!0}if(p$($,W)){let Z=l$($,W);$._response._setHeadersIfNotSet({[y.accessControlAllowOrigin]:Z,[y.accessControlAllowCredentials]:W.credentials?"true":"false"})}return!1},l$=($,W)=>{if(W.origin==="*"){if(W.credentials)throw new Error('CORS Security Error: origin: "*" with credentials: true is forbidden by CORS spec and creates security vulnerabilities. Use specific origins instead.');return"*"}let Y=$.request.headers.origin;if(Y)return Y;if(typeof W.origin==="string")return W.origin;if(Array.isArray(W.origin)&&W.origin.length>0){let[Z]=W.origin;return Z??"null"}return"null"},p$=($,W)=>{if(W.origin==="*")return!0;let Y=$.request.headers.origin?.toLowerCase()??"";if(typeof W.origin==="function")return Boolean(W.origin(Y,$.request));if(typeof W.origin==="string")return Y===W.origin.toLowerCase();if(Array.isArray(W.origin))return W.origin.some((Z)=>Y===Z.toLowerCase());if(W.origin instanceof RegExp)return W.origin.test(Y);return!1};var g$=w$(Q$(),1),h="YINZER",w={reset:"\x1B[0m",cyan:"\x1B[96m",yellow:"\x1B[93m",red:"\x1B[91m",green:"\x1B[92m",magenta:"\x1B[95m",gray:"\x1B[90m"},q0={positive:["n'at!","yinz are good!","that's the way!","right on!","lookin' good!","way to go!","keep it up!"],neutral:["n'at","yinz know","just sayin'","that's how it is","what can ya do","it happens"],negative:["aw jeez","that ain't right","what a jagoff move","that's terrible n'at","somebody messed up","this is bad news","yinz better fix this"]},i=!1,P=null,C=()=>g$.default().format("YYYY-MM-DD HH:mm:ss.SSS"),N$=($)=>{let W=q0[$];return W[Math.floor(Math.random()*W.length)]??""},B0=($)=>{if(typeof $==="string")return Buffer.byteLength($,"utf8");if(Buffer.isBuffer($))return $.length;if(typeof $==="object"&&$!==null)try{return Buffer.byteLength(JSON.stringify($),"utf8")}catch{return 0}return 0},E0=($)=>{if($>=200&&$<300)return"✅";if($>=300&&$<400)return"\uD83D\uDD04";if($>=400&&$<500)return"❌";if($>=500)return"\uD83D\uDCA5";return"❓"},A0=($)=>{if($<50)return{emoji:"⚡",phrase:Math.random()<0.5?"lightning quick n'at!":"faster than a Stillers touchdown!"};if($<100)return{emoji:"\uD83D\uDD25",phrase:Math.random()<0.5?"that's the way!":"smooth as butter n'at!"};if($<200)return{emoji:"✅",phrase:Math.random()<0.5?"not bad yinz!":"keepin' up just fine!"};if($<500)return{emoji:"⚠️",phrase:Math.random()<0.5?"eh, could be better":"slowin' down a bit there"};if($<1000)return{emoji:"\uD83D\uDC0C",phrase:Math.random()<0.5?"that's draggin' n'at":"c'mon, pick up the pace!"};return{emoji:"\uD83D\uDCA5",phrase:Math.random()<0.5?"what a jagoff response time!":"slower than traffic on the Parkway!"}},z0=($,W,Y)=>{if(!i)return;let Z=C(),D=W??"unknown",Q=Y?` - ${Y}`:"",X="",G="info";if($==="connect")X=`\uD83E\uDD1D [NETWORK] New visitor from ${D} - Welcome to the 'Burgh!`;else if($==="disconnect")X=`\uD83D\uDC4B [NETWORK] ${D} headed out - Thanks for stopping by, yinz come back now!`;else X=`\uD83D\uDCA5 [NETWORK] Connection trouble with ${D}${Q} - That's not good, n'at!`,G="error";if(P)P[G](X);else{let V=G==="error"?w.red:w.gray;console.log(`${V}[${h}] [${Z}] ${X}${w.reset}`)}},S0=($,W,Y)=>{if(!i)return;let{request:Z}=$,D=$._response,Q=(Y-W).toFixed(1),X=Z.ipAddress||"unknown",{method:G,path:V,protocol:A}=Z,q=D._statusCode,z=B0(D._body),L=Z.headers.referer?`"${Z.headers.referer}"`:'"-"',e=Z.headers["user-agent"]?`"${Z.headers["user-agent"]}"`:'"-"',j$=E0(q),$$=`\uD83C\uDFE0 ${X} - - [${C()}] "${G} ${V} ${A}" ${q} ${z}b ${L} ${e} ${Q}ms ${j$}`,H$=parseFloat(Q),{emoji:r,phrase:W$}=A0(H$),f=`${r} [PERF] Response time: ${Q}ms - ${W$}`;if(P)P.info(`[NETWORK] ${$$}`),P.info(`[PERF] ${f}`);else console.log(`${w.gray}[${h}] [${C()}] [NETWORK] ${$$}${w.reset}`),console.log(`${w.magenta}[${h}] ${r} [${C()}] [PERF] Response time: ${Q}ms - ${W$}${w.reset}`)},k0=($,W)=>{if(!i)return;let Y=C(),Z=$&&W?`${W}:${$}`:"unknown",D=N$("positive"),Q=`\uD83D\uDE80 [NETWORK] YinzerFlow server is up and running at ${Z} - Ready to serve yinz all, ${D}!`;if(P)P.info(Q);else console.log(`${w.gray}[${h}] [${Y}] ${Q}${w.reset}`)},I0=($,W)=>{if(!i)return;let Y=C(),Z=$&&W?`${W}:${$}`:"unknown",D=N$("neutral"),Q=`\uD83D\uDED1 [NETWORK] YinzerFlow server at ${Z} is shutting down - See yinz later, ${D}!`;if(P)P.info(Q);else console.log(`${w.gray}[${h}] [${Y}] ${Q}${w.reset}`)},L0=($,W,Y)=>{if(!i)return;let Z=C(),D=$&&W?`${W}:${$}`:"unknown",Q=Y?` - ${Y}`:"",X=N$("negative"),G=`\uD83D\uDCA5 [NETWORK] Server error at ${D}${Q} - Something's not right, ${X}!`;if(P)P.error(G);else console.log(`${w.red}[${h}] [${Z}] ${G}${w.reset}`)},v0=($)=>{i=$},T0=($)=>{P=$},x={setEnabled:v0,setNetworkLogger:T0,connection:z0,request:S0,serverStart:k0,serverStop:I0,serverError:L0};var a={off:0,error:1,warn:2,info:3},R0={positive:["n'at!","yinz are good!","that's the way!","right on!","lookin' good!","way to go!","keep it up!"],neutral:["n'at","yinz know","just sayin'","that's how it is","what can ya do","it happens"],negative:["aw jeez","that ain't right","what a jagoff move","that's terrible n'at","somebody messed up","this is bad news","yinz better fix this"]},o=a.warn,c=null,P0=($)=>{let W=R0[$];return W[Math.floor(Math.random()*W.length)]??""},x0=(...$)=>{if(o<a.info)return;if(c)c.info(...$);else q$("info",...$)},C0=(...$)=>{if(o<a.warn)return;if(c)c.warn(...$);else q$("warn",...$)},b0=(...$)=>{if(o<a.error)return;if(c)c.error(...$);else q$("error",...$)},u0=($,W,Y)=>{if(o<a.info)return;let Z=C(),D="❓ ",Q="";if(W<50)D="⚡ ",Q=Math.random()<0.5?"lightning quick n'at!":"faster than a Stillers touchdown!";else if(W<100)D="\uD83D\uDD25 ",Q=Math.random()<0.5?"that's the way!":"smooth as butter n'at!";else if(W<200)D="✅ ",Q=Math.random()<0.5?"not bad yinz!":"keepin' up just fine!";else if(W<500)D="⚠️ ",Q=Math.random()<0.5?"eh, could be better":"slowin' down a bit there";else if(W<1000)D="\uD83D\uDC0C ",Q=Math.random()<0.5?"that's draggin' n'at":"c'mon, pick up the pace!";else D="\uD83D\uDCA5 ",Q=Math.random()<0.5?"what a jagoff response time!":"slower than traffic on the Parkway!";let X=`${w.magenta}[${h}] ${D} [${Z}] [PERF]${w.reset}`,G=Y?{...Y,executionTime:`${W}ms`}:{executionTime:`${W}ms`};console.log(`${X} ${$} -`,G,`- ${Q}`)},y0=($)=>{o={off:0,error:1,warn:2,info:3}[$]},h0=($)=>{c=$},q$=($,...W)=>{let Y=C(),Z="✅ ",D=w.cyan,Q="positive",X="info";if($==="error")Z="❌ ",D=w.red,Q="negative",X="error";else if($==="warn")Z="⚠️ ",D=w.yellow,Q="neutral",X="warn";else Z="✅ ",D=w.cyan,Q="positive",X="info";let G=P0(Q),V=`${D}[${h}] ${Z}[${Y}] [${$.toUpperCase()}]${w.reset}`;console[X](`${V}`,...W,`- ${G}`)},_={setLogLevel:y0,setCustomLogger:h0,info:x0,warn:C0,error:b0,perf:u0,levels:a};class E${setup;constructor($){this.setup=$}async handle($){try{if(J$($,this.setup._configuration.cors)){$._response._parseResponseIntoString();return}let Y=this.setup._routeRegistry._findRoute($.request.method,$.request.path);if(!Y){let q=await this.setup._hooks._onNotFound($);$._response._setBody(q),$._response._parseResponseIntoString();return}$.request.params=Y.params;let{handler:Z,options:D}=Y,{beforeHooks:Q=[],afterHooks:X=[]}=D,G=this.setup._hooks._beforeAll;for(let q of G)await q.handler($);for(let q of Q)await q($);let V=null;try{V=await Z($)}catch(q){throw q}for(let q of X)await q($);let A=this.setup._hooks._afterAll;for(let q of A)await q.handler($);if($._response._setBody(V),$.request.method==="HEAD")$._response._setBody(null);$._response._parseResponseIntoString();return}catch(W){await this.handleError($,W)}}async handleError($,W){try{let Y=this.setup._hooks._onError,Z=await Y($,W);$._response._setBody(Z),J$($,this.setup._configuration.cors),$._response._parseResponseIntoString(),$._response._setHeadersIfNotSet({Date:B$.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":$._response._stringBody.split(`
2
2
 
3
- `)[1]?.length.toString()??"0"})}catch(Y){_.error("Error handler failed, this might be an internal error in the YinzerFlow framework: ",Y),$.response.setStatusCode(500),$._response._setBody({success:!1,message:"Internal Server Error"}),X$($,this.setup._configuration.cors),$._response._parseResponseIntoString(),$._response._setHeadersIfNotSet({Date:w$.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":$._response._stringBody.split(`
3
+ `)[1]?.length.toString()??"0"})}catch(Y){_.error("Error handler failed, this might be an internal error in the YinzerFlow framework: ",Y),$.response.setStatusCode(500),$._response._setBody({success:!1,message:"Internal Server Error"}),J$($,this.setup._configuration.cors),$._response._parseResponseIntoString(),$._response._setHeadersIfNotSet({Date:B$.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":$._response._stringBody.split(`
4
4
 
5
- `)[1]?.length.toString()??"0"})}}}var f$=["__proto__","constructor","prototype"],p$=($,W)=>{if(!$||!$.trim()||$.trim()==="\x00")return;let Y=Buffer.byteLength($,"utf8");if(Y>W.maxSize)throw _.warn("[SECURITY] JSON request body too large",{size:Y,limit:W.maxSize,sizeMB:Math.round(Y/1024/1024)}),new Error(`Request body too large: ${Y} bytes exceeds limit of ${W.maxSize} bytes`);let Z=null;try{Z=JSON.parse($)}catch(D){let Q=D instanceof Error?D.message:String(D);throw new Error(`Invalid JSON syntax: ${Q}`)}try{B$(Z,W,1)}catch(D){let Q=D instanceof Error?D.message:String(D);throw new Error(`JSON security validation failed: ${Q}`)}return Z},b1=($,W)=>{if(typeof $==="string"&&$.length>W.maxStringLength)throw new Error(`String too long: ${$.length} characters exceeds limit of ${W.maxStringLength}`)},u1=($,W,Y)=>{if($.length>W.maxArrayLength)throw new Error(`Array too large: ${$.length} elements exceeds limit of ${W.maxArrayLength}`);for(let Z of $)B$(Z,W,Y+1)},y1=($,W)=>{if($.length>W.maxKeys)throw new Error(`Object has too many keys: ${$.length} exceeds limit of ${W.maxKeys}`);if(!W.allowPrototypeProperties){for(let Y of $)if(f$.includes(Y))throw _.warn("[SECURITY] Prototype pollution attempt detected",{property:Y,dangerousProperties:f$}),new Error(`Prototype pollution attempt detected: property '${Y}' is not allowed`)}},h1=($,W,Y)=>{let Z=Object.keys($);for(let D of Z){if(D.length>W.maxStringLength)throw new Error(`Object key too long: '${D.substring(0,50)}...' exceeds limit of ${W.maxStringLength}`);let Q=$[D];if(typeof Q==="string"&&Q.length>W.maxStringLength)throw new Error(`String value too long: property '${D}' has ${Q.length} characters, exceeds limit of ${W.maxStringLength}`);B$(Q,W,Y+1)}},B$=($,W,Y)=>{if(Y>W.maxDepth)throw _.warn("[SECURITY] JSON nesting too deep - potential stack overflow attack",{currentDepth:Y,maxDepth:W.maxDepth}),new Error(`JSON nesting too deep: current depth ${Y} exceeds maximum depth of ${W.maxDepth}`);if($===null||typeof $!=="object"){b1($,W);return}if(Array.isArray($)){u1($,W,Y);return}let Z=Object.keys($);y1(Z,W),h1($,W,Y)};var m1=($)=>{let W=$.startsWith(`\r
5
+ `)[1]?.length.toString()??"0"})}}}var c$=["__proto__","constructor","prototype"],r$=($,W)=>{if(!$||!$.trim()||$.trim()==="\x00")return;let Y=Buffer.byteLength($,"utf8");if(Y>W.maxSize)throw _.warn("[SECURITY] JSON request body too large",{size:Y,limit:W.maxSize,sizeMB:Math.round(Y/1024/1024)}),new Error(`Request body too large: ${Y} bytes exceeds limit of ${W.maxSize} bytes`);let Z=null;try{Z=JSON.parse($)}catch(D){let Q=D instanceof Error?D.message:String(D);throw new Error(`Invalid JSON syntax: ${Q}`)}try{A$(Z,W,1)}catch(D){let Q=D instanceof Error?D.message:String(D);throw new Error(`JSON security validation failed: ${Q}`)}return Z},m0=($,W)=>{if(typeof $==="string"&&$.length>W.maxStringLength)throw new Error(`String too long: ${$.length} characters exceeds limit of ${W.maxStringLength}`)},f0=($,W,Y)=>{if($.length>W.maxArrayLength)throw new Error(`Array too large: ${$.length} elements exceeds limit of ${W.maxArrayLength}`);for(let Z of $)A$(Z,W,Y+1)},l0=($,W)=>{if($.length>W.maxKeys)throw new Error(`Object has too many keys: ${$.length} exceeds limit of ${W.maxKeys}`);if(!W.allowPrototypeProperties){for(let Y of $)if(c$.includes(Y))throw _.warn("[SECURITY] Prototype pollution attempt detected",{property:Y,dangerousProperties:c$}),new Error(`Prototype pollution attempt detected: property '${Y}' is not allowed`)}},p0=($,W,Y)=>{let Z=Object.keys($);for(let D of Z){if(D.length>W.maxStringLength)throw new Error(`Object key too long: '${D.substring(0,50)}...' exceeds limit of ${W.maxStringLength}`);let Q=$[D];if(typeof Q==="string"&&Q.length>W.maxStringLength)throw new Error(`String value too long: property '${D}' has ${Q.length} characters, exceeds limit of ${W.maxStringLength}`);A$(Q,W,Y+1)}},A$=($,W,Y)=>{if(Y>W.maxDepth)throw _.warn("[SECURITY] JSON nesting too deep - potential stack overflow attack",{currentDepth:Y,maxDepth:W.maxDepth}),new Error(`JSON nesting too deep: current depth ${Y} exceeds maximum depth of ${W.maxDepth}`);if($===null||typeof $!=="object"){m0($,W);return}if(Array.isArray($)){f0($,W,Y);return}let Z=Object.keys($);l0(Z,W),p0($,W,Y)};var g0=($)=>{let W=$.startsWith(`\r
6
6
  `)?$.slice(2):$,Y=W.indexOf(`\r
7
7
  \r
8
- `);if(Y===-1)return["",""];let Z=W.slice(0,Y),D=W.slice(Y+4);return[Z,D]},f1=($)=>{let W={name:""},Y=/name=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec($),Z=/filename=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec($);if(Y)W.name=Y[1]??Y[2]??"";if(Z){let D=Z[1]??Z[2];if(D)W.filename=D}return W},p1=($)=>{let Y=$.split(/\r?\n/).find((Z)=>Z.toLowerCase().startsWith("content-type:"));if(!Y)return"application/octet-stream";return Y.slice(Y.indexOf(":")+1).trim().split(";")[0]?.trim()??"application/octet-stream"},l1=($)=>{return["image/","audio/","video/","application/octet-stream","application/pdf","application/zip","application/x-"].some((Y)=>$.toLowerCase().startsWith(Y))},g1=($)=>Buffer.isBuffer($)?$.length:Buffer.byteLength($,"utf8"),s1=($,W)=>{if(!W)return;if($.size>W.maxFileSize)throw _.warn("[SECURITY] File upload too large",{filename:$.filename,size:$.size,limit:W.maxFileSize,sizeMB:Math.round($.size/1024/1024)}),new Error(`File too large: ${$.filename} is ${$.size} bytes, exceeds limit of ${W.maxFileSize} bytes`);if($.filename&&$.filename.length>W.maxFilenameLength)throw new Error(`Filename too long: ${$.filename.length} characters exceeds limit of ${W.maxFilenameLength}`);if($.filename){let Y=$.filename.toLowerCase().substring($.filename.lastIndexOf("."));if(W.blockedExtensions.includes(Y))throw _.warn("[SECURITY] Blocked file type upload attempt",{filename:$.filename,extension:Y,blockedExtensions:W.blockedExtensions}),new Error(`File type not allowed: ${Y} files are blocked for security reasons`);if(W.allowedExtensions.length>0&&!W.allowedExtensions.includes(Y))throw new Error(`File type not allowed: ${Y} is not in the allowed extensions list`)}},c1=({contentDisposition:$,contentSection:W,headersSection:Y,config:Z})=>{let D=p1(Y),Q=W.endsWith(`\r
9
- `)?W.slice(0,-2):W,X=l1(D)?Buffer.from(Q,"binary"):Q,O={filename:$.filename??"",contentType:D,size:g1(X),content:X};return s1(O,Z),O},l$=($,W,Y)=>{let Z={fields:{},files:[]},D=$.split(`--${W}`).slice(1),Q=0;for(let X of D){if(!X||X.trim()===""||X.trim()==="--")continue;let[O,V]=m1(X);if(!O)continue;let w=O.split(/\r?\n/).find((L)=>L.toLowerCase().startsWith("content-disposition:"));if(!w)continue;let z=f1(w);if(!z.name)continue;if(z.filename!==void 0){if(Y&&Z.files.length>=Y.maxFiles)throw _.warn("[SECURITY] Too many files in upload request",{fileCount:Z.files.length,maxFiles:Y.maxFiles}),new Error(`Too many files: maximum of ${Y.maxFiles} files allowed per request`);let L=c1({contentDisposition:z,contentSection:V,headersSection:O,config:Y});if(Q+=L.size,Y&&Q>Y.maxTotalSize)throw _.warn("[SECURITY] Total upload size too large",{totalSize:Q,limit:Y.maxTotalSize,totalSizeMB:Math.round(Q/1024/1024)}),new Error(`Total file size too large: ${Q} bytes exceeds limit of ${Y.maxTotalSize} bytes`);Z.files.push(L)}if(z.filename===void 0){let L=V.endsWith(`\r
10
- `)?V.slice(0,-2):V;Z.fields[z.name]=L}}return Z};var r1=($,W)=>{if($.length>W.maxFields)throw new Error(`Too many form fields: ${$.length} exceeds limit of ${W.maxFields}`)},d1=($,W,Y)=>{if($.length>Y.maxFieldNameLength)throw new Error(`Form field name too long: ${$.length} characters exceeds limit of ${Y.maxFieldNameLength}`);if(W&&W.length>Y.maxFieldLength)throw new Error(`Form field value too long: field '${$}' has ${W.length} characters, exceeds limit of ${Y.maxFieldLength}`)},i1=($,W,Y)=>{if($.length>Y.maxFieldNameLength)throw new Error(`Decoded form field name too long: ${$.length} characters exceeds limit of ${Y.maxFieldNameLength}`);if(W.length>Y.maxFieldLength)throw new Error(`Decoded form field value too long: field '${$}' has ${W.length} characters, exceeds limit of ${Y.maxFieldLength}`)},a1=($,W,Y)=>{let[Z,D]=$.split("=");if(!Z)return;if(Y)d1(Z,D,Y);try{let Q=decodeURIComponent(Z),X=D?decodeURIComponent(D):"";if(Y)i1(Q,X,Y);W[Q]=X}catch(Q){if(Q instanceof Error&&Q.message.includes("exceeds limit"))throw Q;W[Z]=D??""}},g$=($,W)=>{let Y={},Z=$.split("&");if(W)r1(Z,W);for(let D of Z)a1(D,Y,W);return Y};var J$={JPEG:[255,216,255],PNG:[137,80,78,71],GIF87A:[71,73,70,56,55,97],GIF89A:[71,73,70,56,57,97],BMP:[66,77],TIFF_LE:[73,73,42,0],TIFF_BE:[77,77,0,42],WEBP:[82,73,70,70],ICO:[0,0,1,0],MP3_ID3:[73,68,51],MP3_FRAME:[255,251],WAV:[82,73,70,70],FLAC:[102,76,97,67],OGG:[79,103,103,83],MP4_FTYP:[0,0,0,24,102,116,121,112],MP4_FTYP_ALT:[0,0,0,28,102,116,121,112],AVI:[82,73,70,70],WEBM:[26,69,223,163],PDF:[37,80,68,70],ZIP:[80,75,3,4],ZIP_EMPTY:[80,75,5,6],ZIP_SPANNED:[80,75,7,8],RAR:[82,97,114,33,26,7,0],RAR5:[82,97,114,33,26,7,1,0],SEVENZ:[55,122,188,175,39,28],GZIP:[31,139],EXE:[77,90],ELF:[127,69,76,70],OFFICE_OLD:[208,207,17,224,161,177,26,225]},K$=($,W)=>{if($.length<W.length)return!1;return W.every((Y,Z)=>$[Z]===Y)},n1=($)=>{if(K$($,J$.WEBP)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="WEBP";if(K$($,J$.WAV)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="WAVE";if(K$($,J$.AVI)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="AVI ";return!1},G$=($,W)=>{if(!$)return t1(W);let Y=$.toLowerCase();if(Y.startsWith("image/")||Y.startsWith("video/")||Y.startsWith("audio/")||Y==="application/pdf"||Y==="application/octet-stream"||Y.startsWith("application/zip")||Y.startsWith("application/x-"))return"base64";if(Y.startsWith("text/")||Y.startsWith("application/json")||Y.startsWith("application/xml")||Y.startsWith("application/javascript"))return"utf8";return"binary"},t1=($)=>{if(Buffer.isBuffer($))return o1($)?"base64":"utf8";if(typeof $==="object"&&$!==null)return"utf8";if(typeof $==="string")return"utf8";return"utf8"},o1=($)=>{if($.length===0)return!1;let W=Object.values(J$);for(let D of W)if(K$($,D))return!0;if(n1($))return!0;let Y=$.filter((D)=>D===0).length,Z=$.filter((D)=>D<32&&D!==9&&D!==10&&D!==13).length;return Y/$.length>0.1||Z/$.length>0.3};var e1=($)=>{if(!($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")))return!1;try{return JSON.parse($),!0}catch{return!1}},$0=($)=>$.includes("=")&&$.includes("&"),W0=($)=>$.includes("boundary="),Y0=($)=>typeof $==="object"&&$!==null&&!Buffer.isBuffer($)&&!($ instanceof Uint8Array)&&!($ instanceof ArrayBuffer)&&!($ instanceof Date),Z0=($)=>$ instanceof Date,D0=($)=>{if(Buffer.isBuffer($))return $;return Buffer.from($)},Q0=($)=>{return G$(void 0,$)==="base64"?"application/octet-stream":"text/plain"},E$=($)=>{let W=$.trim();if(e1(W))return v.json;if($0(W))return v.form;if(W0(W))return v.multipart;return"text/plain"},s$=($)=>{if($===null||$===void 0)return"text/plain";if(Z0($))return"text/plain";if(Y0($))return v.json;if(typeof $==="string")return E$($);if(Buffer.isBuffer($)||$ instanceof Uint8Array||$ instanceof ArrayBuffer){let W=D0($);return Q0(W)}return"text/plain"};var X0=($,W,Y)=>{let Z=Buffer.byteLength($,"utf8");if(W===v.json){if(Z>Y.json.maxSize)throw new Error(`JSON body too large: ${Z} bytes exceeds limit of ${Y.json.maxSize} bytes`)}else if(W===v.form){if(Z>Y.urlEncoded.maxSize)throw new Error(`URL-encoded body too large: ${Z} bytes exceeds limit of ${Y.urlEncoded.maxSize} bytes`)}else if(W===v.multipart){if(Z>Y.fileUploads.maxTotalSize)throw new Error(`Multipart body too large: ${Z} bytes exceeds limit of ${Y.fileUploads.maxTotalSize} bytes`)}},c$=($,W={})=>{let{headerContentType:Y,boundary:Z,config:D}=W;if(!$||!$.trim())return;let Q=Y??E$($);if(D)X0($,Q,D);if(Q===v.json){if(!D)throw new Error("Body parser configuration is required for JSON parsing");return p$($,D.json)}if(Q===v.multipart){if(!Z)throw new Error("Invalid multipart form data: missing boundary");return l$($,Z,D?.fileUploads)}if(Q===v.form)return g$($,D?.urlEncoded);return $};var A$=($,W)=>{let Y=$.indexOf(W);if(Y===-1)return[$,""];let Z=$.slice(0,Y),D=$.slice(Y+W.length);return[Z,D]};var r$=($)=>{if(!$||!$.trim())return{method:"GET",path:"/",protocol:"HTTP/1.1",headersRaw:"",rawBody:""};let[W,Y]=A$($,`\r
11
- `),[Z,D,Q]=W.split(" ",3),[X,O]=A$(Y,`\r
8
+ `);if(Y===-1)return["",""];let Z=W.slice(0,Y),D=W.slice(Y+4);return[Z,D]},c0=($)=>{let W={name:""},Y=/name=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec($),Z=/filename=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec($);if(Y)W.name=Y[1]??Y[2]??"";if(Z){let D=Z[1]??Z[2];if(D)W.filename=D}return W},r0=($)=>{let Y=$.split(/\r?\n/).find((Z)=>Z.toLowerCase().startsWith("content-type:"));if(!Y)return"application/octet-stream";return Y.slice(Y.indexOf(":")+1).trim().split(";")[0]?.trim()??"application/octet-stream"},s0=($)=>{return["image/","audio/","video/","application/octet-stream","application/pdf","application/zip","application/x-"].some((Y)=>$.toLowerCase().startsWith(Y))},d0=($)=>Buffer.isBuffer($)?$.length:Buffer.byteLength($,"utf8"),i0=($,W)=>{if(!W)return;if($.size>W.maxFileSize)throw _.warn("[SECURITY] File upload too large",{filename:$.filename,size:$.size,limit:W.maxFileSize,sizeMB:Math.round($.size/1024/1024)}),new Error(`File too large: ${$.filename} is ${$.size} bytes, exceeds limit of ${W.maxFileSize} bytes`);if($.filename&&$.filename.length>W.maxFilenameLength)throw new Error(`Filename too long: ${$.filename.length} characters exceeds limit of ${W.maxFilenameLength}`);if($.filename){let Y=$.filename.toLowerCase().substring($.filename.lastIndexOf("."));if(W.blockedExtensions.includes(Y))throw _.warn("[SECURITY] Blocked file type upload attempt",{filename:$.filename,extension:Y,blockedExtensions:W.blockedExtensions}),new Error(`File type not allowed: ${Y} files are blocked for security reasons`);if(W.allowedExtensions.length>0&&!W.allowedExtensions.includes(Y))throw new Error(`File type not allowed: ${Y} is not in the allowed extensions list`)}},a0=({contentDisposition:$,contentSection:W,headersSection:Y,config:Z})=>{let D=r0(Y),Q=W.endsWith(`\r
9
+ `)?W.slice(0,-2):W,X=s0(D)?Buffer.from(Q,"binary"):Q,G={filename:$.filename??"",contentType:D,size:d0(X),content:X};return i0(G,Z),G},s$=($,W,Y)=>{let Z={fields:{},files:[]},D=$.split(`--${W}`).slice(1),Q=0;for(let X of D){if(!X||X.trim()===""||X.trim()==="--")continue;let[G,V]=g0(X);if(!G)continue;let q=G.split(/\r?\n/).find((L)=>L.toLowerCase().startsWith("content-disposition:"));if(!q)continue;let z=c0(q);if(!z.name)continue;if(z.filename!==void 0){if(Y&&Z.files.length>=Y.maxFiles)throw _.warn("[SECURITY] Too many files in upload request",{fileCount:Z.files.length,maxFiles:Y.maxFiles}),new Error(`Too many files: maximum of ${Y.maxFiles} files allowed per request`);let L=a0({contentDisposition:z,contentSection:V,headersSection:G,config:Y});if(Q+=L.size,Y&&Q>Y.maxTotalSize)throw _.warn("[SECURITY] Total upload size too large",{totalSize:Q,limit:Y.maxTotalSize,totalSizeMB:Math.round(Q/1024/1024)}),new Error(`Total file size too large: ${Q} bytes exceeds limit of ${Y.maxTotalSize} bytes`);Z.files.push(L)}if(z.filename===void 0){let L=V.endsWith(`\r
10
+ `)?V.slice(0,-2):V;Z.fields[z.name]=L}}return Z};var n0=($,W)=>{if($.length>W.maxFields)throw new Error(`Too many form fields: ${$.length} exceeds limit of ${W.maxFields}`)},t0=($,W,Y)=>{if($.length>Y.maxFieldNameLength)throw new Error(`Form field name too long: ${$.length} characters exceeds limit of ${Y.maxFieldNameLength}`);if(W&&W.length>Y.maxFieldLength)throw new Error(`Form field value too long: field '${$}' has ${W.length} characters, exceeds limit of ${Y.maxFieldLength}`)},o0=($,W,Y)=>{if($.length>Y.maxFieldNameLength)throw new Error(`Decoded form field name too long: ${$.length} characters exceeds limit of ${Y.maxFieldNameLength}`);if(W.length>Y.maxFieldLength)throw new Error(`Decoded form field value too long: field '${$}' has ${W.length} characters, exceeds limit of ${Y.maxFieldLength}`)},e0=($,W,Y)=>{let[Z,D]=$.split("=");if(!Z)return;if(Y)t0(Z,D,Y);try{let Q=decodeURIComponent(Z),X=D?decodeURIComponent(D):"";if(Y)o0(Q,X,Y);W[Q]=X}catch(Q){if(Q instanceof Error&&Q.message.includes("exceeds limit"))throw Q;W[Z]=D??""}},d$=($,W)=>{let Y={},Z=$.split("&");if(W)n0(Z,W);for(let D of Z)e0(D,Y,W);return Y};var K$={JPEG:[255,216,255],PNG:[137,80,78,71],GIF87A:[71,73,70,56,55,97],GIF89A:[71,73,70,56,57,97],BMP:[66,77],TIFF_LE:[73,73,42,0],TIFF_BE:[77,77,0,42],WEBP:[82,73,70,70],ICO:[0,0,1,0],MP3_ID3:[73,68,51],MP3_FRAME:[255,251],WAV:[82,73,70,70],FLAC:[102,76,97,67],OGG:[79,103,103,83],MP4_FTYP:[0,0,0,24,102,116,121,112],MP4_FTYP_ALT:[0,0,0,28,102,116,121,112],AVI:[82,73,70,70],WEBM:[26,69,223,163],PDF:[37,80,68,70],ZIP:[80,75,3,4],ZIP_EMPTY:[80,75,5,6],ZIP_SPANNED:[80,75,7,8],RAR:[82,97,114,33,26,7,0],RAR5:[82,97,114,33,26,7,1,0],SEVENZ:[55,122,188,175,39,28],GZIP:[31,139],EXE:[77,90],ELF:[127,69,76,70],OFFICE_OLD:[208,207,17,224,161,177,26,225]},M$=($,W)=>{if($.length<W.length)return!1;return W.every((Y,Z)=>$[Z]===Y)},$1=($)=>{if(M$($,K$.WEBP)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="WEBP";if(M$($,K$.WAV)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="WAVE";if(M$($,K$.AVI)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="AVI ";return!1},G$=($,W)=>{if(!$)return W1(W);let Y=$.toLowerCase();if(Y.startsWith("image/")||Y.startsWith("video/")||Y.startsWith("audio/")||Y==="application/pdf"||Y==="application/octet-stream"||Y.startsWith("application/zip")||Y.startsWith("application/x-"))return"base64";if(Y.startsWith("text/")||Y.startsWith("application/json")||Y.startsWith("application/xml")||Y.startsWith("application/javascript"))return"utf8";return"binary"},W1=($)=>{if(Buffer.isBuffer($))return Y1($)?"base64":"utf8";if(typeof $==="object"&&$!==null)return"utf8";if(typeof $==="string")return"utf8";return"utf8"},Y1=($)=>{if($.length===0)return!1;let W=Object.values(K$);for(let D of W)if(M$($,D))return!0;if($1($))return!0;let Y=$.filter((D)=>D===0).length,Z=$.filter((D)=>D<32&&D!==9&&D!==10&&D!==13).length;return Y/$.length>0.1||Z/$.length>0.3};var Z1=($)=>{if(!($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")))return!1;try{return JSON.parse($),!0}catch{return!1}},D1=($)=>$.includes("=")&&$.includes("&"),Q1=($)=>$.includes("boundary="),X1=($)=>typeof $==="object"&&$!==null&&!Buffer.isBuffer($)&&!($ instanceof Uint8Array)&&!($ instanceof ArrayBuffer)&&!($ instanceof Date),J1=($)=>$ instanceof Date,K1=($)=>{if(Buffer.isBuffer($))return $;return Buffer.from($)},M1=($)=>{return G$(void 0,$)==="base64"?"application/octet-stream":"text/plain"},z$=($)=>{let W=$.trim();if(Z1(W))return R.json;if(D1(W))return R.form;if(Q1(W))return R.multipart;return"text/plain"},i$=($)=>{if($===null||$===void 0)return"text/plain";if(J1($))return"text/plain";if(X1($))return R.json;if(typeof $==="string")return z$($);if(Buffer.isBuffer($)||$ instanceof Uint8Array||$ instanceof ArrayBuffer){let W=K1($);return M1(W)}return"text/plain"};var G1=($,W,Y)=>{let Z=Buffer.byteLength($,"utf8");if(W===R.json){if(Z>Y.json.maxSize)throw new Error(`JSON body too large: ${Z} bytes exceeds limit of ${Y.json.maxSize} bytes`)}else if(W===R.form){if(Z>Y.urlEncoded.maxSize)throw new Error(`URL-encoded body too large: ${Z} bytes exceeds limit of ${Y.urlEncoded.maxSize} bytes`)}else if(W===R.multipart){if(Z>Y.fileUploads.maxTotalSize)throw new Error(`Multipart body too large: ${Z} bytes exceeds limit of ${Y.fileUploads.maxTotalSize} bytes`)}},a$=($,W={})=>{let{headerContentType:Y,boundary:Z,config:D}=W;if(!$||!$.trim())return;let Q=Y??z$($);if(D)G1($,Q,D);if(Q===R.json){if(!D)throw new Error("Body parser configuration is required for JSON parsing");return r$($,D.json)}if(Q===R.multipart){if(!Z)throw new Error("Invalid multipart form data: missing boundary");return s$($,Z,D?.fileUploads)}if(Q===R.form)return d$($,D?.urlEncoded);return $};var S$=($,W)=>{let Y=$.indexOf(W);if(Y===-1)return[$,""];let Z=$.slice(0,Y),D=$.slice(Y+W.length);return[Z,D]};var n$=($)=>{if(!$||!$.trim())return{method:"GET",path:"/",protocol:"HTTP/1.1",headersRaw:"",rawBody:""};let[W,Y]=S$($,`\r
11
+ `),[Z,D,Q]=W.split(" ",3),[X,G]=S$(Y,`\r
12
12
  \r
13
- `);if(!Z||!Object.values(A).includes(Z))return{method:"GET",path:D??"/",protocol:Q??"HTTP/1.1",headersRaw:X,rawBody:O};return{method:Z,path:D??"/",protocol:Q??"HTTP/1.1",headersRaw:X,rawBody:O}};var d$=($)=>{if(!$)return{};if(!$.includes("?"))return{};let[,W]=$.split("?");if(!W)return{};let Y={},Z=W.split("&");for(let D of Z){let[Q,X]=D.split("=");if(Q)try{let O=decodeURIComponent(Q),V=X?decodeURIComponent(X):"";Y[O]=V}catch{Y[Q]=X??""}}return Y};var J0=[/^(?<classA>10)\./,/^(?<classB>172)\.(?<classBRange>1[6-9]|2[0-9]|3[0-1])\./,/^(?<classC>192)\.(?<classCRange>168)\./,/^(?<linkLocal>169)\.(?<linkLocalRange>254)\./,/^(?<loopback>127)\./,/^(?<ipv6Loopback>::1)$/,/^(?<ipv6LinkLocal>fe80):/i,/^(?<ipv6UniqueLocalFC>fc00):/i,/^(?<ipv6UniqueLocalFD>fd00):/i],i$=($)=>{if(!$||typeof $!=="string")return!1;let W=$.replace(/^\[|\]$/g,"");if(/^(?<octet>(?<highByte>25[0-5]|(?<midByte>2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/.test(W)){let D=W.split(".");return D.length===4&&D.every((Q)=>{let X=parseInt(Q,10);return X>=0&&X<=255})}if(W.includes("::")&&(W.match(/::/g)??[]).length>1)return!1;return/^(?<ipv6Address>(?<fullAddress>(?<hexQuad>[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4})|(?<compressedAddress>(?<leadingPart>[0-9a-fA-F]{1,4}:){1,7}:)|(?<mixedCompression>(?<frontPart>[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4})|(?<doubleColonOnly>::)|(?<linkLocal>fe80:(?<linkSuffix>:[0-9a-fA-F]{0,4}){0,4}(?<zoneId>%[0-9a-zA-Z]+)?)|(?<ipv4MappedFull>::ffff:(?<mappedIpv4>(?<mappedOctet>[0-9]{1,3}\.){3}[0-9]{1,3}))|(?<generalPattern>(?<segmentGroup>[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}))$/.test(W)},a$=($)=>{if(!$)return!1;let W=$.replace(/^\[|\]$/g,"");return J0.some((Y)=>Y.test(W))},n$=($,W)=>{if(!$||!W.length)return!1;if(W.includes("*"))return!0;return W.includes($)},K0=($,W)=>{if(!W.detectSpoofing||$.length<=1)return!1;if($.length>W.maxChainLength)return!0;if(new Set($).size!==$.length)return!0;let Z=$.filter(i$).length;if(Z>0&&Z<$.length)return!0;return!1},G0=($,W)=>{if($.length<=1)return!0;let Y=$[$.length-1];return Boolean(Y&&n$(Y,W.trustedProxies))},O0=($,W)=>{if(W==="x-forwarded-for")return $[0];return $[$.length-1]},M0=($)=>{let{clientIp:W,headerName:Y,ipChain:Z,config:D}=$,Q=a$(W),X=Y==="x-forwarded-for"?n$(Z[Z.length-1]??"",D.trustedProxies):!0;return{ip:W,isValid:!0,isPrivate:Q,source:Y,trusted:X}},U0=()=>({ip:"",isValid:!1,isPrivate:!1,source:"socket",trusted:!1}),j0=($,W)=>{for(let Y of W.headerPreference){let Z=$[Y];if(!Z)continue;let D=Z.split(",").map((O)=>O.trim()).filter(Boolean);if(D.length===0)continue;if(K0(D,W))continue;if(Y==="x-forwarded-for"&&!G0(D,W))continue;let Q=O0(D,Y);if(!Q||!i$(Q))continue;if(a$(Q)&&!W.allowPrivateIps)continue;return M0({clientIp:Q,headerName:Y,ipChain:D,config:W})}return U0()},F0=($,W,Y={})=>{let D={...$._configuration.ipSecurity,...Y},Q=j0(W,D);if(Q.isValid)return Q;return{ip:"",isValid:!1,isPrivate:!1,source:"socket",trusted:!1}},t$=($,W)=>{return F0($,W).ip};var o$=($)=>{if(!$)return;return/boundary\s*=\s*(?<temp1>[^;,\s]*)/i.exec($)?.[1]};var e$=($)=>{if(!$)return{};_0($);let W=V0($),Y=H0(W);return q0(Y)},_0=($)=>{if($.split(/\r\n|\r|\n/).length>100)throw new Error("Too many headers: maximum 100 allowed")},V0=($)=>{let W={},Z=$.replace(/\r\n|\r|\n/g,`
13
+ `);if(!Z||!Object.values(E).includes(Z))return{method:"GET",path:D??"/",protocol:Q??"HTTP/1.1",headersRaw:X,rawBody:G};return{method:Z,path:D??"/",protocol:Q??"HTTP/1.1",headersRaw:X,rawBody:G}};var t$=($)=>{if(!$)return{};if(!$.includes("?"))return{};let[,W]=$.split("?");if(!W)return{};let Y={},Z=W.split("&");for(let D of Z){let[Q,X]=D.split("=");if(Q)try{let G=decodeURIComponent(Q),V=X?decodeURIComponent(X):"";Y[G]=V}catch{Y[Q]=X??""}}return Y};var U1=[/^(?<classA>10)\./,/^(?<classB>172)\.(?<classBRange>1[6-9]|2[0-9]|3[0-1])\./,/^(?<classC>192)\.(?<classCRange>168)\./,/^(?<linkLocal>169)\.(?<linkLocalRange>254)\./,/^(?<loopback>127)\./,/^(?<ipv6Loopback>::1)$/,/^(?<ipv6LinkLocal>fe80):/i,/^(?<ipv6UniqueLocalFC>fc00):/i,/^(?<ipv6UniqueLocalFD>fd00):/i],o$=($)=>{if(!$||typeof $!=="string")return!1;let W=$.replace(/^\[|\]$/g,"");if(/^(?<octet>(?<highByte>25[0-5]|(?<midByte>2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/.test(W)){let D=W.split(".");return D.length===4&&D.every((Q)=>{let X=parseInt(Q,10);return X>=0&&X<=255})}if(W.includes("::")&&(W.match(/::/g)??[]).length>1)return!1;return/^(?<ipv6Address>(?<fullAddress>(?<hexQuad>[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4})|(?<compressedAddress>(?<leadingPart>[0-9a-fA-F]{1,4}:){1,7}:)|(?<mixedCompression>(?<frontPart>[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4})|(?<doubleColonOnly>::)|(?<linkLocal>fe80:(?<linkSuffix>:[0-9a-fA-F]{0,4}){0,4}(?<zoneId>%[0-9a-zA-Z]+)?)|(?<ipv4MappedFull>::ffff:(?<mappedIpv4>(?<mappedOctet>[0-9]{1,3}\.){3}[0-9]{1,3}))|(?<generalPattern>(?<segmentGroup>[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}))$/.test(W)},e$=($)=>{if(!$)return!1;let W=$.replace(/^\[|\]$/g,"");return U1.some((Y)=>Y.test(W))},$0=($,W)=>{if(!$||!W.length)return!1;if(W.includes("*"))return!0;return W.includes($)},F1=($,W)=>{if(!W.detectSpoofing||$.length<=1)return!1;if($.length>W.maxChainLength)return!0;if(new Set($).size!==$.length)return!0;let Z=$.filter(o$).length;if(Z>0&&Z<$.length)return!0;return!1},j1=($,W)=>{if($.length<=1)return!0;let Y=$[$.length-1];return Boolean(Y&&$0(Y,W.trustedProxies))},H1=($,W)=>{if(W==="x-forwarded-for")return $[0];return $[$.length-1]},_1=($)=>{let{clientIp:W,headerName:Y,ipChain:Z,config:D}=$,Q=e$(W),X=Y==="x-forwarded-for"?$0(Z[Z.length-1]??"",D.trustedProxies):!0;return{ip:W,isValid:!0,isPrivate:Q,source:Y,trusted:X}},w1=()=>({ip:"",isValid:!1,isPrivate:!1,source:"socket",trusted:!1}),O1=($,W)=>{for(let Y of W.headerPreference){let Z=$[Y];if(!Z)continue;let D=Z.split(",").map((G)=>G.trim()).filter(Boolean);if(D.length===0)continue;if(F1(D,W))continue;if(Y==="x-forwarded-for"&&!j1(D,W))continue;let Q=H1(D,Y);if(!Q||!o$(Q))continue;if(e$(Q)&&!W.allowPrivateIps)continue;return _1({clientIp:Q,headerName:Y,ipChain:D,config:W})}return w1()},V1=($,W,Y={})=>{let D={...$._configuration.ipSecurity,...Y},Q=O1(W,D);if(Q.isValid)return Q;return{ip:"",isValid:!1,isPrivate:!1,source:"socket",trusted:!1}},W0=($,W)=>{return V1($,W).ip};var Y0=($)=>{if(!$)return;return/boundary\s*=\s*(?<temp1>[^;,\s]*)/i.exec($)?.[1]};var Z0=($)=>{if(!$)return{};N1($);let W=q1($),Y=B1(W);return E1(Y)},N1=($)=>{if($.split(/\r\n|\r|\n/).length>100)throw new Error("Too many headers: maximum 100 allowed")},q1=($)=>{let W={},Z=$.replace(/\r\n|\r|\n/g,`
14
14
  `).split(`
15
- `);for(let D of Z){if(!D.trim())continue;let Q=D.indexOf(":");if(Q===-1)continue;let X=D.slice(0,Q).trim(),O=D.slice(Q+1).trim();if(!X)continue;if(!w0(X))throw new Error(`Invalid header name: ${X}`);if(X.length>200)throw new Error("Header name too long: maximum 200 characters allowed");if(O.length>8192)throw new Error("Header value too long: maximum 8192 characters allowed");W[X.toLowerCase()]=O}return W},H0=($)=>{let W={};for(let[Y,Z]of Object.entries($))W[Y]=N0(Z);return W},q0=($)=>$,w0=($)=>{return/^[a-zA-Z0-9!#$%&'*+\-.^_`|~]+$/.test($)},N0=($)=>{return $.replace(/[\x00-\x08\x0A-\x1F\x7F]/g,"")};class z${_rawRequest;_setup;method;path;protocol;headers;body;query;params;ipAddress;rawBody;constructor($,W,Y){this._rawRequest=$,this._setup=W,this.ipAddress=Y??"";let{method:Z,path:D,protocol:Q,headers:X,body:O,query:V,params:B,rawBody:w}=this._parseRequestIntoObject();this.method=Z,this.path=D,this.protocol=Q,this.headers=X,this.body=O,this.query=V??{},this.params=B??{},this.rawBody=w;let z=t$(this._setup,X);if(z)this.ipAddress=z}_parseRequestIntoObject(){let $=this._rawRequest.toString(),{method:W,path:Y,protocol:Z,headersRaw:D,rawBody:Q}=r$($),X=e$(D),O=X["content-type"],V=O?.split(";")[0]?.trim().toLowerCase(),B=o$(O);return{method:W,path:Y,protocol:Z,headers:X,body:c$(Q,{headerContentType:V,boundary:B,config:this._setup._configuration.bodyParser}),query:d$(Y),params:{},rawBody:Q}}}var D1=F$(D$(),1);var $1=($,W)=>{let Y=W?.encoding??"utf8";if($===null||$===void 0)return"";if(Buffer.isBuffer($))return S$($,Y);if($ instanceof Uint8Array)return B0($,Y);if($ instanceof ArrayBuffer)return E0($,Y);if(typeof $==="string")return $;if(typeof $==="object")return A0($);return String($)},S$=($,W)=>{if(W==="base64")return $.toString("base64");if(W==="binary")return $.toString("binary");return $.toString("utf8")},B0=($,W)=>{let Y=Buffer.from($);return S$(Y,W)},E0=($,W)=>{let Y=Buffer.from($);return S$(Y,W)},A0=($)=>{try{return JSON.stringify($)}catch(W){return String($)}};var W1=new Map;for(let[$,W]of Object.entries(b)){let Z=Q$[$];W1.set(W,Z)}var Y1=($)=>{let W=W1.get($);if(!W)throw new Error(`Unknown status code: ${$}`);return W};var z0=($,W)=>{if(typeof W!=="string")throw new Error(`Header value must be a string, got ${typeof W}`);if(W.includes("\r")||W.includes(`
16
- `))throw new Error(`Header value contains invalid line break characters: ${$}`);let Y=[/[\r\n](?:set-cookie|location|authorization|www-authenticate):/i,/\r\n\r\n|\n\n/,/[\r\n]http\/\d\.\d\s+\d+/i];for(let Z of Y)if(Z.test(W))throw new Error(`Header value contains suspicious injection pattern: ${$}`)},S0=($)=>{for(let[W,Y]of Object.entries($))z0(W,Y)},k$=($)=>{let W={};for(let[Y,Z]of Object.entries($))if(Z!==void 0)W[Y]=Z;return S0(W),W};var Z1=($,W)=>{if(!$)return"0";let Y=0;if(W===r.base64)Y=Buffer.byteLength($,"utf8");if(W===r.binary)Y=$.length;if(W===r.utf8)Y=Buffer.byteLength($,"utf8");return String(Y)};class I${_request;_statusCode=b.ok;_status=Q$.ok;_headers={};_body="";_stringBody="";_encoding=r.utf8;constructor($){this._request=$,this._setSecurityHeaders()}_parseResponseIntoString(){let $=`${this._request.protocol} ${this._statusCode} ${this._status}`,W=Object.entries(this._headers).map(([X,O])=>`${X}: ${O}`),Y=G$(this._headers["content-type"],this._body),Z=$1(this._body,{encoding:Y});this._encoding=Y;let D=W.length>0?`${W.join(`
15
+ `);for(let D of Z){if(!D.trim())continue;let Q=D.indexOf(":");if(Q===-1)continue;let X=D.slice(0,Q).trim(),G=D.slice(Q+1).trim();if(!X)continue;if(!A1(X))throw new Error(`Invalid header name: ${X}`);if(X.length>200)throw new Error("Header name too long: maximum 200 characters allowed");if(G.length>8192)throw new Error("Header value too long: maximum 8192 characters allowed");W[X.toLowerCase()]=G}return W},B1=($)=>{let W={};for(let[Y,Z]of Object.entries($))W[Y]=z1(Z);return W},E1=($)=>$,A1=($)=>{return/^[a-zA-Z0-9!#$%&'*+\-.^_`|~]+$/.test($)},z1=($)=>{return $.replace(/[\x00-\x08\x0A-\x1F\x7F]/g,"")};class k${_rawRequest;_setup;method;path;protocol;headers;body;query;params;ipAddress;rawBody;constructor($,W,Y){this._rawRequest=$,this._setup=W,this.ipAddress=Y??"";let{method:Z,path:D,protocol:Q,headers:X,body:G,query:V,params:A,rawBody:q}=this._parseRequestIntoObject();this.method=Z,this.path=D,this.protocol=Q,this.headers=X,this.body=G,this.query=V??{},this.params=A??{},this.rawBody=q;let z=W0(this._setup,X);if(z)this.ipAddress=z}_parseRequestIntoObject(){let $=this._rawRequest.toString(),{method:W,path:Y,protocol:Z,headersRaw:D,rawBody:Q}=n$($),X=Z0(D),G=X["content-type"],V=G?.split(";")[0]?.trim().toLowerCase(),A=Y0(G);return{method:W,path:Y,protocol:Z,headers:X,body:a$(Q,{headerContentType:V,boundary:A,config:this._setup._configuration.bodyParser}),query:t$(Y),params:{},rawBody:Q}}}var K0=w$(Q$(),1);var D0=($,W)=>{let Y=W?.encoding??"utf8";if($===null||$===void 0)return"";if(Buffer.isBuffer($))return I$($,Y);if($ instanceof Uint8Array)return S1($,Y);if($ instanceof ArrayBuffer)return k1($,Y);if(typeof $==="string")return $;if(typeof $==="object")return I1($);return String($)},I$=($,W)=>{if(W==="base64")return $.toString("base64");if(W==="binary")return $.toString("binary");return $.toString("utf8")},S1=($,W)=>{let Y=Buffer.from($);return I$(Y,W)},k1=($,W)=>{let Y=Buffer.from($);return I$(Y,W)},I1=($)=>{try{return JSON.stringify($)}catch(W){return String($)}};var Q0=new Map;for(let[$,W]of Object.entries(u)){let Z=X$[$];Q0.set(W,Z)}var X0=($)=>{let W=Q0.get($);if(!W)throw new Error(`Unknown status code: ${$}`);return W};var L1=($,W)=>{if(typeof W!=="string")throw new Error(`Header value must be a string, got ${typeof W}`);if(W.includes("\r")||W.includes(`
16
+ `))throw new Error(`Header value contains invalid line break characters: ${$}`);let Y=[/[\r\n](?:set-cookie|location|authorization|www-authenticate):/i,/\r\n\r\n|\n\n/,/[\r\n]http\/\d\.\d\s+\d+/i];for(let Z of Y)if(Z.test(W))throw new Error(`Header value contains suspicious injection pattern: ${$}`)},v1=($)=>{for(let[W,Y]of Object.entries($))L1(W,Y)},L$=($)=>{let W={};for(let[Y,Z]of Object.entries($))if(Z!==void 0)W[Y]=Z;return v1(W),W};var J0=($,W)=>{if(!$)return"0";let Y=0;if(W===d.base64)Y=Buffer.byteLength($,"utf8");if(W===d.binary)Y=$.length;if(W===d.utf8)Y=Buffer.byteLength($,"utf8");return String(Y)};class v${_request;_statusCode=u.ok;_status=X$.ok;_headers={};_body="";_stringBody="";_encoding=d.utf8;constructor($){this._request=$,this._setSecurityHeaders()}_parseResponseIntoString(){let $=`${this._request.protocol} ${this._statusCode} ${this._status}`,W=Object.entries(this._headers).map(([X,G])=>`${X}: ${G}`),Y=G$(this._headers["content-type"],this._body),Z=D0(this._body,{encoding:Y});this._encoding=Y;let D=W.length>0?`${W.join(`
17
17
  `)}
18
18
  `:"";this._stringBody=`${$}
19
19
  ${D}
20
- ${Z}`;let Q=Z1(this._stringBody,this._encoding);this._setHeadersIfNotSet({Date:D1.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":Q})}_setHeadersIfNotSet($){let W={};for(let[Z,D]of Object.entries($))if(D!==void 0&&!(Z in this._headers))W[Z]=D;let Y=k$(W);Object.assign(this._headers,Y)}_setBody($){if(this._body=$,!this._headers["content-type"]){let W=s$($);this._setHeadersIfNotSet({"Content-Type":W})}}setStatusCode($){this._statusCode=$,this._status=Y1($)}addHeaders($){let W=k$($);this._headers={...this._headers,...W}}removeHeaders($){for(let W of $)delete this._headers[W]}_setSecurityHeaders(){this._setHeadersIfNotSet({"X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"})}}class L${_request;_response;request;response;constructor($,W,Y){this._request=new z$($,W,Y),this._response=new I$(this._request),this.request=this._request,this.response=this._response}}var Q1={off:"off",error:"error",warn:"warn",info:"info"};var k0={enabled:!0,origin:"*",methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:"*",exposedHeaders:[],credentials:!1,maxAge:86400,preflightContinue:!1,optionsSuccessStatus:b.noContent},O$={json:{maxSize:262144,maxDepth:10,allowPrototypeProperties:!1,maxKeys:1000,maxStringLength:1048576,maxArrayLength:1e4},fileUploads:{maxFileSize:10485760,maxTotalSize:52428800,maxFiles:10,allowedExtensions:[],blockedExtensions:[".exe",".bat",".cmd",".scr",".pif",".com"],maxFilenameLength:255},urlEncoded:{maxSize:1048576,maxFields:1000,maxFieldNameLength:100,maxFieldLength:1048576}},X1={trustedProxies:["127.0.0.1","::1"],allowPrivateIps:!0,headerPreference:["x-forwarded-for","x-real-ip","cf-connecting-ip","x-client-ip","true-client-ip"],maxChainLength:10,detectSpoofing:!0},I0={port:5000,host:"0.0.0.0",logLevel:Q1.warn,networkLogs:!1,cors:{enabled:!1},bodyParser:O$,ipSecurity:X1,connectionOptions:{socketTimeout:30000,gracefulShutdownTimeout:30000,keepAliveTimeout:65000,headersTimeout:66000},autoGracefulShutdown:!0},L0=($)=>{if($.maxSize<1)throw new Error("bodyParser.json.maxSize must be at least 1 byte");if($.maxDepth<1)throw new Error("bodyParser.json.maxDepth must be at least 1");if($.maxKeys<1)throw new Error("bodyParser.json.maxKeys must be at least 1");if($.maxStringLength<1)throw new Error("bodyParser.json.maxStringLength must be at least 1 byte");if($.maxArrayLength<1)throw new Error("bodyParser.json.maxArrayLength must be at least 1")},T0=($)=>{if($.maxFileSize<1)throw new Error("bodyParser.fileUploads.maxFileSize must be at least 1 byte");if($.maxTotalSize<1)throw new Error("bodyParser.fileUploads.maxTotalSize must be at least 1 byte");if($.maxFiles<1)throw new Error("bodyParser.fileUploads.maxFiles must be at least 1");if($.maxFilenameLength<1)throw new Error("bodyParser.fileUploads.maxFilenameLength must be at least 1 character")},R0=($)=>{if($.maxSize<1)throw new Error("bodyParser.urlEncoded.maxSize must be at least 1 byte");if($.maxFields<1)throw new Error("bodyParser.urlEncoded.maxFields must be at least 1");if($.maxFieldNameLength<1)throw new Error("bodyParser.urlEncoded.maxFieldNameLength must be at least 1 character");if($.maxFieldLength<1)throw new Error("bodyParser.urlEncoded.maxFieldLength must be at least 1 byte")},v0=($)=>{if(!Array.isArray($.trustedProxies))throw new Error("ipSecurity.trustedProxies must be an array");if(!Array.isArray($.headerPreference))throw new Error("ipSecurity.headerPreference must be an array");if($.headerPreference.length===0)throw new Error("ipSecurity.headerPreference must contain at least one header");if($.maxChainLength<1)throw new Error("ipSecurity.maxChainLength must be at least 1");if($.maxChainLength>50)throw new Error("ipSecurity.maxChainLength must not exceed 50 to prevent DoS attacks")},P0=($)=>{if($.allowPrototypeProperties)_.warn("[SECURITY WARNING] bodyParser.json.allowPrototypeProperties is enabled. This allows prototype pollution attacks. Only enable this if you absolutely need it and have other protections in place.");if($.maxSize>10485760)_.warn(`[SECURITY WARNING] bodyParser.json.maxSize is set to ${$.maxSize} bytes (${Math.round($.maxSize/1024/1024)}MB). Large JSON payloads can cause memory exhaustion and DoS attacks. Consider if this size is necessary.`);if($.maxDepth>50)_.warn(`[SECURITY WARNING] bodyParser.json.maxDepth is set to ${$.maxDepth}. Very deep JSON nesting can cause stack overflow attacks. Consider if this depth is necessary.`)},x0=($)=>{if($.maxFileSize>104857600)_.warn(`[SECURITY WARNING] bodyParser.fileUploads.maxFileSize is set to ${$.maxFileSize} bytes (${Math.round($.maxFileSize/1024/1024)}MB). Large file uploads can consume significant server resources.`);if($.maxTotalSize>1073741824)_.warn(`[SECURITY WARNING] bodyParser.fileUploads.maxTotalSize is set to ${$.maxTotalSize} bytes (${Math.round($.maxTotalSize/1024/1024/1024)}GB). Very large total upload sizes can cause memory and disk space exhaustion.`);let W=[".exe",".bat",".cmd",".scr",".pif",".com",".vbs",".jar",".app"],Y=$.allowedExtensions.filter((Z)=>W.includes(Z.toLowerCase()));if(Y.length>0)_.warn(`[SECURITY WARNING] bodyParser.fileUploads.allowedExtensions includes dangerous file types: ${Y.join(", ")}. This could allow execution of malicious files. Only allow these if absolutely necessary.`);if($.blockedExtensions.length===0&&$.allowedExtensions.length===0)_.warn("[SECURITY WARNING] File uploads have no extension restrictions (no blockedExtensions and no allowedExtensions). Consider adding blockedExtensions or allowedExtensions to improve security.")},C0=($)=>{if($.trustedProxies.length===0)_.warn("[SECURITY WARNING] ipSecurity.trustedProxies is empty. No proxy headers will be trusted, which may prevent proper client IP detection.");if($.maxChainLength>20)_.warn(`[SECURITY WARNING] ipSecurity.maxChainLength is set to ${$.maxChainLength}. Very long proxy chains can consume significant resources and may indicate amplification attacks.`);if(!$.detectSpoofing)_.warn("[SECURITY WARNING] ipSecurity.detectSpoofing is disabled. This reduces protection against IP spoofing attacks. Only disable if you have other protective measures.")},b0=($,W)=>{if(W?.cors?.enabled)$.cors={...k0,...W.cors,enabled:!0}},u0=($,W)=>{if(W?.bodyParser)$.bodyParser={json:{...O$.json,...W.bodyParser.json},fileUploads:{...O$.fileUploads,...W.bodyParser.fileUploads},urlEncoded:{...O$.urlEncoded,...W.bodyParser.urlEncoded}},m0($.bodyParser)},y0=($,W)=>{if(W?.ipSecurity)$.ipSecurity={...X1,...W.ipSecurity},v0($.ipSecurity),C0($.ipSecurity)},h0=($,W)=>{if(W?.port!==void 0){let Y=Number(W.port);if(isNaN(Y)||Y<1||Y>65535)throw new Error("Invalid port number");$.port=Y}},m0=($)=>{L0($.json),T0($.fileUploads),R0($.urlEncoded),P0($.json),x0($.fileUploads)},J1=($)=>{let W={...I0};return Object.assign(W,$),b0(W,$),u0(W,$),y0(W,$),h0(W,$),W};class T${_beforeAll;_afterAll;_onError;_onNotFound;constructor(){this._beforeAll=new Set,this._afterAll=new Set,this._onError=($,W)=>{return _.error("Error while handeling your request: ",W),$.response.setStatusCode(b.internalServerError),{success:!1,message:"Internal Server Error"}},this._onNotFound=($)=>{return $.response.setStatusCode(b.notFound),{success:!1,message:"404 Not Found"}}}_addBeforeHooks($,W){for(let Y of $)this._beforeAll.add({handler:Y,options:W??{routesToExclude:[],routesToInclude:[]}})}_addAfterHooks($,W){for(let Y of $)this._afterAll.add({handler:Y,options:W??{routesToExclude:[],routesToInclude:[]}})}_addOnError($){this._onError=$}_addOnNotFound($){this._onNotFound=$}}var K1=($)=>{let W=[],Y=$.path.replace(/:\w+/g,(Z)=>{let D=Z.slice(1);return W.push(D),"([^/]+)"}).replace(/\//g,"\\/");return{...$,pattern:new RegExp(`^${Y}$`),paramNames:W,isParameterized:!0}};var R$=($)=>{let[W]=$.split("?");if(!W)return"";if([W]=W.split("#"),!W)return"";try{W=decodeURIComponent(W)}catch(Y){_.warn("Failed to decode URL path",{path:W})}if(W=W.startsWith("/")?W:`/${W}`,W=W.replace(/\/\/+/g,"/"),W=f0(W),W.length>1&&W.endsWith("/"))W=W.slice(0,-1);return W},f0=($)=>{let W=$.split("/"),Y=[];for(let D of W){if(D==="."||D===""){if(D===""&&Y.length===0)Y.push(D);continue}if(D===".."){if(Y.length>1)Y.pop()}else Y.push(D)}return Y.join("/")||"/"},v$=($)=>$.replace(/:\w+/g,":param");var G1=($)=>{let W=$.match(/:\w+/g);if(!W)return;let Y=W.map((D)=>D.slice(1)),Z=new Set(Y);if(Y.length!==Z.size){let D=Y.filter((Q,X)=>Y.indexOf(Q)!==X);throw new Error(`Route ${$} has duplicate parameter names: ${D.join(", ")}. Parameter names must be unique within a route for clarity and to prevent conflicts.`)}};class P${_exactRoutes=new Map;_parameterizedRoutes=new Map;_register({method:$,path:W,handler:Y,options:Z}){let D=R$(W),Q=D.includes(":");if(Q)G1(D);if(this._hasExactRoutePattern($,D))throw new Error(`Route ${D} already exists for method ${$}`);let X={method:$,path:D,handler:Y,options:Z,params:{}};if(Q)this._storeParameterizedRoute($,X);else this._storeExactRoute($,D,X)}_findRoute($,W){let Y=R$(W),Z=this._exactRoutes.get($)?.get(Y);if(Z)return Z;let D=this._findParameterizedRoute($,Y);if(D)return D;return}_hasExactRoutePattern($,W){if(this._exactRoutes.get($)?.has(W))return!0;if(W.includes(":")){let Y=v$(W),Z=this._parameterizedRoutes.get($);if(Z)return Z.some((D)=>v$(D.path)===Y)}else{let Y=this._parameterizedRoutes.get($);if(Y)return Y.some((Z)=>Z.path===W)}return!1}_storeExactRoute($,W,Y){if(!this._exactRoutes.has($))this._exactRoutes.set($,new Map);this._exactRoutes.get($)?.set(W,Y)}_storeParameterizedRoute($,W){if(!this._parameterizedRoutes.has($))this._parameterizedRoutes.set($,[]);let Y=K1(W);this._parameterizedRoutes.get($)?.push(Y)}_findParameterizedRoute($,W){let Y=this._parameterizedRoutes.get($);if(!Y)return;for(let Z of Y){let D=W.match(Z.pattern);if(D){let Q={};for(let X=0;X<Z.paramNames.length;X++){let O=D[X+1],V=Z.paramNames[X];if(O!==void 0&&V!==void 0)Q[V]=O}return{...Z,params:Q}}}return}}class x${_configuration;_routeRegistry=new P$;_hooks=new T$;constructor($){this._configuration=J1($)}get($,W,Y){let Z=Y??{beforeHooks:[],afterHooks:[]};this._routeRegistry._register({method:A.get,handler:W,path:$,options:Z,params:{}}),this._routeRegistry._register({method:A.head,handler:W,path:$,options:Z,params:{}})}head($,W,Y){this._routeRegistry._register({method:A.head,handler:W,path:$,options:Y??{beforeHooks:[],afterHooks:[]},params:{}})}post($,W,Y){this._routeRegistry._register({method:A.post,handler:W,path:$,options:Y??{beforeHooks:[],afterHooks:[]},params:{}})}put($,W,Y){this._routeRegistry._register({method:A.put,handler:W,path:$,options:Y??{beforeHooks:[],afterHooks:[]},params:{}})}patch($,W,Y){this._routeRegistry._register({method:A.patch,handler:W,path:$,options:Y??{beforeHooks:[],afterHooks:[]},params:{}})}delete($,W,Y){this._routeRegistry._register({method:A.delete,handler:W,path:$,options:Y??{beforeHooks:[],afterHooks:[]},params:{}})}options($,W,Y){this._routeRegistry._register({method:A.options,handler:W,path:$,options:Y??{beforeHooks:[],afterHooks:[]},params:{}})}group($,W,Y){let Z=(Q)=>(X,O,V)=>{let B=`${$}${X}`,w={beforeHooks:[...Y?.beforeHooks??[],...V?.beforeHooks??[]],afterHooks:[...V?.afterHooks??[],...Y?.afterHooks??[]]};if(this._routeRegistry._register({method:Q,handler:O,path:B,options:w,params:{}}),Q===A.get)this._routeRegistry._register({method:A.head,handler:O,path:B,options:w,params:{}})},D={get:Z(A.get),head:Z(A.head),post:Z(A.post),put:Z(A.put),delete:Z(A.delete),patch:Z(A.patch),options:Z(A.options)};W(D)}beforeAll($,W){this._hooks._addBeforeHooks($,W)}afterAll($,W){this._hooks._addAfterHooks($,W)}onError($){this._hooks._addOnError($)}onNotFound($){this._hooks._addOnNotFound($)}}class O1 extends x${_isListening=!1;_server;constructor($){super($);if(this._configuration.logger)_.setCustomLogger(this._configuration.logger);if(_.setLogLevel(this._configuration.logLevel),x.setEnabled(this._configuration.networkLogs),this._configuration.networkLogger)x.setNetworkLogger(this._configuration.networkLogger);if(_.info("YinzerFlow initialized with logging enabled",`${N.green}level: ${this._configuration.logLevel}, networkLogs: ${this._configuration.networkLogs}${N.reset}`),this._configuration.autoGracefulShutdown)this._setupGracefulShutdown()}_setupServer($,W,Y){if(!this._server)return;this._server.on("error",(Z)=>{x.serverError(this._configuration.port,this._configuration.host,Z.message),W(Z)}),this._server.on("listening",()=>{this._isListening=!0,x.serverStart(this._configuration.port,this._configuration.host),$()}),this._server.on("connection",(Z)=>{this._handleConnection(Z,Y)})}async _processRequest({data:$,socket:W,requestHandler:Y,clientAddress:Z}){let D=Date.now();_.info("Processing incoming request",`Client: ${Z}, Data Size: ${$.length}`);let Q=new L$($,this,Z);await Y.handle(Q),W.write(Q._response._stringBody),W.end();let X=Date.now(),O=X-D;if(x.request(Q,D,X),O>500)_.warn("Slow request detected",{method:Q.request.method,path:Q.request.path,statusCode:Q._response._statusCode,responseTime:`${O}ms`,clientAddress:Z})}_handleConnection($,W){let Y=$.remoteAddress??"unknown";x.connection("connect",Y),$.on("data",(Z)=>{this._processRequest({data:Z,socket:$,requestHandler:W,clientAddress:Y}).catch((D)=>{let Q=D instanceof Error?D.message:"Unknown error";x.connection("error",Y,`Unexpected error: ${Q}`),$.destroy()})}),$.on("error",(Z)=>{x.connection("error",Y,Z.message)}),$.on("close",()=>{x.connection("disconnect",Y)})}async listen(){if(this._isListening)throw new Error("Server is already listening");return new Promise(($,W)=>{let Y=new N$(this);this._server=p0(),this._setupServer($,W,Y),this._server.listen(this._configuration.port,this._configuration.host)})}async close(){if(!this._isListening||!this._server)return;return new Promise(($)=>{if(!this._server){this._isListening=!1,$();return}this._server.close(()=>{this._isListening=!1,x.serverStop(this._configuration.port,this._configuration.host),$()})})}status(){return{isListening:this._isListening,port:this._configuration.port,host:this._configuration.host}}_setupGracefulShutdown(){if(process.listenerCount("SIGTERM")===0&&process.listenerCount("SIGINT")===0){let $=(W)=>{_.info(`\uD83D\uDED1 Received ${W}, shutting down gracefully...`),this.close().then(()=>{_.info("✅ Server shut down gracefully"),process.exit(0)}).catch((Y)=>{_.error("❌ Error during graceful shutdown:",Y),process.exit(1)})};process.on("SIGTERM",()=>$("SIGTERM")),process.on("SIGINT",()=>$("SIGINT"))}}}export{_ as log,O1 as YinzerFlow};
20
+ ${Z}`;let Q=J0(this._stringBody,this._encoding);this._setHeadersIfNotSet({Date:K0.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":Q})}_setHeadersIfNotSet($){let W={};for(let[Z,D]of Object.entries($))if(D!==void 0&&!(Z in this._headers))W[Z]=D;let Y=L$(W);Object.assign(this._headers,Y)}_setBody($){if(this._body=$,!this._headers["content-type"]){let W=i$($);this._setHeadersIfNotSet({"Content-Type":W})}}setStatusCode($){this._statusCode=$,this._status=X0($)}addHeaders($){let W=L$($);this._headers={...this._headers,...W}}removeHeaders($){for(let W of $)delete this._headers[W]}_setSecurityHeaders(){this._setHeadersIfNotSet({"X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"})}}class T${_request;_response;request;response;state={};constructor($,W,Y){this._request=new k$($,W,Y),this._response=new v$(this._request),this.request=this._request,this.response=this._response}}var M0={off:"off",error:"error",warn:"warn",info:"info"};var T1={enabled:!0,origin:"*",methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:"*",exposedHeaders:[],credentials:!1,maxAge:86400,preflightContinue:!1,optionsSuccessStatus:u.noContent},U$={json:{maxSize:262144,maxDepth:10,allowPrototypeProperties:!1,maxKeys:1000,maxStringLength:1048576,maxArrayLength:1e4},fileUploads:{maxFileSize:10485760,maxTotalSize:52428800,maxFiles:10,allowedExtensions:[],blockedExtensions:[".exe",".bat",".cmd",".scr",".pif",".com"],maxFilenameLength:255},urlEncoded:{maxSize:1048576,maxFields:1000,maxFieldNameLength:100,maxFieldLength:1048576}},G0={trustedProxies:["127.0.0.1","::1"],allowPrivateIps:!0,headerPreference:["x-forwarded-for","x-real-ip","cf-connecting-ip","x-client-ip","true-client-ip"],maxChainLength:10,detectSpoofing:!0},R1={port:5000,host:"0.0.0.0",logLevel:M0.warn,networkLogs:!1,cors:{enabled:!1},bodyParser:U$,ipSecurity:G0,connectionOptions:{socketTimeout:30000,gracefulShutdownTimeout:30000,keepAliveTimeout:65000,headersTimeout:66000},autoGracefulShutdown:!0},P1=($)=>{if($.maxSize<1)throw new Error("bodyParser.json.maxSize must be at least 1 byte");if($.maxDepth<1)throw new Error("bodyParser.json.maxDepth must be at least 1");if($.maxKeys<1)throw new Error("bodyParser.json.maxKeys must be at least 1");if($.maxStringLength<1)throw new Error("bodyParser.json.maxStringLength must be at least 1 byte");if($.maxArrayLength<1)throw new Error("bodyParser.json.maxArrayLength must be at least 1")},x1=($)=>{if($.maxFileSize<1)throw new Error("bodyParser.fileUploads.maxFileSize must be at least 1 byte");if($.maxTotalSize<1)throw new Error("bodyParser.fileUploads.maxTotalSize must be at least 1 byte");if($.maxFiles<1)throw new Error("bodyParser.fileUploads.maxFiles must be at least 1");if($.maxFilenameLength<1)throw new Error("bodyParser.fileUploads.maxFilenameLength must be at least 1 character")},C1=($)=>{if($.maxSize<1)throw new Error("bodyParser.urlEncoded.maxSize must be at least 1 byte");if($.maxFields<1)throw new Error("bodyParser.urlEncoded.maxFields must be at least 1");if($.maxFieldNameLength<1)throw new Error("bodyParser.urlEncoded.maxFieldNameLength must be at least 1 character");if($.maxFieldLength<1)throw new Error("bodyParser.urlEncoded.maxFieldLength must be at least 1 byte")},b1=($)=>{if(!Array.isArray($.trustedProxies))throw new Error("ipSecurity.trustedProxies must be an array");if(!Array.isArray($.headerPreference))throw new Error("ipSecurity.headerPreference must be an array");if($.headerPreference.length===0)throw new Error("ipSecurity.headerPreference must contain at least one header");if($.maxChainLength<1)throw new Error("ipSecurity.maxChainLength must be at least 1");if($.maxChainLength>50)throw new Error("ipSecurity.maxChainLength must not exceed 50 to prevent DoS attacks")},u1=($)=>{if($.allowPrototypeProperties)_.warn("[SECURITY WARNING] bodyParser.json.allowPrototypeProperties is enabled. This allows prototype pollution attacks. Only enable this if you absolutely need it and have other protections in place.");if($.maxSize>10485760)_.warn(`[SECURITY WARNING] bodyParser.json.maxSize is set to ${$.maxSize} bytes (${Math.round($.maxSize/1024/1024)}MB). Large JSON payloads can cause memory exhaustion and DoS attacks. Consider if this size is necessary.`);if($.maxDepth>50)_.warn(`[SECURITY WARNING] bodyParser.json.maxDepth is set to ${$.maxDepth}. Very deep JSON nesting can cause stack overflow attacks. Consider if this depth is necessary.`)},y1=($)=>{if($.maxFileSize>104857600)_.warn(`[SECURITY WARNING] bodyParser.fileUploads.maxFileSize is set to ${$.maxFileSize} bytes (${Math.round($.maxFileSize/1024/1024)}MB). Large file uploads can consume significant server resources.`);if($.maxTotalSize>1073741824)_.warn(`[SECURITY WARNING] bodyParser.fileUploads.maxTotalSize is set to ${$.maxTotalSize} bytes (${Math.round($.maxTotalSize/1024/1024/1024)}GB). Very large total upload sizes can cause memory and disk space exhaustion.`);let W=[".exe",".bat",".cmd",".scr",".pif",".com",".vbs",".jar",".app"],Y=$.allowedExtensions.filter((Z)=>W.includes(Z.toLowerCase()));if(Y.length>0)_.warn(`[SECURITY WARNING] bodyParser.fileUploads.allowedExtensions includes dangerous file types: ${Y.join(", ")}. This could allow execution of malicious files. Only allow these if absolutely necessary.`);if($.blockedExtensions.length===0&&$.allowedExtensions.length===0)_.warn("[SECURITY WARNING] File uploads have no extension restrictions (no blockedExtensions and no allowedExtensions). Consider adding blockedExtensions or allowedExtensions to improve security.")},h1=($)=>{if($.trustedProxies.length===0)_.warn("[SECURITY WARNING] ipSecurity.trustedProxies is empty. No proxy headers will be trusted, which may prevent proper client IP detection.");if($.maxChainLength>20)_.warn(`[SECURITY WARNING] ipSecurity.maxChainLength is set to ${$.maxChainLength}. Very long proxy chains can consume significant resources and may indicate amplification attacks.`);if(!$.detectSpoofing)_.warn("[SECURITY WARNING] ipSecurity.detectSpoofing is disabled. This reduces protection against IP spoofing attacks. Only disable if you have other protective measures.")},m1=($,W)=>{if(W?.cors?.enabled)$.cors={...T1,...W.cors,enabled:!0}},f1=($,W)=>{if(W?.bodyParser)$.bodyParser={json:{...U$.json,...W.bodyParser.json},fileUploads:{...U$.fileUploads,...W.bodyParser.fileUploads},urlEncoded:{...U$.urlEncoded,...W.bodyParser.urlEncoded}},g1($.bodyParser)},l1=($,W)=>{if(W?.ipSecurity)$.ipSecurity={...G0,...W.ipSecurity},b1($.ipSecurity),h1($.ipSecurity)},p1=($,W)=>{if(W?.port!==void 0){let Y=Number(W.port);if(isNaN(Y)||Y<1||Y>65535)throw new Error("Invalid port number");$.port=Y}},g1=($)=>{P1($.json),x1($.fileUploads),C1($.urlEncoded),u1($.json),y1($.fileUploads)},U0=($)=>{let W={...R1};return Object.assign(W,$),m1(W,$),f1(W,$),l1(W,$),p1(W,$),W};class R${_beforeAll;_afterAll;_onError;_onNotFound;constructor(){this._beforeAll=new Set,this._afterAll=new Set,this._onError=($,W)=>{return _.error("Error while handeling your request: ",W),$.response.setStatusCode(u.internalServerError),{success:!1,message:"Internal Server Error"}},this._onNotFound=($)=>{return $.response.setStatusCode(u.notFound),{success:!1,message:"404 Not Found"}}}_addBeforeHooks($,W){this._validateHandlersArray($,"beforeAll");for(let Y of $)this._beforeAll.add({handler:Y,options:W??{routesToExclude:[],routesToInclude:[]}})}_addAfterHooks($,W){this._validateHandlersArray($,"afterAll");for(let Y of $)this._afterAll.add({handler:Y,options:W??{routesToExclude:[],routesToInclude:[]}})}_validateHandlersArray($,W){if(!Array.isArray($)){let Y=typeof $;throw new Error(`YinzerFlow: ${W}() expects an array of handler functions, but received ${Y}.${Y==="function"?`
21
21
 
22
- //# debugId=AEA4C27F898EB43E64756E2164756E21
22
+ Incorrect: app.${W}${w.red}(${w.reset}(ctx) => { ... }${w.red})${w.reset}
23
+ ✅ Correct: app.${W}${w.green}([${w.reset}(ctx) => { ... }${w.green}])${w.reset}
24
+
25
+ Note: Wrap your handler function in ${w.magenta}square brackets${w.reset} to make it an array.
26
+
27
+ `:`
28
+
29
+ Expected: Array<HandlerCallback>
30
+ Received: ${Y}`}`)}if($.length===0){_.warn(`${W}() called with empty array. No hooks will be registered.`);return}for(let Y=0;Y<$.length;Y++){let Z=$[Y];if(typeof Z!=="function")throw new Error(`YinzerFlow: ${W}() array contains non-function at index ${Y}. Expected: function, received: ${typeof Z}`)}}_addOnError($){this._onError=$}_addOnNotFound($){this._onNotFound=$}}var F0=($)=>{let W=[],Y=$.path.replace(/:\w+/g,(Z)=>{let D=Z.slice(1);return W.push(D),"([^/]+)"}).replace(/\//g,"\\/");return{...$,pattern:new RegExp(`^${Y}$`),paramNames:W,isParameterized:!0}};var P$=($)=>{let[W]=$.split("?");if(!W)return"";if([W]=W.split("#"),!W)return"";try{W=decodeURIComponent(W)}catch(Y){_.warn("Failed to decode URL path",{path:W})}if(W=W.startsWith("/")?W:`/${W}`,W=W.replace(/\/\/+/g,"/"),W=c1(W),W.length>1&&W.endsWith("/"))W=W.slice(0,-1);return W},c1=($)=>{let W=$.split("/"),Y=[];for(let D of W){if(D==="."||D===""){if(D===""&&Y.length===0)Y.push(D);continue}if(D===".."){if(Y.length>1)Y.pop()}else Y.push(D)}return Y.join("/")||"/"},x$=($)=>$.replace(/:\w+/g,":param");var j0=($)=>{let W=$.match(/:\w+/g);if(!W)return;let Y=W.map((D)=>D.slice(1)),Z=new Set(Y);if(Y.length!==Z.size){let D=Y.filter((Q,X)=>Y.indexOf(Q)!==X);throw new Error(`Route ${$} has duplicate parameter names: ${D.join(", ")}. Parameter names must be unique within a route for clarity and to prevent conflicts.`)}};class C${_exactRoutes=new Map;_parameterizedRoutes=new Map;_register({method:$,path:W,handler:Y,options:Z}){let D=P$(W),Q=D.includes(":");if(Q)j0(D);if(this._hasExactRoutePattern($,D))throw new Error(`Route ${D} already exists for method ${$}`);let X={method:$,path:D,handler:Y,options:Z,params:{}};if(Q)this._storeParameterizedRoute($,X);else this._storeExactRoute($,D,X)}_findRoute($,W){let Y=P$(W),Z=this._exactRoutes.get($)?.get(Y);if(Z)return Z;let D=this._findParameterizedRoute($,Y);if(D)return D;return}_hasExactRoutePattern($,W){if(this._exactRoutes.get($)?.has(W))return!0;if(W.includes(":")){let Y=x$(W),Z=this._parameterizedRoutes.get($);if(Z)return Z.some((D)=>x$(D.path)===Y)}else{let Y=this._parameterizedRoutes.get($);if(Y)return Y.some((Z)=>Z.path===W)}return!1}_storeExactRoute($,W,Y){if(!this._exactRoutes.has($))this._exactRoutes.set($,new Map);this._exactRoutes.get($)?.set(W,Y)}_storeParameterizedRoute($,W){if(!this._parameterizedRoutes.has($))this._parameterizedRoutes.set($,[]);let Y=F0(W);this._parameterizedRoutes.get($)?.push(Y)}_findParameterizedRoute($,W){let Y=this._parameterizedRoutes.get($);if(!Y)return;for(let Z of Y){let D=W.match(Z.pattern);if(D){let Q={};for(let X=0;X<Z.paramNames.length;X++){let G=D[X+1],V=Z.paramNames[X];if(G!==void 0&&V!==void 0)Q[V]=G}return{...Z,params:Q}}}return}}var b=($)=>({beforeHooks:$?.beforeHooks??[],afterHooks:$?.afterHooks??[]}),b$=($,W)=>({beforeHooks:[...$.beforeHooks??[],...W?.beforeHooks??[]],afterHooks:[...W?.afterHooks??[],...$.afterHooks??[]]}),u$=($,W)=>{let Y=$.endsWith("/")?$.slice(0,-1):$,Z=W.startsWith("/")?W:`/${W}`;return`${Y}${Z}`};class F${_setup;_prefix;_options;constructor($,W,Y){this._setup=$,this._prefix=W,this._options=b(Y)}_createRouteHandler($){return(W,Y,Z)=>{let D=u$(this._prefix,W),Q=b$(this._options,Z);if(this._setup._routeRegistry._register({method:$,handler:Y,path:D,options:Q,params:{}}),$===E.get)this._setup._routeRegistry._register({method:E.head,handler:Y,path:D,options:Q,params:{}})}}get=this._createRouteHandler(E.get);head=this._createRouteHandler(E.head);post=this._createRouteHandler(E.post);put=this._createRouteHandler(E.put);delete=this._createRouteHandler(E.delete);patch=this._createRouteHandler(E.patch);options=this._createRouteHandler(E.options);group($,W,Y){let Z=u$(this._prefix,$),D=b$(this._options,Y),Q=new F$(this._setup,Z,D);return W(Q),Q}}class y${_configuration;_routeRegistry=new C$;_hooks=new R$;constructor($){this._configuration=U0($)}get($,W,Y){let Z=b(Y);this._routeRegistry._register({method:E.get,handler:W,path:$,options:Z,params:{}}),this._routeRegistry._register({method:E.head,handler:W,path:$,options:Z,params:{}})}head($,W,Y){this._routeRegistry._register({method:E.head,handler:W,path:$,options:b(Y),params:{}})}post($,W,Y){this._routeRegistry._register({method:E.post,handler:W,path:$,options:b(Y),params:{}})}put($,W,Y){this._routeRegistry._register({method:E.put,handler:W,path:$,options:b(Y),params:{}})}patch($,W,Y){this._routeRegistry._register({method:E.patch,handler:W,path:$,options:b(Y),params:{}})}delete($,W,Y){this._routeRegistry._register({method:E.delete,handler:W,path:$,options:b(Y),params:{}})}options($,W,Y){this._routeRegistry._register({method:E.options,handler:W,path:$,options:b(Y),params:{}})}group($,W,Y){let Z=new F$(this,$,Y);return W(Z),Z}beforeAll($,W){this._hooks._addBeforeHooks($,W)}afterAll($,W){this._hooks._addAfterHooks($,W)}onError($){this._hooks._addOnError($)}onNotFound($){this._hooks._addOnNotFound($)}}class H0 extends y${_isListening=!1;_server;constructor($){super($);if(this._configuration.logger)_.setCustomLogger(this._configuration.logger);if(_.setLogLevel(this._configuration.logLevel),x.setEnabled(this._configuration.networkLogs),this._configuration.networkLogger)x.setNetworkLogger(this._configuration.networkLogger);if(_.info("YinzerFlow initialized with logging enabled",`${w.green}level: ${this._configuration.logLevel}, networkLogs: ${this._configuration.networkLogs}${w.reset}`),this._configuration.autoGracefulShutdown)this._setupGracefulShutdown()}_setupServer($,W,Y){if(!this._server)return;this._server.on("error",(Z)=>{x.serverError(this._configuration.port,this._configuration.host,Z.message),W(Z)}),this._server.on("listening",()=>{this._isListening=!0,x.serverStart(this._configuration.port,this._configuration.host),$()}),this._server.on("connection",(Z)=>{this._handleConnection(Z,Y)})}async _processRequest({data:$,socket:W,requestHandler:Y,clientAddress:Z}){let D=Date.now();_.info("Processing incoming request",`Client: ${Z}, Data Size: ${$.length}`);let Q=new T$($,this,Z);await Y.handle(Q),W.write(Q._response._stringBody),W.end();let X=Date.now(),G=X-D;if(x.request(Q,D,X),G>500)_.warn("Slow request detected",{method:Q.request.method,path:Q.request.path,statusCode:Q._response._statusCode,responseTime:`${G}ms`,clientAddress:Z})}_handleConnection($,W){let Y=$.remoteAddress??"unknown";x.connection("connect",Y),$.on("data",(Z)=>{this._processRequest({data:Z,socket:$,requestHandler:W,clientAddress:Y}).catch((D)=>{let Q=D instanceof Error?D.message:"Unknown error";x.connection("error",Y,`Unexpected error: ${Q}`),$.destroy()})}),$.on("error",(Z)=>{x.connection("error",Y,Z.message)}),$.on("close",()=>{x.connection("disconnect",Y)})}async listen(){if(this._isListening)throw new Error("Server is already listening");return new Promise(($,W)=>{let Y=new E$(this);this._server=r1(),this._setupServer($,W,Y),this._server.listen(this._configuration.port,this._configuration.host)})}async close(){if(!this._isListening||!this._server)return;return new Promise(($)=>{if(!this._server){this._isListening=!1,$();return}this._server.close(()=>{this._isListening=!1,x.serverStop(this._configuration.port,this._configuration.host),$()})})}status(){return{isListening:this._isListening,port:this._configuration.port,host:this._configuration.host}}_setupGracefulShutdown(){if(process.listenerCount("SIGTERM")===0&&process.listenerCount("SIGINT")===0){let $=(W)=>{_.info(`\uD83D\uDED1 Received ${W}, shutting down gracefully...`),this.close().then(()=>{_.info("✅ Server shut down gracefully"),process.exit(0)}).catch((Y)=>{_.error("❌ Error during graceful shutdown:",Y),process.exit(1)})};process.on("SIGTERM",()=>$("SIGTERM")),process.on("SIGINT",()=>$("SIGINT"))}}}export{_ as log,H0 as YinzerFlow};
31
+
32
+ //# debugId=C76EA9A23F53082C64756E2164756E21