@based/get-service
Advanced tools
Comparing version 0.1.7 to 0.2.0
@@ -0,1 +1,2 @@ | ||
export declare const getClusterUrl: (cluster?: string) => string; | ||
export declare type ServiceUrl = { | ||
@@ -2,0 +3,0 @@ protocol: string; |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getClusterUrl = void 0; | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
const DEV_CLUSTER = 'https://dg194mksjrqfz.cloudfront.net'; | ||
const parsUrlRe = /^(?:(tcp|wss?|https?):\/\/)?([a-z0-9.-]*)(?::(\d+))?$/; | ||
@@ -12,10 +14,28 @@ const wait = (t = 1e3) => new Promise((resolve) => { | ||
}); | ||
// this has to be fixed - has to come from machine env var (should be there) | ||
if (!process.env.SERVICE_SELECTOR_LIST && typeof window === 'undefined') { | ||
if (process.env.CLUSTER === 'dev') { | ||
process.env.SERVICE_SELECTOR_LIST = DEV_CLUSTER; | ||
} | ||
} | ||
const SELECTOR_LIST = process.env.CLUSTER === 'local' | ||
? 'http://localhost:7022' | ||
: // : process.env.SERVICE_SELECTOR_LIST | ||
// ? `https://${process.env.SERVICE_SELECTOR_LIST}` | ||
'https://dg194mksjrqfz.cloudfront.net'; | ||
? `http://${process.env.SERVICE_SELECTOR_LIST}` | ||
: `https://${process.env.SERVICE_SELECTOR_LIST}`; | ||
let registryIndex = 0; | ||
const getClusterUrl = (cluster) => { | ||
if (!cluster) { | ||
return DEV_CLUSTER; | ||
} | ||
if (cluster === 'local') { | ||
return 'http://localhost:7022'; | ||
} | ||
if (cluster === 'localSpesh') { | ||
return 'http://localhost:9022'; | ||
} | ||
return cluster; | ||
}; | ||
exports.getClusterUrl = getClusterUrl; | ||
async function getService(opts, retries = 0, cluster = SELECTOR_LIST) { | ||
if (!cluster) { | ||
throw new Error('No cluster url defined'); | ||
} | ||
try { | ||
@@ -22,0 +42,0 @@ const registryUrls = await Promise.race([ |
{ | ||
"name": "@based/get-service", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "__module": "src/index.ts", |
import fetch from 'cross-fetch' | ||
const DEV_CLUSTER = 'https://dg194mksjrqfz.cloudfront.net' | ||
const parsUrlRe = /^(?:(tcp|wss?|https?):\/\/)?([a-z0-9.-]*)(?::(\d+))?$/ | ||
@@ -9,12 +11,28 @@ const wait = (t = 1e3) => | ||
// this has to be fixed - has to come from machine env var (should be there) | ||
if (!process.env.SERVICE_SELECTOR_LIST && typeof window === 'undefined') { | ||
if (process.env.CLUSTER === 'dev') { | ||
process.env.SERVICE_SELECTOR_LIST = DEV_CLUSTER | ||
} | ||
} | ||
const SELECTOR_LIST = | ||
process.env.CLUSTER === 'local' | ||
? 'http://localhost:7022' | ||
: // : process.env.SERVICE_SELECTOR_LIST | ||
// ? `https://${process.env.SERVICE_SELECTOR_LIST}` | ||
'https://dg194mksjrqfz.cloudfront.net' | ||
? `http://${process.env.SERVICE_SELECTOR_LIST}` | ||
: `https://${process.env.SERVICE_SELECTOR_LIST}` | ||
let registryIndex = 0 | ||
export const getClusterUrl = (cluster?: string): string => { | ||
if (!cluster) { | ||
return DEV_CLUSTER | ||
} | ||
if (cluster === 'local') { | ||
return 'http://localhost:7022' | ||
} | ||
if (cluster === 'localSpesh') { | ||
return 'http://localhost:9022' | ||
} | ||
return cluster | ||
} | ||
export type ServiceUrl = { | ||
@@ -41,2 +59,6 @@ protocol: string | ||
): Promise<ServiceUrl> { | ||
if (!cluster) { | ||
throw new Error('No cluster url defined') | ||
} | ||
try { | ||
@@ -43,0 +65,0 @@ const registryUrls = await Promise.race([ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
72595
218
10