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