veloce-ts 0.4.11 → 0.4.13

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.
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var h5=Object.create;var{getPrototypeOf:g5,defineProperty:g1,getOwnPropertyNames:o6,getOwnPropertyDescriptor:y5}=Object,s6=Object.prototype.hasOwnProperty;function r6($){return this[$]}var u5,l5,m5=($,Q,J)=>{var Y=$!=null&&typeof $==="object";if(Y){var X=Q?u5??=new WeakMap:l5??=new WeakMap,G=X.get($);if(G)return G}J=$!=null?h5(g5($)):{};let H=Q||!$||!$.__esModule?g1(J,"default",{value:$,enumerable:!0}):J;for(let W of o6($))if(!s6.call(H,W))g1(H,W,{get:r6.bind($,W),enumerable:!0});if(Y)X.set($,H);return H},i$=($)=>{var Q=(p6??=new WeakMap).get($),J;if(Q)return Q;if(Q=g1({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var Y of o6($))if(!s6.call(Q,Y))g1(Q,Y,{get:r6.bind($,Y),enumerable:!(J=y5($,Y))||J.enumerable})}return p6.set($,Q),Q},p6,o=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var c5=($)=>$;function d5($,Q){this[$]=c5.bind(null,Q)}var n0=($,Q)=>{for(var J in Q)g1($,J,{get:Q[J],enumerable:!0,configurable:!0,set:d5.bind(Q,J)})};var r=($,Q)=>()=>($&&(Q=$($=0)),Q);var $0=import.meta.require;var p$={};n0(p$,{HonoAdapter:()=>a6});class a6{hono;name="hono";runtime;constructor($){this.hono=$;this.runtime=n5()}listen($,Q){switch(this.runtime){case"bun":return this.listenBun($,Q);case"deno":return this.listenDeno($,Q);case"node":return this.listenNode($,Q);case"workerd":throw Error("Cloudflare Workers do not support listen(). Deploy using wrangler or export the handler with getHandler().");default:throw Error(`Unsupported runtime: ${this.runtime}. FastAPI-TS supports Bun, Node.js, Deno, and Cloudflare Workers.`)}}getHandler(){return this.hono.fetch}getRuntime(){return this.runtime}listenBun($,Q){let J=Bun.serve({port:$,fetch:this.hono.fetch});if(Q)Q();return{port:$,close:async()=>{J.stop()},...J}}listenDeno($,Q){let J=new AbortController;return Deno.serve({port:$,signal:J.signal,onListen:Q},this.hono.fetch),{port:$,close:async()=>{J.abort()}}}listenNode($,Q){try{let{serve:J}=(()=>{throw new Error("Cannot require module "+"@hono/node-server");})(),Y=J({fetch:this.hono.fetch,port:$},Q);return{port:$,close:async()=>{return new Promise((X)=>{Y.close(()=>X())})},...Y}}catch(J){throw Error("Node.js adapter requires @hono/node-server package. Install it with: npm install @hono/node-server")}}}var n5=()=>{if(typeof Bun<"u")return"bun";if(typeof Deno<"u")return"deno";if(typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers")return"workerd";if(typeof process<"u"&&process.versions&&process.versions.node)return"node";return"unknown"};var t6={};n0(t6,{ExpressAdapter:()=>o$});class o${veloceApp;name="express";expressApp;constructor($,Q){this.veloceApp=$;this.expressApp=Q??o$.createExpressApp(),this.setupBridge()}listen($,Q){return this.expressApp.listen($,Q)}getHandler(){return this.expressApp}getExpressApp(){return this.expressApp}static createExpressApp(){let $=$0,Q;try{Q=$("express")}catch{throw Error(`[ExpressAdapter] Could not load the "express" package.
2
+ var h5=Object.create;var{getPrototypeOf:g5,defineProperty:g1,getOwnPropertyNames:o6,getOwnPropertyDescriptor:y5}=Object,s6=Object.prototype.hasOwnProperty;function r6($){return this[$]}var u5,l5,m5=($,Q,J)=>{var Y=$!=null&&typeof $==="object";if(Y){var X=Q?u5??=new WeakMap:l5??=new WeakMap,G=X.get($);if(G)return G}J=$!=null?h5(g5($)):{};let H=Q||!$||!$.__esModule?g1(J,"default",{value:$,enumerable:!0}):J;for(let W of o6($))if(!s6.call(H,W))g1(H,W,{get:r6.bind($,W),enumerable:!0});if(Y)X.set($,H);return H},i$=($)=>{var Q=(p6??=new WeakMap).get($),J;if(Q)return Q;if(Q=g1({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var Y of o6($))if(!s6.call(Q,Y))g1(Q,Y,{get:r6.bind($,Y),enumerable:!(J=y5($,Y))||J.enumerable})}return p6.set($,Q),Q},p6,o=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var c5=($)=>$;function d5($,Q){this[$]=c5.bind(null,Q)}var n0=($,Q)=>{for(var J in Q)g1($,J,{get:Q[J],enumerable:!0,configurable:!0,set:d5.bind(Q,J)})};var r=($,Q)=>()=>($&&(Q=$($=0)),Q);var $0=import.meta.require;var p$={};n0(p$,{HonoAdapter:()=>a6});class a6{hono;name="hono";runtime;constructor($){this.hono=$;this.runtime=n5()}listen($,Q){switch(this.runtime){case"bun":return this.listenBun($,Q);case"deno":return this.listenDeno($,Q);case"node":return this.listenNode($,Q);case"workerd":throw Error("Cloudflare Workers do not support listen(). Deploy using wrangler or export the handler with getHandler().");default:throw Error(`Unsupported runtime: ${this.runtime}. FastAPI-TS supports Bun, Node.js, Deno, and Cloudflare Workers.`)}}getHandler(){return this.hono.fetch}getRuntime(){return this.runtime}listenBun($,Q){let J=this.hono,Y=Bun.serve({port:$,fetch(X,G){return J.fetch(X,{upgrade:G.upgrade.bind(G)})},websocket:{open(X){let{manager:G,metadata:H}=X.data??{};if(!G||!H)return;let W=G.handleConnectionBun(X,H);X.data._connection=W},message(X,G){let{manager:H,metadata:W,_connection:z}=X.data??{};if(!H||!W||!z)return;H.handleMessageBun(G,z,W)},close(X,G,H){let{manager:W,metadata:z,_connection:N}=X.data??{};if(!W||!z||!N)return;W.handleDisconnectBun(N,z)},error(X,G){console.error("[WS] Bun WebSocket error:",G)}}});if(Q)Q();return{port:$,close:async()=>{Y.stop()},...Y}}listenDeno($,Q){let J=new AbortController;return Deno.serve({port:$,signal:J.signal,onListen:Q},this.hono.fetch),{port:$,close:async()=>{J.abort()}}}listenNode($,Q){try{let{serve:J}=(()=>{throw new Error("Cannot require module "+"@hono/node-server");})(),Y=J({fetch:this.hono.fetch,port:$},Q);return{port:$,close:async()=>{return new Promise((X)=>{Y.close(()=>X())})},...Y}}catch(J){throw Error("Node.js adapter requires @hono/node-server package. Install it with: npm install @hono/node-server")}}}var n5=()=>{if(typeof Bun<"u")return"bun";if(typeof Deno<"u")return"deno";if(typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers")return"workerd";if(typeof process<"u"&&process.versions&&process.versions.node)return"node";return"unknown"};var t6={};n0(t6,{ExpressAdapter:()=>o$});class o${veloceApp;name="express";expressApp;constructor($,Q){this.veloceApp=$;this.expressApp=Q??o$.createExpressApp(),this.setupBridge()}listen($,Q){return this.expressApp.listen($,Q)}getHandler(){return this.expressApp}getExpressApp(){return this.expressApp}static createExpressApp(){let $=$0,Q;try{Q=$("express")}catch{throw Error(`[ExpressAdapter] Could not load the "express" package.
3
3
  Install it as a peer dependency: npm install express`)}return Q()}setupBridge(){let $=this.veloceApp.getHono();this.expressApp.use(async(Q,J,Y)=>{try{let X=this.toWebRequest(Q),G=await $.fetch(X);await this.writeExpressResponse(J,G)}catch(X){Y(X)}})}toWebRequest($){let Q=$.protocol??"http",J=$.get?.("host")??$.headers?.host??"localhost",Y=`${Q}://${J}${$.originalUrl??$.url}`,X=new Headers;for(let[H,W]of Object.entries($.headers??{}))if(typeof W==="string")X.set(H,W);else if(Array.isArray(W))W.forEach((z)=>X.append(H,z));let G={method:$.method,headers:X};if($.method!=="GET"&&$.method!=="HEAD"){if(Buffer.isBuffer($.body))G.body=$.body;else if($.body!==void 0&&$.body!==null){if(G.body=JSON.stringify($.body),!X.has("content-type"))X.set("content-type","application/json")}}return new Request(Y,G)}async writeExpressResponse($,Q){if($.status(Q.status),Q.headers.forEach((Y,X)=>{if(X.toLowerCase()!=="transfer-encoding")$.setHeader(X,Y)}),!Q.body){$.end();return}let J=Q.headers.get("content-type")??"";if(J.includes("application/json")){let Y=await Q.json();$.json(Y)}else if(J.startsWith("text/")){let Y=await Q.text();$.send(Y)}else{let Y=await Q.arrayBuffer();$.send(Buffer.from(Y))}}}var e6=()=>{};var r$=($,Q,J)=>{return(Y,X)=>{let G=-1;return H(0);async function H(W){if(W<=G)throw Error("next() called multiple times");G=W;let z,N=!1,V;if($[W])V=$[W][0][0],Y.req.routeIndex=W;else V=W===$.length&&X||void 0;if(V)try{z=await V(Y,()=>H(W+1))}catch(U){if(U instanceof Error&&Q)Y.error=U,z=await Q(U,Y),N=!0;else throw U}else if(Y.finalized===!1&&J)z=await J(Y);if(z&&(Y.finalized===!1||N))Y.res=z;return Y}}};var $4=()=>{};var Q4=()=>{};var J4;var Y4=r(()=>{J4=Symbol()});async function i5($,Q){let J=await $.formData();if(J)return p5(J,Q);return{}}function p5($,Q){let J=Object.create(null);if($.forEach((Y,X)=>{if(!(Q.all||X.endsWith("[]")))J[X]=Y;else o5(J,X,Y)}),Q.dot)Object.entries(J).forEach(([Y,X])=>{if(Y.includes("."))s5(J,Y,X),delete J[Y]});return J}var X4=async($,Q=Object.create(null))=>{let{all:J=!1,dot:Y=!1}=Q,G=($ instanceof B$?$.raw.headers:$.headers).get("Content-Type");if(G?.startsWith("multipart/form-data")||G?.startsWith("application/x-www-form-urlencoded"))return i5($,{all:J,dot:Y});return{}},o5=($,Q,J)=>{if($[Q]!==void 0)if(Array.isArray($[Q]))$[Q].push(J);else $[Q]=[$[Q],J];else if(!Q.endsWith("[]"))$[Q]=J;else $[Q]=[J]},s5=($,Q,J)=>{if(/(?:^|\.)__proto__\./.test(Q))return;let Y=$,X=Q.split(".");X.forEach((G,H)=>{if(H===X.length-1)Y[G]=J;else{if(!Y[G]||typeof Y[G]!=="object"||Array.isArray(Y[G])||Y[G]instanceof File)Y[G]=Object.create(null);Y=Y[G]}})};var G4=r(()=>{a$()});var e$=($)=>{let Q=$.split("/");if(Q[0]==="")Q.shift();return Q},H4=($)=>{let{groups:Q,path:J}=r5($),Y=e$(J);return a5(Y,Q)},r5=($)=>{let Q=[];return $=$.replace(/\{[^}]+\}/g,(J,Y)=>{let X=`@${Y}`;return Q.push([X,J]),X}),{groups:Q,path:$}},a5=($,Q)=>{for(let J=Q.length-1;J>=0;J--){let[Y]=Q[J];for(let X=$.length-1;X>=0;X--)if($[X].includes(Y)){$[X]=$[X].replace(Y,Q[J][1]);break}}return $},V$,W4=($,Q)=>{if($==="*")return"*";let J=$.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(J){let Y=`${$}#${Q}`;if(!V$[Y])if(J[2])V$[Y]=Q&&Q[0]!==":"&&Q[0]!=="*"?[Y,J[1],new RegExp(`^${J[2]}(?=/${Q})`)]:[$,J[1],new RegExp(`^${J[2]}$`)];else V$[Y]=[$,J[1],!0];return V$[Y]}return null},w1=($,Q)=>{try{return Q($)}catch{return $.replace(/(?:%[0-9A-Fa-f]{2})+/g,(J)=>{try{return Q(J)}catch{return J}})}},t5=($)=>w1($,decodeURI),$2=($)=>{let Q=$.url,J=Q.indexOf("/",Q.indexOf(":")+4),Y=J;for(;Y<Q.length;Y++){let X=Q.charCodeAt(Y);if(X===37){let G=Q.indexOf("?",Y),H=Q.indexOf("#",Y),W=G===-1?H===-1?void 0:H:H===-1?G:Math.min(G,H),z=Q.slice(J,W);return t5(z.includes("%25")?z.replace(/%25/g,"%2525"):z)}else if(X===63||X===35)break}return Q.slice(J,Y)},z4=($)=>{let Q=$2($);return Q.length>1&&Q.at(-1)==="/"?Q.slice(0,-1):Q},p0=($,Q,...J)=>{if(J.length)Q=p0(Q,...J);return`${$?.[0]==="/"?"":"/"}${$}${Q==="/"?"":`${$?.at(-1)==="/"?"":"/"}${Q?.[0]==="/"?Q.slice(1):Q}`}`},U$=($)=>{if($.charCodeAt($.length-1)!==63||!$.includes(":"))return null;let Q=$.split("/"),J=[],Y="";return Q.forEach((X)=>{if(X!==""&&!/\:/.test(X))Y+="/"+X;else if(/\:/.test(X))if(/\?/.test(X)){if(J.length===0&&Y==="")J.push("/");else J.push(Y);let G=X.replace("?","");Y+="/"+G,J.push(Y)}else Y+="/"+X}),J.filter((X,G,H)=>H.indexOf(X)===G)},t$=($)=>{if(!/[%+]/.test($))return $;if($.indexOf("+")!==-1)$=$.replace(/\+/g," ");return $.indexOf("%")!==-1?w1($,u1):$},N4=($,Q,J)=>{let Y;if(!J&&Q&&!/[%+]/.test(Q)){let H=$.indexOf("?",8);if(H===-1)return;if(!$.startsWith(Q,H+1))H=$.indexOf(`&${Q}`,H+1);while(H!==-1){let W=$.charCodeAt(H+Q.length+1);if(W===61){let z=H+Q.length+2,N=$.indexOf("&",z);return t$($.slice(z,N===-1?void 0:N))}else if(W==38||isNaN(W))return"";H=$.indexOf(`&${Q}`,H+1)}if(Y=/[%+]/.test($),!Y)return}let X={};Y??=/[%+]/.test($);let G=$.indexOf("?",8);while(G!==-1){let H=$.indexOf("&",G+1),W=$.indexOf("=",G);if(W>H&&H!==-1)W=-1;let z=$.slice(G+1,W===-1?H===-1?void 0:H:W);if(Y)z=t$(z);if(G=H,z==="")continue;let N;if(W===-1)N="";else if(N=$.slice(W+1,H===-1?void 0:H),Y)N=t$(N);if(J){if(!(X[z]&&Array.isArray(X[z])))X[z]=[];X[z].push(N)}else X[z]??=N}return Q?X[Q]:X},B4,V4=($,Q)=>{return N4($,Q,!0)},u1;var o0=r(()=>{V$={},B4=N4,u1=decodeURIComponent});var U4=($)=>w1($,u1),B$;var a$=r(()=>{Q4();Y4();G4();o0();B$=class{raw;#$;#Q;routeIndex=0;path;bodyCache={};constructor($,Q="/",J=[[]]){this.raw=$,this.path=Q,this.#Q=J,this.#$={}}param($){return $?this.#J($):this.#G()}#J($){let Q=this.#Q[0][this.routeIndex][1][$],J=this.#X(Q);return J&&/\%/.test(J)?U4(J):J}#G(){let $={},Q=Object.keys(this.#Q[0][this.routeIndex][1]);for(let J of Q){let Y=this.#X(this.#Q[0][this.routeIndex][1][J]);if(Y!==void 0)$[J]=/\%/.test(Y)?U4(Y):Y}return $}#X($){return this.#Q[1]?this.#Q[1][$]:$}query($){return B4(this.url,$)}queries($){return V4(this.url,$)}header($){if($)return this.raw.headers.get($)??void 0;let Q={};return this.raw.headers.forEach((J,Y)=>{Q[Y]=J}),Q}async parseBody($){return X4(this,$)}#Y=($)=>{let{bodyCache:Q,raw:J}=this,Y=Q[$];if(Y)return Y;let X=Object.keys(Q)[0];if(X)return Q[X].then((G)=>{if(X==="json")G=JSON.stringify(G);return new Response(G)[$]()});return Q[$]=J[$]()};json(){return this.#Y("text").then(($)=>JSON.parse($))}text(){return this.#Y("text")}arrayBuffer(){return this.#Y("arrayBuffer")}blob(){return this.#Y("blob")}formData(){return this.#Y("formData")}addValidatedData($,Q){this.#$[$]=Q}valid($){return this.#$[$]}get url(){return this.raw.url}get method(){return this.raw.method}get[J4](){return this.#Q}get matchedRoutes(){return this.#Q[0].map(([[,$]])=>$)}get routePath(){return this.#Q[0].map(([[,$]])=>$)[this.routeIndex].path}}});var _4,e5=($,Q)=>{let J=new String($);return J.isEscaped=!0,J.callbacks=Q,J},Q2=async($,Q,J,Y,X)=>{if(typeof $==="object"&&!($ instanceof String)){if(!($ instanceof Promise))$=$.toString();if($ instanceof Promise)$=await $}let G=$.callbacks;if(!G?.length)return Promise.resolve($);if(X)X[0]+=$;else X=[$];let H=Promise.all(G.map((W)=>W({phase:Q,buffer:X,context:Y}))).then((W)=>Promise.all(W.filter(Boolean).map((z)=>Q2(z,Q,!1,Y,X))).then(()=>X[0]));if(J)return e5(await H,G);else return H};var w4=r(()=>{_4={Stringify:1,BeforeStream:2,Stream:3}});var $7="text/plain; charset=UTF-8",J2=($,Q)=>{return{"Content-Type":$,...Q}},l1=($,Q)=>new Response($,Q),q4=class{#$;#Q;env={};#J;finalized=!1;error;#G;#X;#Y;#B;#z;#N;#W;#V;#U;constructor($,Q){if(this.#$=$,Q)this.#X=Q.executionCtx,this.env=Q.env,this.#N=Q.notFoundHandler,this.#U=Q.path,this.#V=Q.matchResult}get req(){return this.#Q??=new B$(this.#$,this.#U,this.#V),this.#Q}get event(){if(this.#X&&"respondWith"in this.#X)return this.#X;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#X)return this.#X;else throw Error("This context has no ExecutionContext")}get res(){return this.#Y||=l1(null,{headers:this.#W??=new Headers})}set res($){if(this.#Y&&$){$=l1($.body,$);for(let[Q,J]of this.#Y.headers.entries()){if(Q==="content-type")continue;if(Q==="set-cookie"){let Y=this.#Y.headers.getSetCookie();$.headers.delete("set-cookie");for(let X of Y)$.headers.append("set-cookie",X)}else $.headers.set(Q,J)}}this.#Y=$,this.finalized=!0}render=(...$)=>{return this.#z??=(Q)=>this.html(Q),this.#z(...$)};setLayout=($)=>this.#B=$;getLayout=()=>this.#B;setRenderer=($)=>{this.#z=$};header=($,Q,J)=>{if(this.finalized)this.#Y=l1(this.#Y.body,this.#Y);let Y=this.#Y?this.#Y.headers:this.#W??=new Headers;if(Q===void 0)Y.delete($);else if(J?.append)Y.append($,Q);else Y.set($,Q)};status=($)=>{this.#G=$};set=($,Q)=>{this.#J??=new Map,this.#J.set($,Q)};get=($)=>{return this.#J?this.#J.get($):void 0};get var(){if(!this.#J)return{};return Object.fromEntries(this.#J)}#H($,Q,J){let Y=this.#Y?new Headers(this.#Y.headers):this.#W??new Headers;if(typeof Q==="object"&&"headers"in Q){let G=Q.headers instanceof Headers?Q.headers:new Headers(Q.headers);for(let[H,W]of G)if(H.toLowerCase()==="set-cookie")Y.append(H,W);else Y.set(H,W)}if(J)for(let[G,H]of Object.entries(J))if(typeof H==="string")Y.set(G,H);else{Y.delete(G);for(let W of H)Y.append(G,W)}let X=typeof Q==="number"?Q:Q?.status??this.#G;return l1($,{status:X,headers:Y})}newResponse=(...$)=>this.#H(...$);body=($,Q,J)=>this.#H($,Q,J);text=($,Q,J)=>{return!this.#W&&!this.#G&&!Q&&!J&&!this.finalized?new Response($):this.#H($,Q,J2($7,J))};json=($,Q,J)=>{return this.#H(JSON.stringify($),Q,J2("application/json",J))};html=($,Q,J)=>{let Y=(X)=>this.#H(X,Q,J2("text/html; charset=UTF-8",J));return typeof $==="object"?Q2($,_4.Stringify,!1,{}).then(Y):Y($)};redirect=($,Q)=>{let J=String($);return this.header("Location",!/[^\x00-\xFF]/.test(J)?J:encodeURI(J)),this.newResponse(null,Q??302)};notFound=()=>{return this.#N??=()=>l1(),this.#N(this)}};var A4=r(()=>{a$();w4()});var a="ALL",D4="all",F4,_$="Can not add a route since the matcher is already built.",w$;var s0=r(()=>{F4=["get","post","put","delete","options","patch"],w$=class extends Error{}});var j4="__COMPOSED_HANDLER";var R4=()=>{};var Q7=($)=>{return $.text("404 Not Found",404)},E4=($,Q)=>{if("getResponse"in $){let J=$.getResponse();return Q.newResponse(J.body,J)}return console.error($),Q.text("Internal Server Error",500)},L4=class ${get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#$="/";routes=[];constructor(Q={}){[...F4,D4].forEach((G)=>{this[G]=(H,...W)=>{if(typeof H==="string")this.#$=H;else this.#G(G,this.#$,H);return W.forEach((z)=>{this.#G(G,this.#$,z)}),this}}),this.on=(G,H,...W)=>{for(let z of[H].flat()){this.#$=z;for(let N of[G].flat())W.map((V)=>{this.#G(N.toUpperCase(),this.#$,V)})}return this},this.use=(G,...H)=>{if(typeof G==="string")this.#$=G;else this.#$="*",H.unshift(G);return H.forEach((W)=>{this.#G(a,this.#$,W)}),this};let{strict:Y,...X}=Q;Object.assign(this,X),this.getPath=Y??!0?Q.getPath??$2:z4}#Q(){let Q=new $({router:this.router,getPath:this.getPath});return Q.errorHandler=this.errorHandler,Q.#J=this.#J,Q.routes=this.routes,Q}#J=Q7;errorHandler=E4;route(Q,J){let Y=this.basePath(Q);return J.routes.map((X)=>{let G;if(J.errorHandler===E4)G=X.handler;else G=async(H,W)=>(await r$([],J.errorHandler)(H,()=>X.handler(H,W))).res,G[j4]=X.handler;Y.#G(X.method,X.path,G)}),this}basePath(Q){let J=this.#Q();return J._basePath=p0(this._basePath,Q),J}onError=(Q)=>{return this.errorHandler=Q,this};notFound=(Q)=>{return this.#J=Q,this};mount(Q,J,Y){let X,G;if(Y)if(typeof Y==="function")G=Y;else if(G=Y.optionHandler,Y.replaceRequest===!1)X=(z)=>z;else X=Y.replaceRequest;let H=G?(z)=>{let N=G(z);return Array.isArray(N)?N:[N]}:(z)=>{let N=void 0;try{N=z.executionCtx}catch{}return[z.env,N]};X||=(()=>{let z=p0(this._basePath,Q),N=z==="/"?0:z.length;return(V)=>{let U=new URL(V.url);return U.pathname=U.pathname.slice(N)||"/",new Request(U,V)}})();let W=async(z,N)=>{let V=await J(X(z.req.raw),...H(z));if(V)return V;await N()};return this.#G(a,p0(Q,"*"),W),this}#G(Q,J,Y){Q=Q.toUpperCase(),J=p0(this._basePath,J);let X={basePath:this._basePath,path:J,method:Q,handler:Y};this.router.add(Q,J,[Y,X]),this.routes.push(X)}#X(Q,J){if(Q instanceof Error)return this.errorHandler(Q,J);throw Q}#Y(Q,J,Y,X){if(X==="HEAD")return(async()=>new Response(null,await this.#Y(Q,J,Y,"GET")))();let G=this.getPath(Q,{env:Y}),H=this.router.match(X,G),W=new q4(Q,{path:G,matchResult:H,env:Y,executionCtx:J,notFoundHandler:this.#J});if(H[0].length===1){let N;try{N=H[0][0][0][0](W,async()=>{W.res=await this.#J(W)})}catch(V){return this.#X(V,W)}return N instanceof Promise?N.then((V)=>V||(W.finalized?W.res:this.#J(W))).catch((V)=>this.#X(V,W)):N??this.#J(W)}let z=r$(H[0],this.errorHandler,this.#J);return(async()=>{try{let N=await z(W);if(!N.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return N.res}catch(N){return this.#X(N,W)}})()}fetch=(Q,...J)=>{return this.#Y(Q,J[1],J[0],Q.method)};request=(Q,J,Y,X)=>{if(Q instanceof Request)return this.fetch(J?new Request(Q,J):Q,Y,X);return Q=Q.toString(),this.fetch(new Request(/^https?:\/\//.test(Q)?Q:`http://localhost${p0("/",Q)}`,J),Y,X)};fire=()=>{addEventListener("fetch",(Q)=>{Q.respondWith(this.#Y(Q.request,Q,void 0,Q.request.method))})}};var M4=r(()=>{$4();A4();s0();R4();o0()});function q$($,Q){let J=this.buildAllMatchers(),Y=(X,G)=>{let H=J[X]||J[a],W=H[2][G];if(W)return W;let z=G.match(H[0]);if(!z)return[[],m1];let N=z.indexOf("",1);return[H[1][N],z]};return this.match=Y,Y($,Q)}var m1;var Y2=r(()=>{s0();m1=[]});function Y7($,Q){if($.length===1)return Q.length===1?$<Q?-1:1:-1;if(Q.length===1)return 1;if($===c1||$===d1)return 1;else if(Q===c1||Q===d1)return-1;if($===A$)return 1;else if(Q===A$)return-1;return $.length===Q.length?$<Q?-1:1:Q.length-$.length}var A$="[^/]+",c1=".*",d1="(?:|/.*)",r0,J7,O4=class ${#$;#Q;#J=Object.create(null);insert(Q,J,Y,X,G){if(Q.length===0){if(this.#$!==void 0)throw r0;if(G)return;this.#$=J;return}let[H,...W]=Q,z=H==="*"?W.length===0?["","",c1]:["","",A$]:H==="/*"?["","",d1]:H.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),N;if(z){let V=z[1],U=z[2]||A$;if(V&&z[2]){if(U===".*")throw r0;if(U=U.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(U))throw r0}if(N=this.#J[U],!N){if(Object.keys(this.#J).some((q)=>q!==c1&&q!==d1))throw r0;if(G)return;if(N=this.#J[U]=new $,V!=="")N.#Q=X.varIndex++}if(!G&&V!=="")Y.push([V,N.#Q])}else if(N=this.#J[H],!N){if(Object.keys(this.#J).some((V)=>V.length>1&&V!==c1&&V!==d1))throw r0;if(G)return;N=this.#J[H]=new $}N.insert(W,J,Y,X,G)}buildRegExpStr(){let J=Object.keys(this.#J).sort(Y7).map((Y)=>{let X=this.#J[Y];return(typeof X.#Q==="number"?`(${Y})@${X.#Q}`:J7.has(Y)?`\\${Y}`:Y)+X.buildRegExpStr()});if(typeof this.#$==="number")J.unshift(`#${this.#$}`);if(J.length===0)return"";if(J.length===1)return J[0];return"(?:"+J.join("|")+")"}};var X2=r(()=>{r0=Symbol(),J7=new Set(".\\+*[^]$()")});var S4=class{#$={varIndex:0};#Q=new O4;insert($,Q,J){let Y=[],X=[];for(let H=0;;){let W=!1;if($=$.replace(/\{[^}]+\}/g,(z)=>{let N=`@\\${H}`;return X[H]=[N,z],H++,W=!0,N}),!W)break}let G=$.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let H=X.length-1;H>=0;H--){let[W]=X[H];for(let z=G.length-1;z>=0;z--)if(G[z].indexOf(W)!==-1){G[z]=G[z].replace(W,X[H][1]);break}}return this.#Q.insert(G,Q,Y,this.#$,J),Y}buildRegExp(){let $=this.#Q.buildRegExpStr();if($==="")return[/^$/,[],[]];let Q=0,J=[],Y=[];return $=$.replace(/#(\d+)|@(\d+)|\.\*\$/g,(X,G,H)=>{if(G!==void 0)return J[++Q]=Number(G),"$()";if(H!==void 0)return Y[Number(H)]=++Q,"";return""}),[new RegExp(`^${$}`),J,Y]}};var C4=r(()=>{X2()});function K4($){return f4[$]??=new RegExp($==="*"?"":`^${$.replace(/\/\*$|([.\\+*[^\]$()])/g,(Q,J)=>J?`\\${J}`:"(?:|/.*)")}$`)}function G7(){f4=Object.create(null)}function H7($){let Q=new S4,J=[];if($.length===0)return X7;let Y=$.map((N)=>[!/\*|\/:/.test(N[0]),...N]).sort(([N,V],[U,q])=>N?1:U?-1:V.length-q.length),X=Object.create(null);for(let N=0,V=-1,U=Y.length;N<U;N++){let[q,F,B]=Y[N];if(q)X[F]=[B.map(([E])=>[E,Object.create(null)]),m1];else V++;let j;try{j=Q.insert(F,V,q)}catch(E){throw E===r0?new w$(F):E}if(q)continue;J[V]=B.map(([E,O])=>{let K=Object.create(null);O-=1;for(;O>=0;O--){let[f,Z]=j[O];K[f]=Z}return[E,K]})}let[G,H,W]=Q.buildRegExp();for(let N=0,V=J.length;N<V;N++)for(let U=0,q=J[N].length;U<q;U++){let F=J[N][U]?.[1];if(!F)continue;let B=Object.keys(F);for(let j=0,E=B.length;j<E;j++)F[B[j]]=W[F[B[j]]]}let z=[];for(let N in H)z[N]=J[H[N]];return[G,z,X]}function q1($,Q){if(!$)return;for(let J of Object.keys($).sort((Y,X)=>X.length-Y.length))if(K4(J).test(Q))return[...$[J]];return}var X7,f4,D$=class{name="RegExpRouter";#$;#Q;constructor(){this.#$={[a]:Object.create(null)},this.#Q={[a]:Object.create(null)}}add($,Q,J){let Y=this.#$,X=this.#Q;if(!Y||!X)throw Error(_$);if(!Y[$])[Y,X].forEach((W)=>{W[$]=Object.create(null),Object.keys(W[a]).forEach((z)=>{W[$][z]=[...W[a][z]]})});if(Q==="/*")Q="*";let G=(Q.match(/\/:/g)||[]).length;if(/\*$/.test(Q)){let W=K4(Q);if($===a)Object.keys(Y).forEach((z)=>{Y[z][Q]||=q1(Y[z],Q)||q1(Y[a],Q)||[]});else Y[$][Q]||=q1(Y[$],Q)||q1(Y[a],Q)||[];Object.keys(Y).forEach((z)=>{if($===a||$===z)Object.keys(Y[z]).forEach((N)=>{W.test(N)&&Y[z][N].push([J,G])})}),Object.keys(X).forEach((z)=>{if($===a||$===z)Object.keys(X[z]).forEach((N)=>W.test(N)&&X[z][N].push([J,G]))});return}let H=U$(Q)||[Q];for(let W=0,z=H.length;W<z;W++){let N=H[W];Object.keys(X).forEach((V)=>{if($===a||$===V)X[V][N]||=[...q1(Y[V],N)||q1(Y[a],N)||[]],X[V][N].push([J,G-z+W+1])})}}match=q$;buildAllMatchers(){let $=Object.create(null);return Object.keys(this.#Q).concat(Object.keys(this.#$)).forEach((Q)=>{$[Q]||=this.#J(Q)}),this.#$=this.#Q=void 0,G7(),$}#J($){let Q=[],J=$===a;if([this.#$,this.#Q].forEach((Y)=>{let X=Y[$]?Object.keys(Y[$]).map((G)=>[G,Y[$][G]]):[];if(X.length!==0)J||=!0,Q.push(...X);else if($!==a)Q.push(...Object.keys(Y[a]).map((G)=>[G,Y[a][G]]))}),!J)return null;else return H7(Q)}};var G2=r(()=>{s0();o0();Y2();X2();C4();X7=[/^$/,[],Object.create(null)],f4=Object.create(null)});var W7=class{name="PreparedRegExpRouter";#$;#Q;constructor($,Q){this.#$=$,this.#Q=Q}#J($,Q){let J=this.#$[$];J[1].forEach((Y)=>Y&&Y.push(Q)),Object.values(J[2]).forEach((Y)=>Y[0].push(Q))}#G($,Q,J,Y,X){let G=this.#$[$];if(!X)G[2][Q][0].push([J,{}]);else Y.forEach((H)=>{if(typeof H==="number")G[1][H].push([J,X]);else G[2][H||Q][0].push([J,X])})}add($,Q,J){if(!this.#$[$]){let X=this.#$[a],G={};for(let H in X[2])G[H]=[X[2][H][0].slice(),m1];this.#$[$]=[X[0],X[1].map((H)=>Array.isArray(H)?H.slice():0),G]}if(Q==="/*"||Q==="*"){let X=[J,{}];if($===a)for(let G in this.#$)this.#J(G,X);else this.#J($,X);return}let Y=this.#Q[Q];if(!Y)throw Error(`Path ${Q} is not registered`);for(let[X,G]of Y)if($===a)for(let H in this.#$)this.#G(H,Q,J,X,G);else this.#G($,Q,J,X,G)}buildAllMatchers(){return this.#$}match=q$};var P4=r(()=>{s0();Y2();G2()});var b4=r(()=>{G2();P4()});var H2=class{name="SmartRouter";#$=[];#Q=[];constructor($){this.#$=$.routers}add($,Q,J){if(!this.#Q)throw Error(_$);this.#Q.push([$,Q,J])}match($,Q){if(!this.#Q)throw Error("Fatal error");let J=this.#$,Y=this.#Q,X=J.length,G=0,H;for(;G<X;G++){let W=J[G];try{for(let z=0,N=Y.length;z<N;z++)W.add(...Y[z]);H=W.match($,Q)}catch(z){if(z instanceof w$)continue;throw z}this.match=W.match.bind(W),this.#$=[W],this.#Q=void 0;break}if(G===X)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,H}get activeRouter(){if(this.#Q||this.#$.length!==1)throw Error("No active router has been determined yet.");return this.#$[0]}};var I4=r(()=>{s0()});var T4=r(()=>{I4()});var n1,z7=($)=>{for(let Q in $)return!0;return!1},Z4=class ${#$;#Q;#J;#G=0;#X=n1;constructor(Q,J,Y){if(this.#Q=Y||Object.create(null),this.#$=[],Q&&J){let X=Object.create(null);X[Q]={handler:J,possibleKeys:[],score:0},this.#$=[X]}this.#J=[]}insert(Q,J,Y){this.#G=++this.#G;let X=this,G=H4(J),H=[];for(let W=0,z=G.length;W<z;W++){let N=G[W],V=G[W+1],U=W4(N,V),q=Array.isArray(U)?U[0]:N;if(q in X.#Q){if(X=X.#Q[q],U)H.push(U[1]);continue}if(X.#Q[q]=new $,U)X.#J.push(U),H.push(U[1]);X=X.#Q[q]}return X.#$.push({[Q]:{handler:Y,possibleKeys:H.filter((W,z,N)=>N.indexOf(W)===z),score:this.#G}}),X}#Y(Q,J,Y,X,G){for(let H=0,W=J.#$.length;H<W;H++){let z=J.#$[H],N=z[Y]||z[a],V={};if(N!==void 0){if(N.params=Object.create(null),Q.push(N),X!==n1||G&&G!==n1)for(let U=0,q=N.possibleKeys.length;U<q;U++){let F=N.possibleKeys[U],B=V[N.score];N.params[F]=G?.[F]&&!B?G[F]:X[F]??G?.[F],V[N.score]=!0}}}}search(Q,J){let Y=[];this.#X=n1;let G=[this],H=e$(J),W=[],z=H.length,N=null;for(let V=0;V<z;V++){let U=H[V],q=V===z-1,F=[];for(let j=0,E=G.length;j<E;j++){let O=G[j],K=O.#Q[U];if(K)if(K.#X=O.#X,q){if(K.#Q["*"])this.#Y(Y,K.#Q["*"],Q,O.#X);this.#Y(Y,K,Q,O.#X)}else F.push(K);for(let f=0,Z=O.#J.length;f<Z;f++){let u=O.#J[f],m=O.#X===n1?{}:{...O.#X};if(u==="*"){let Q0=O.#Q["*"];if(Q0)this.#Y(Y,Q0,Q,O.#X),Q0.#X=m,F.push(Q0);continue}let[i,s,g]=u;if(!U&&!(g instanceof RegExp))continue;let p=O.#Q[i];if(g instanceof RegExp){if(N===null){N=Array(z);let z0=J[0]==="/"?1:0;for(let Y0=0;Y0<z;Y0++)N[Y0]=z0,z0+=H[Y0].length+1}let Q0=J.substring(N[V]),e=g.exec(Q0);if(e){if(m[s]=e[0],this.#Y(Y,p,Q,O.#X,m),z7(p.#Q)){p.#X=m;let z0=e[0].match(/\//)?.length??0;(W[z0]||=[]).push(p)}continue}}if(g===!0||g.test(U))if(m[s]=U,q){if(this.#Y(Y,p,Q,m,O.#X),p.#Q["*"])this.#Y(Y,p.#Q["*"],Q,m,O.#X)}else p.#X=m,F.push(p)}}let B=W.shift();G=B?F.concat(B):F}if(Y.length>1)Y.sort((V,U)=>{return V.score-U.score});return[Y.map(({handler:V,params:U})=>[V,U])]}};var k4=r(()=>{s0();o0();n1=Object.create(null)});var W2=class{name="TrieRouter";#$;constructor(){this.#$=new Z4}add($,Q,J){let Y=U$(Q);if(Y){for(let X=0,G=Y.length;X<G;X++)this.#$.insert($,Y[X],J);return}this.#$.insert($,Q,J)}match($,Q){return this.#$.search($,Q)}};var x4=r(()=>{o0();k4()});var v4=r(()=>{x4()});var z2;var h4=r(()=>{M4();b4();T4();v4();z2=class extends L4{constructor($={}){super($);this.router=$.router??new H2({routers:[new D$,new W2]})}}});var g4=r(()=>{h4()});var u4=o(()=>{/*! *****************************************************************************
4
4
  Copyright (C) Microsoft. All rights reserved.
5
5
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -45,4 +45,4 @@ Body: ${X.text}`);let G={};if($.username)G.username=$.username;if($.email)G.emai
45
45
  `).map((H)=>H.trim()):void 0};if(this.format==="legacy"){let H={error:"Internal Server Error",statusCode:Y,message:X};if(this.isDevelopment){if(H.name=$.name,$.stack)H.stack=$.stack.split(`
46
46
  `).map((W)=>W.trim())}return Q.json(H,Y)}return R$(Q,G,Y,this.format)}isDevelopmentMode(){return this.isDevelopment}setDevelopmentMode($){this.isDevelopment=$}}class x6{plugins=new Map;installed=new Set;register($){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);this.plugins.set($.name,$)}async install($){let Q=this.resolveInstallOrder();for(let J of Q)await this.plugins.get(J).install($),this.installed.add(J)}isInstalled($){return this.installed.has($)}getPlugin($){return this.plugins.get($)}getPluginNames(){return Array.from(this.plugins.keys())}resolveInstallOrder(){let $=new Set,Q=new Set,J=[],Y=(X,G=[])=>{if(Q.has(X)){let W=[...G,X].join(" -> ");throw Error(`Circular dependency detected in plugins: ${W}`)}if($.has(X))return;Q.add(X);let H=this.plugins.get(X);if(!H)throw Error(`Plugin "${X}" is not registered`);if(H.dependencies)for(let W of H.dependencies){if(!this.plugins.has(W))throw Error(`Plugin "${X}" depends on "${W}" which is not registered`);Y(W,[...G,X])}Q.delete(X),$.add(X),J.push(X)};for(let X of this.plugins.keys())Y(X);return J}}function D5($){let{windowMs:Q=60000,max:J=100,keyGenerator:Y=(H)=>{let W=H.req.header("x-forwarded-for");if(W)return W.split(",")[0].trim();return H.req.header("x-real-ip")||"unknown"}}=$,X=new Map,G=setInterval(()=>{let H=Date.now();for(let[W,z]of X.entries())if(H>z.resetTime)X.delete(W)},Q);if(typeof process<"u"&&process.on)process.on("exit",()=>clearInterval(G));return async(H,W)=>{let z=Y(H),N=Date.now(),V=X.get(z);if(!V||N>V.resetTime)X.set(z,{count:1,resetTime:N+Q}),H.header("X-RateLimit-Limit",J.toString()),H.header("X-RateLimit-Remaining",(J-1).toString()),H.header("X-RateLimit-Reset",new Date(N+Q).toISOString()),await W();else if(V.count<J)V.count++,H.header("X-RateLimit-Limit",J.toString()),H.header("X-RateLimit-Remaining",(J-V.count).toString()),H.header("X-RateLimit-Reset",new Date(V.resetTime).toISOString()),await W();else{let U=Math.ceil((V.resetTime-N)/1000);return H.header("X-RateLimit-Limit",J.toString()),H.header("X-RateLimit-Remaining","0"),H.header("X-RateLimit-Reset",new Date(V.resetTime).toISOString()),H.header("Retry-After",U.toString()),H.json({error:"Too Many Requests",message:`Rate limit exceeded. Please try again in ${U} seconds.`,retryAfter:U},429)}}}function F5($){let{threshold:Q=1024,level:J=6}=$||{};return async(Y,X)=>{await X();let G=Y.res;if(!G)return;let H=G.headers.get("content-type")||"",W=G.headers.get("content-length"),z=Y.req.header("accept-encoding")||"";if(!["text/","application/json","application/javascript","application/xml","application/x-www-form-urlencoded"].some((B)=>H.toLowerCase().includes(B)))return;if(W&&parseInt(W)<Q)return;if(G.headers.get("content-encoding"))return;let U=await G.arrayBuffer();if(U.byteLength<Q)return;let q=null,F=null;if(!q&&z.includes("gzip")&&typeof CompressionStream<"u")try{let B=new CompressionStream("gzip"),j=B.writable.getWriter();j.write(new Uint8Array(U)),j.close();let E=B.readable.getReader(),O=[];while(!0){let{done:u,value:m}=await E.read();if(u)break;O.push(m)}let K=O.reduce((u,m)=>u+m.length,0),f=new Uint8Array(K),Z=0;for(let u of O)f.set(u,Z),Z+=u.length;q=f,F="gzip"}catch(B){q=null}if(q&&F&&q.byteLength<U.byteLength){let B=new Headers(G.headers);B.set("content-encoding",F),B.set("content-length",q.byteLength.toString()),B.delete("content-length");let j=new Response(q,{status:G.status,statusText:G.statusText,headers:B});Y.res=j;return}}}function $N(){return async($,Q)=>{let J=Z6({context:"request",method:$.req.method,path:$.req.path,ip:$.req.header("x-forwarded-for")||$.req.header("x-real-ip")||"unknown"}),Y=Date.now();J.info("Incoming request");try{await Q();let X=Date.now()-Y;J.info("Request completed",{status:$.res.status,duration:`${X}ms`})}catch(X){let G=Date.now()-Y;throw J.error("Request failed",X,{status:X.status||500,duration:`${G}ms`}),X}}}function QN(){return async($,Q)=>{try{await Q()}catch(J){throw Z6({context:"error"}).error("Unhandled error",J,{method:$.req.method,path:$.req.path,query:$.req.query(),headers:Object.fromEntries(new Map($.req.raw.headers))}),J}}}class v6{hono;metadata;container;validator;errorHandler;compiler;pluginManager;config;compiled=!1;globalMiddleware=[];groupPrefix="";constructor($){if(this.config={adapter:"hono",title:"Veloce-TS API",version:"1.0.0",docs:!0,...$},this.hono=new z2,this.metadata=new f0,this.container=new E2,this.validator=new u2,this.errorHandler=new k6(void 0,{errorResponseFormat:this.config.errorResponseFormat}),this.pluginManager=new x6,this.compiler=new v2(this.hono,this.metadata,this.container,this.validator,this.errorHandler),this.config.cors)if(this.config.cors===!0)this.useCors();else this.useCors(this.config.cors)}include($){let Q=f0.getControllerMetadata($);if(Q)this.metadata.registerController($,Q);let J=f0.getRouteMethods($);for(let Y of J){let X=f0.getRouteMetadata($.prototype,Y),G=f0.getParameterMetadata($.prototype,Y),H=f0.getDependencyMetadata($.prototype,Y);if(X&&X.method&&X.path!==void 0){let W=Q?.prefix||"",z=this.normalizePath(W,X.path);this.metadata.registerRoute({...X,target:$,propertyKey:Y,method:X.method,path:z,middleware:[...Q?.middleware||[],...X.middleware||[]],parameters:G||X.parameters||[],dependencies:H||X.dependencies||[],responses:X.responses||[],docs:X.docs})}}}get($,Q){this.registerFunctionalRoute("GET",$,Q)}post($,Q){this.registerFunctionalRoute("POST",$,Q)}put($,Q){this.registerFunctionalRoute("PUT",$,Q)}delete($,Q){this.registerFunctionalRoute("DELETE",$,Q)}patch($,Q){this.registerFunctionalRoute("PATCH",$,Q)}route($){return new R5(this,$)}group($,Q){let J=this.groupPrefix;this.groupPrefix=this.normalizePath(this.groupPrefix,$),Q(),this.groupPrefix=J}registerFunctionalRoute($,Q,J){let Y=this.normalizePath(this.groupPrefix,Q),X={target:j5,propertyKey:`${$.toLowerCase()}_${Y}`,method:$,path:Y,middleware:J.middleware||[],parameters:this.extractParametersFromSchema(J.schema),dependencies:[],responses:J.responses||[],docs:J.docs,handler:J.handler};this.metadata.registerRoute(X)}extractParametersFromSchema($){let Q=[],J=0;if($?.body)Q.push({index:J++,type:"body",schema:$.body,required:!0});if($?.query)Q.push({index:J++,type:"query",schema:$.query,required:!1});if($?.params)Q.push({index:J++,type:"param",schema:$.params,required:!0});if($?.headers)Q.push({index:J++,type:"header",schema:$.headers,required:!1});return Q}use($){this.globalMiddleware.push($),this.hono.use("*",$)}useCors($){let Q=A5($);this.use(Q)}useRateLimit($){let Q=D5($);this.use(Q)}useCompression($){let Q=F5($);this.use(Q)}usePlugin($){this.pluginManager.register($)}getPluginManager(){return this.pluginManager}onError($){this.errorHandler.setCustomHandler($)}getErrorHandler(){return this.errorHandler}normalizePath(...$){let Q=$.filter((J)=>J!=="").join("/").replace(/\/+/g,"/").replace(/\/$/,"");return Q.startsWith("/")?Q:`/${Q}`}getHono(){return this.hono}getMetadata(){return this.metadata}getContainer(){return this.container}getCompiler(){return this.compiler}getConfig(){return this.config}isCompiled(){return this.compiled}markCompiled(){this.compiled=!0}async compile(){if(this.compiled){console.warn("Routes have already been compiled. Skipping compilation.");return}await this.pluginManager.install(this),this.compiler.compile(),this.compiled=!0}serverInstance=null;shutdownHandlersRegistered=!1;async listen($,Q){if(!this.compiled)await this.compile();let J=this.createAdapter();return this.serverInstance=J.listen($,Q),this.setupGracefulShutdown(),this.serverInstance}setupGracefulShutdown(){if(typeof process>"u")return;if(this.shutdownHandlersRegistered)return;this.shutdownHandlersRegistered=!0;let $=async(Q)=>{let J=B1().child({component:"app"});if(J.info(`Received ${Q}, starting graceful shutdown...`),this.serverInstance&&typeof this.serverInstance.close==="function")try{await Promise.resolve(this.serverInstance.close()),J.info("Server closed gracefully")}catch(Y){J.error("Error during shutdown",Y)}process.exit(0)};process.on("SIGTERM",()=>$("SIGTERM")),process.on("SIGINT",()=>$("SIGINT"))}async shutdown(){if(this.serverInstance&&typeof this.serverInstance.close==="function")await Promise.resolve(this.serverInstance.close()),this.serverInstance=null}createAdapter(){let $=this.config.adapter||"hono";switch($){case"hono":{let{HonoAdapter:Q}=i$(p$);return new Q(this.hono)}case"express":{let{ExpressAdapter:Q}=(e6(),i$(t6));return new Q(this)}case"native":{let{HonoAdapter:Q}=i$(p$);return new Q(this.hono)}default:throw Error(`Unknown adapter type: ${$}. Supported adapters: 'hono', 'express', 'native'`)}}}class j5{}class R5{app;path;constructor($,Q){this.app=$;this.path=Q}get($){return this.app.get(this.path,$),this}post($){return this.app.post(this.path,$),this}put($){return this.app.put(this.path,$),this}delete($){return this.app.delete(this.path,$),this}patch($){return this.app.patch(this.path,$),this}}function E5($){let Q={docs:!1,cors:!1,...$};return new v6(Q)}function IG($,Q,J,Y){let X=$.getContainer(),G=typeof J==="function"?J:()=>J;X.register(Q,{scope:Y?.scope||"singleton",factory:G})}function L5($){return new y1($)}async function TG($,Q){let J=E5(Q);await $(J),await J.compile();let Y=L5(J);return{app:J,client:Y}}function ZG($){$.getContainer().clear()}export{TG as setupTestApp,IG as mockDependency,L5 as createTestClient,E5 as createTestApp,ZG as clearMocks,s$ as TestResponse,y1 as TestClient};
47
47
 
48
- //# debugId=8104D8C2F871B5E064756E2164756E21
48
+ //# debugId=CEA603C9D30FE05D64756E2164756E21