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) • 897 B
import{readLiveDevServerState as c}from"@lunora/config";import{LunoraError as i}from"@lunora/errors";const a=new Set(["127.0.0.1","::1","[::1]","localhost"]),h=/\/$/u,n="http://localhost:8787",l=r=>r===void 0?n:c(r)?.url??n,u=r=>r.replace(h,""),v=(r,s,e)=>{const o=r??l(e);let t;try{t=new URL(o)}catch{s.error(`invalid --url: ${o}`);return}if(!a.has(t.hostname)&&t.protocol!=="https:"){s.error(`refusing to send the admin bearer over ${t.protocol}// to ${t.hostname} — use https for non-localhost targets`);return}return u(o)},f=async(r,s)=>{try{return await fetch(r,s)}catch(e){if(!(e instanceof TypeError))throw e;const o=e.cause instanceof Error?e.cause.message:e.message,t=a.has(new URL(r).hostname)?" — is the dev server running? Start it, or pass --url to point at the worker":"";throw new i("INTERNAL",`could not reach ${r} (${o})${t}`,{cause:e})}};export{f as a,l as b,u as n,v as r};