af-consul
Advanced tools
Comparing version 2.0.15 to 2.0.16
@@ -1,5 +0,5 @@ | ||
import { IApi, ICache, ICLOptions } from './interfaces'; | ||
import { IAFConsulAPI, ICache, ICLOptions } from './interfaces'; | ||
export { accessPointsUpdater } from './access-points/access-points-updater'; | ||
export declare const apiCache: ICache<IApi>; | ||
export declare const getAPI: (options: ICLOptions) => Promise<IApi>; | ||
export declare const apiCache: ICache<IAFConsulAPI>; | ||
export declare const getAPI: (options: ICLOptions) => Promise<IAFConsulAPI>; | ||
//# sourceMappingURL=get-api.d.ts.map |
@@ -153,3 +153,3 @@ /// <reference types="node" /> | ||
} | ||
export interface IApi extends IConsulAPI { | ||
export interface IAFConsulAPI extends IConsulAPI { | ||
registerConfig: IRegisterConfig; | ||
@@ -156,0 +156,0 @@ getConsulUIAddress: TMethod<string>; |
{ | ||
"name": "af-consul", | ||
"version": "2.0.15", | ||
"version": "2.0.16", | ||
"description": "A highly specialized function library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/src/index.js", |
/* eslint-disable no-console */ | ||
// noinspection JSUnusedGlobalSymbols | ||
import { IApi, ICache, ICLOptions, IConsulAPI, TRegisterType } from './interfaces'; | ||
import { IAFConsulAPI, ICache, ICLOptions, IConsulAPI, TRegisterType } from './interfaces'; | ||
import { getConsulApiCached } from './prepare-consul-api'; | ||
@@ -29,8 +29,8 @@ import { CONSUL_DEBUG_ON, MAX_API_CACHED, PREFIX } from './constants'; | ||
export const apiCache: ICache<IApi> = {}; | ||
export const apiCache: ICache<IAFConsulAPI> = {}; | ||
export const getAPI = async (options: ICLOptions): Promise<IApi> => { | ||
export const getAPI = async (options: ICLOptions): Promise<IAFConsulAPI> => { | ||
const hash = getConfigHash(options); | ||
if (!apiCache[hash]) { | ||
const api: IConsulAPI = await getConsulApiCached(options) as IApi; | ||
const api: IConsulAPI = await getConsulApiCached(options) as IAFConsulAPI; | ||
const registerConfig = await getRegisterConfig(options); | ||
@@ -51,3 +51,3 @@ const serviceId = registerConfig.id; | ||
deregister: (svcId?: string, agentHost?: string, agentPort?: string) => api.deregisterIfNeed(svcId || serviceId, agentHost, agentPort), | ||
} as IApi; | ||
} as IAFConsulAPI; | ||
@@ -54,0 +54,0 @@ Object.entries(api).forEach(([k, v]) => { |
@@ -175,3 +175,3 @@ import Consul from 'consul'; | ||
export interface IApi extends IConsulAPI { | ||
export interface IAFConsulAPI extends IConsulAPI { | ||
registerConfig: IRegisterConfig, | ||
@@ -178,0 +178,0 @@ getConsulUIAddress: TMethod<string>, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
279699