@based/get-service
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -1,2 +0,2 @@ | ||
var I=Object.create;var c=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of N(e))!b.call(t,n)&&n!==r&&c(t,n,{get:()=>e[n],enumerable:!(s=_(e,n))||s.enumerable});return t};var J=(t,e,r)=>(r=t!=null?I(P(t)):{},u(e||!t||!t.__esModule?c(r,"default",{value:t,enumerable:!0}):r,t)),V=t=>u(c({},"__esModule",{value:!0}),t);var F={};j(F,{default:()=>g,getClusterUrl:()=>K});module.exports=V(F);var a=J(require("cross-fetch")),k="https://d15p61sp2f2oaj.cloudfront.net",D=/^(?:(tcp|wss?|https?):\/\/)?([a-z0-9.-]*)(?::(\d+))?$/,l=(t=1e3)=>new Promise(e=>{setTimeout(e,t)}),v,y,S,p=((v=process==null?void 0:process.env)==null?void 0:v.CLOUD)==="local"?`http://${(y=process==null?void 0:process.env)==null?void 0:y.SERVICE_SELECTOR_LIST}`:`https://${(S=process==null?void 0:process.env)==null?void 0:S.SERVICE_SELECTOR_LIST}`,E=0,K=t=>t?t==="local"?"http://localhost:7022":t:p||k;async function g(t,e=0,r){var s,n,f;if(r||(console.info("No cluster use selector list",p),r=p),!r)throw new Error("No cluster url defined");try{let o=await Promise.race([(0,a.default)(r).then(A).catch(m),l(3e3)]);if(typeof t=="string"&&(t={name:t}),!o)throw new Error(`Cannot connect to service-selector-list within 5s, retrying... | ||
${JSON.stringify(t,null,2)}`);let{org:$=(s=process==null?void 0:process.env)==null?void 0:s.ORG,project:w=(n=process==null?void 0:process.env)==null?void 0:n.PROJECT,env:T=(f=process==null?void 0:process.env)==null?void 0:f.ENV,name:C,key:h,optionalKey:L}=t,R=o.length,i;for(;R--;){let U=o[++E]||o[E=0];if(i=await Promise.race([(0,a.default)(`${U}/${$}.${w}.${T}.${C}${h?`.${h}`:""}${L?"$":""}`).then(z).catch(m),l(3e3)]),i){let[,O,d,x]=D.exec(i);return{protocol:O,host:d,port:Number(x),url:i}}}}catch(o){console.error(o.message)}return e++,await l(Math.min(e*1e3,2e3)),g(t,e,r)}function z(t){return t.text()}function A(t){return t.json()}function m(){}0&&(module.exports={getClusterUrl}); | ||
var d=Object.create;var c=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of N(e))!b.call(t,n)&&n!==r&&c(t,n,{get:()=>e[n],enumerable:!(s=x(e,n))||s.enumerable});return t};var V=(t,e,r)=>(r=t!=null?d(P(t)):{},u(e||!t||!t.__esModule?c(r,"default",{value:t,enumerable:!0}):r,t)),J=t=>u(c({},"__esModule",{value:!0}),t);var F={};j(F,{default:()=>g,getClusterUrl:()=>K});module.exports=J(F);var a=V(require("cross-fetch")),k="https://d15p61sp2f2oaj.cloudfront.net",D=/^(?:(tcp|wss?|https?):\/\/)?([a-z0-9.-]*)(?::(\d+))?$/,l=(t=1e3)=>new Promise(e=>{setTimeout(e,t)}),m,v,y,p=((m=process==null?void 0:process.env)==null?void 0:m.CLOUD)==="local"?`http://${(v=process==null?void 0:process.env)==null?void 0:v.SERVICE_SELECTOR_LIST}`:`https://${(y=process==null?void 0:process.env)==null?void 0:y.SERVICE_SELECTOR_LIST}`,E=0,K=t=>{var e;return t?t==="local"?"http://localhost:7022":t:(e=process==null?void 0:process.env)!=null&&e.SERVICE_SELECTOR_LIST?p:k};async function g(t,e=0,r){var s,n,f;if(r||(console.info("No cluster use selector list",p),r=p),!r)throw new Error("No cluster url defined");try{let o=await Promise.race([(0,a.default)(r).then(A).catch(S),l(3e3)]);if(typeof t=="string"&&(t={name:t}),!o)throw new Error(`Cannot connect to service-selector-list within 5s, retrying... | ||
${JSON.stringify(t,null,2)}`);let{org:T=(s=process==null?void 0:process.env)==null?void 0:s.ORG,project:$=(n=process==null?void 0:process.env)==null?void 0:n.PROJECT,env:w=(f=process==null?void 0:process.env)==null?void 0:f.ENV,name:C,key:h,optionalKey:L}=t,R=o.length,i;for(;R--;){let O=o[++E]||o[E=0];if(i=await Promise.race([(0,a.default)(`${O}/${T}.${$}.${w}.${C}${h?`.${h}`:""}${L?"$":""}`).then(z).catch(S),l(3e3)]),i){let[,U,I,_]=D.exec(i);return{protocol:U,host:I,port:Number(_),url:i}}}}catch(o){console.error(o.message)}return e++,await l(Math.min(e*1e3,2e3)),g(t,e,r)}function z(t){return t.text()}function A(t){return t.json()}function S(){}0&&(module.exports={getClusterUrl}); |
{ | ||
"name": "@based/get-service", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -21,3 +21,3 @@ import fetch from 'cross-fetch' | ||
if (!cluster) { | ||
return SELECTOR_LIST || DEFAULT_CLUSTER | ||
return process?.env?.SERVICE_SELECTOR_LIST ? SELECTOR_LIST : DEFAULT_CLUSTER | ||
} | ||
@@ -24,0 +24,0 @@ if (cluster === 'local') { |
Sorry, the diff of this file is not supported yet
10867
8