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) • 708 B
const i="https://api.cloudflare.com/client/v4/accounts",u=async({accountId:t,apiToken:a,fetch:e,init:o,path:l})=>{const n=await(e??globalThis.fetch.bind(globalThis))(`${i}/${encodeURIComponent(t)}${l}`,{...o,headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"}}),c=await n.text();let s;try{s=JSON.parse(c)}catch{return{ok:!1,status:n.status,text:c}}return!n.ok||typeof s!="object"||s===null||s.success===!1?{ok:!1,status:n.status,text:c}:{body:s,ok:!0}},r=t=>typeof t=="string"&&t.trim().length>0?t.trim():void 0,d=(t,a)=>{const e=r(t.CLOUDFLARE_ACCOUNT_ID)??r(a),o=r(t.CLOUDFLARE_API_TOKEN);return{...e===void 0?{}:{accountId:e},...o===void 0?{}:{token:o}}};export{u as c,r as n,d as r};