From 094e41b9cea377393d6e884a1366b4290ca4f7bf Mon Sep 17 00:00:00 2001 From: Ilko Hoffmann Date: Fri, 7 Apr 2017 17:05:10 +0200 Subject: [PATCH] added types for eureka-js-client --- .../eureka-js-client-tests.ts | 21 +++++ types/eureka-js-client/index.d.ts | 80 +++++++++++++++++++ types/eureka-js-client/tsconfig.json | 22 +++++ 3 files changed, 123 insertions(+) create mode 100644 types/eureka-js-client/eureka-js-client-tests.ts create mode 100644 types/eureka-js-client/index.d.ts create mode 100644 types/eureka-js-client/tsconfig.json diff --git a/types/eureka-js-client/eureka-js-client-tests.ts b/types/eureka-js-client/eureka-js-client-tests.ts new file mode 100644 index 0000000000..a28a4d7a48 --- /dev/null +++ b/types/eureka-js-client/eureka-js-client-tests.ts @@ -0,0 +1,21 @@ +import { Eureka } from 'eureka-js-client'; + +// example configuration +let client = new Eureka({ + // application instance information + instance: { + app: 'jqservice', + hostName: 'localhost', + ipAddr: '127.0.0.1', + port: 8080, + vipAddress: 'jq.test.something.com', + dataCenterInfo: { + name: 'MyOwn', + }, + }, + eureka: { + // eureka server host / port + host: '192.168.99.100', + port: 32768, + } +}); \ No newline at end of file diff --git a/types/eureka-js-client/index.d.ts b/types/eureka-js-client/index.d.ts new file mode 100644 index 0000000000..d8fb19ac1f --- /dev/null +++ b/types/eureka-js-client/index.d.ts @@ -0,0 +1,80 @@ +// Type definitions for eureka-js-client 4.3.0 +// Project: https://github.com/jquatier/eureka-js-client +// Definitions by: Ilko Hoffmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export declare class Eureka { + constructor(config: EurekaClient.EurekaConfig) + start(): void; + stop(): void; + getInstancesByAppId(appId: string): Array; + getInstancesByVipAddress(vidAddress: string): Array; +} + +declare namespace EurekaClient { + + type InstanceStatus = 'UP' | 'DOWN' | 'STARTING' | 'OUT_OF_SERVICE' | 'UNKNOWN'; + type ActionType = 'ADDED' | 'MODIFIED' | 'DELETED'; + + interface EurekaConfig { + instance: EurekaInstanceConfig, + eureka: EurekaClientConfig + } + interface EurekaInstanceConfig { + app: string, + hostName: string, + ipAddr: string, + vipAddress: string, + dataCenterInfo: DataCenterInfo, + port?: number, + instanceId?: string, + appGroupName?: string, + sid?: string, + securePort?: PortWrapper, + homePageUrl?: string, + statusPageUrl?: string, + healthCheckUrl?: string, + secureHealthCheckUrl?: string, + secureVipAddress?: string, + countryId?: number, + status?: InstanceStatus, + overriddenstatus?: InstanceStatus, + leaseInfo?: LeaseInfo, + isCoordinatingDiscoveryServer?: boolean, + metadata?: Array<[string, string]>, + lastUpdatedTimestamp?: number, + lastDirtyTimestamp?: number, + actionType?: ActionType, + asgName?: string + } + interface EurekaClientConfig { + host: string, + port: number, + heartbeatInterval?: number, + registryFetchInterval?: number, + maxRetries?: number, + requestRetryDelay?: number, + fetchRegistry?: boolean, + filterUpInstances?: boolean, + servicePath?: string, + ssl?: boolean, + useDns?: boolean, + preferSameZone?: boolean, + clusterRefreshInterval?: boolean, + fetchMetadata?: boolean, + registerWithEureka?: boolean, + useLocalMetadata?: boolean, + preferIpAddress?: boolean + } + interface PortWrapper { + enabled: boolean, + port: number + } + interface LeaseInfo { + renewalIntervalInSecs: number; + durationInSecs: number; + } + interface DataCenterInfo { + name: 'Netflix' | 'Amazon' | 'MyOwn'; + } +} \ No newline at end of file diff --git a/types/eureka-js-client/tsconfig.json b/types/eureka-js-client/tsconfig.json new file mode 100644 index 0000000000..5cb950ba75 --- /dev/null +++ b/types/eureka-js-client/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "eureka-js-client-tests.ts" + ] +} \ No newline at end of file