UNPKG

@lunora/cli

Version:

The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands

2 lines (1 loc) 883 B
const d="/_lunora/health",H="/_lunora/health/ready",f=(t,e=d)=>(t.endsWith("/")?t.slice(0,-1):t)+e,u=async(t,e,i)=>{let n={error:`health probe failed: no health path configured for ${t}`,url:t};for(const[l,h]of e.entries()){const r=f(t,h);let o;try{o=await i(r)}catch(a){const s=a instanceof Error?a.message:String(a);return{error:`health probe failed: could not reach ${r} (${s})`,url:r}}if(o.ok)return{url:r};if(n={error:`health probe failed: ${r} returned HTTP ${String(o.status)}`,url:r},o.status!==404||l===e.length-1)return n}return n},p=async t=>new Promise(e=>{setTimeout(e,t)}),g=async({attempts:t=1,baseUrl:e,delayMs:i=2e3,fetchImpl:n,paths:l=[d],sleep:h=p,timeoutMs:r=1e4})=>{const o=n??(c=>fetch(c,{signal:AbortSignal.timeout(r)})),a=Math.max(1,t);let s=await u(e,l,o);for(let c=1;c<a&&s.error!==void 0;c+=1)await h(i),s=await u(e,l,o);return s};export{H,d as a,g as p};