Lewati ke konten

Definisi Tipe (Type Definitions)

Modul tipe berisi definisi TypeScript otoritatif, antarmuka, dan kontrak tipe yang digunakan di seluruh codebase gateway. Modul ini mendefinisikan konteks permintaan, spesifikasi rute, tanda tangan plugin, model identitas, dan tata letak konfigurasi server. Tipe-tipe ini memberikan jaminan waktu kompilasi dan kenyamanan autolengkap bagi pengguna gateway.

SimbolJenisTanda TanganTujuan
ConfigFileinterfaceinterface ConfigFile extends GatewayConfigConfiguration file format
ValidationResultinterfaceinterface ValidationResultConfiguration validation result
ValidationErrorinterfaceinterface ValidationErrorConfiguration validation error
ConfigLoaderOptionsinterfaceinterface ConfigLoaderOptionsConfiguration loader options
ConfigChangeEventinterfaceinterface ConfigChangeEventConfiguration change event
ConfigWatcherCallbacktypetype ConfigWatcherCallback = (event: ConfigChangeEvent) => void | Promise<void>Configuration watcher callback
{ GatewayConfig, ServerConfig, PerformanceConfig, UpstreamTarget, Route, PluginConfig }typetype { GatewayConfig, ServerConfig, PerformanceConfig, UpstreamTarget, Route, PluginConfigType export for { GatewayConfig, ServerConfig, PerformanceConfig, UpstreamTarget, Route, PluginConfig }.
HttpMethodtypetype HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'HTTP methods supported by the gateway
RequestContextinterfaceinterface RequestContextPooled request context object This object is reused across requests to minimize allocations Enhanced with route matching
RouteMatchinterfaceinterface RouteMatchRoute match result
RouteHandlertypetype RouteHandler = (ctx: RequestContext) => Promise<void> | voidRoute handler function signature Handlers should be monomorphic for V8 optimization
Routeinterfaceinterface RouteRoute definition
UpstreamTargetinterfaceinterface UpstreamTargetUpstream service target definition
HealthCheckConfiginterfaceinterface HealthCheckConfigHealth check configuration
LoadBalancerStrategytypetype LoadBalancerStrategy =Load balancing strategies
CircuitBreakerStateenumenum CircuitBreakerStateCircuit breaker states
CircuitBreakerConfiginterfaceinterface CircuitBreakerConfigCircuit breaker configuration
WorkerMessageTypeenumenum WorkerMessageTypeWorker message types for master-worker communication
WorkerMessageinterfaceinterface WorkerMessageWorker message protocol
MetricsSnapshotinterfaceinterface MetricsSnapshotPerformance metrics snapshot Designed for lock-free atomic operations
ServerConfiginterfaceinterface ServerConfigServer configuration
GatewayConfiginterfaceinterface GatewayConfigGateway configuration (root)
PluginConfiginterfaceinterface PluginConfigPlugin configuration
PerformanceConfiginterfaceinterface PerformanceConfigPerformance tuning configuration
BodyParserConfiginterfaceinterface BodyParserConfigBody parser configuration
ConnectionPoolConfiginterfaceinterface ConnectionPoolConfigConnection pool configuration
HealthCheckTypetypetype HealthCheckType = 'active' | 'passive' | 'hybrid'Health check type
HealthStatusenumenum HealthStatusHealth status
LoadBalancerConfiginterfaceinterface LoadBalancerConfigLoad balancer configuration
MonitoringConfiginterfaceinterface MonitoringConfigMonitoring configuration
ApiKeysConfiginterfaceinterface ApiKeysConfigInterface export for ApiKeysConfig.
UpstreamCredentialsConfiginterfaceinterface UpstreamCredentialsConfigInterface export for UpstreamCredentialsConfig.
WithIdentityinterfaceinterface WithIdentity extends GatewayConfigInterface export for WithIdentity.
PluginHookenumenum PluginHookPlugin lifecycle hooks
Plugininterfaceinterface PluginPlugin interface All plugins must implement this interface
PluginMetadatainterfaceinterface PluginMetadataPlugin metadata
PluginExecutionContextinterfaceinterface PluginExecutionContextPlugin execution context Used internally by plugin executor
PluginStatsinterfaceinterface PluginStatsPlugin execution statistics
PluginLoaderConfiginterfaceinterface PluginLoaderConfigPlugin loader configuration

Kontrak skema utama yang mendeskripsikan port server, upstream pool, rute, dan plugin.

Konteks eksekusi yang diteruskan melalui router, kebijakan, dan plugin.

Kontrak siklus hidup yang mendefinisikan hook penanganan onRequest, onResponse, dan onError.

  • src/types/config.ts
  • src/types/core.ts
  • src/types/identity.ts
  • src/types/plugin.ts