@iota-big3/sdk-gateway
Version:
Universal API Gateway with protocol translation, intelligent routing, rate limiting, health checking, and caching
149 lines • 3.65 kB
TypeScript
/**
* @iota-big3/sdk-gateway
* Clean Gateway Manager - Phase 2d Rebuild
*/
import { EventEmitter } from 'events';
import { CacheStats, GatewayConfig, GatewayMetrics, GatewayRequest, GatewayResponse, OverallHealth, Result, RouteConfig } from '../types/gateway-types';
export declare class UniversalAPIGateway extends EventEmitter {
private config;
private adapters;
private routingEngine;
private circuitBreaker;
private _slaMonitor?;
private _costTracker?;
private serviceDiscovery;
private responseAggregator;
private isRunning;
private isEnabled;
private rateLimiter?;
private healthChecker?;
private cacheManager?;
private database?;
private logger?;
private authManager?;
private eventBus?;
private metrics;
constructor(config: GatewayConfig);
/**
* Initialize the gateway and all integrations
*/
initializeAsync(): Promise<void>;
/**
* Validate a request (for auth integration)
*/
validateRequestAsync(request: GatewayRequest): Promise<boolean>;
/**
* Reload routes from database
*/
reloadRoutesAsync(): Promise<Result<void, Error>>;
/**
* Load routes from database
*/
private loadRoutesFromDatabase;
/**
* Setup event listeners for integration
*/
private setupEventListeners;
/**
* Helper to log messages
*/
private log;
/**
* Helper to emit events
*/
private emitEvent;
/**
* Check if object is a valid route
*/
private isValidRoute;
/**
* Start the gateway
*/
startAsync(): Promise<void>;
/**
* Stop the gateway
*/
stopAsync(): Promise<void>;
/**
* Add a new route
*/
addRoute(route: RouteConfig): void;
/**
* Remove a route
*/
removeRoute(routeId: string): boolean;
/**
* Get all routes
*/
getRoutes(): RouteConfig[];
/**
* Update gateway configuration
*/
updateConfig(config: Partial<GatewayConfig>): void;
/**
* Enable the gateway
*/
enable(): void;
/**
* Disable the gateway
*/
disable(): void;
/**
* Check if gateway is enabled
*/
isGatewayEnabled(): boolean;
/**
* Check if gateway is running
*/
isGatewayRunning(): boolean;
/**
* Handle incoming request
*/
handleRequestAsync(request: GatewayRequest): Promise<GatewayResponse>;
/**
* Handle multi-service request
*/
private handleMultiServiceRequestAsync;
/**
* Find a healthy endpoint from the route
*/
private findHealthyEndpointAsync;
/**
* Make request to backend service
*/
private makeRequestAsync;
/**
* Update gateway metrics
*/
private updateMetrics;
/**
* Get current metrics
*/
getMetrics(): GatewayMetrics & {
cache?: CacheStats;
};
/**
* Get health status
*/
getHealthStatusAsync(): Promise<OverallHealth | {
status: string;
message: string;
}>;
/**
* Add a route with Result pattern
*/
addRouteSafe(route: RouteConfig): Result<void, Error>;
/**
* Remove a route with Result pattern
*/
removeRouteSafe(routeId: string): Result<boolean, Error>;
/**
* Handle a request with Result pattern
*/
handleRequestSafeAsync(request: GatewayRequest): Promise<Result<GatewayResponse, Error>>;
}
/**
* Factory function to create gateway
*/
export declare function createGateway(config: GatewayConfig): UniversalAPIGateway;
//# sourceMappingURL=gateway-manager.d.ts.map