433 lines
6.7 KiB
TypeScript
433 lines
6.7 KiB
TypeScript
/**
|
|
* Base configuration interface with common properties for all services
|
|
*/
|
|
export interface IBaseConfig {
|
|
/**
|
|
* Unique identifier for this configuration
|
|
* Used to track configuration versions and changes
|
|
*/
|
|
id?: string;
|
|
|
|
/**
|
|
* Configuration version
|
|
* Used for migration between different config formats
|
|
*/
|
|
version?: string;
|
|
|
|
/**
|
|
* Environment this configuration is intended for
|
|
* (development, test, production, etc.)
|
|
*/
|
|
environment?: 'development' | 'test' | 'staging' | 'production';
|
|
|
|
/**
|
|
* Display name for this configuration
|
|
*/
|
|
name?: string;
|
|
|
|
/**
|
|
* Whether this configuration is enabled
|
|
* Services with disabled configuration shouldn't start
|
|
*/
|
|
enabled?: boolean;
|
|
|
|
/**
|
|
* Logging configuration
|
|
*/
|
|
logging?: {
|
|
/**
|
|
* Minimum log level to output
|
|
*/
|
|
level?: 'error' | 'warn' | 'info' | 'debug';
|
|
|
|
/**
|
|
* Whether to include structured data in logs
|
|
*/
|
|
structured?: boolean;
|
|
|
|
/**
|
|
* Whether to enable correlation tracking in logs
|
|
*/
|
|
correlationTracking?: boolean;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Base database configuration
|
|
*/
|
|
export interface IDatabaseConfig {
|
|
/**
|
|
* Database connection string or URL
|
|
*/
|
|
connectionString?: string;
|
|
|
|
/**
|
|
* Database host
|
|
*/
|
|
host?: string;
|
|
|
|
/**
|
|
* Database port
|
|
*/
|
|
port?: number;
|
|
|
|
/**
|
|
* Database name
|
|
*/
|
|
database?: string;
|
|
|
|
/**
|
|
* Database username
|
|
*/
|
|
username?: string;
|
|
|
|
/**
|
|
* Database password
|
|
*/
|
|
password?: string;
|
|
|
|
/**
|
|
* SSL configuration for database connection
|
|
*/
|
|
ssl?: boolean | {
|
|
/**
|
|
* Whether to reject unauthorized SSL connections
|
|
*/
|
|
rejectUnauthorized?: boolean;
|
|
|
|
/**
|
|
* Path to CA certificate file
|
|
*/
|
|
ca?: string;
|
|
|
|
/**
|
|
* Path to client certificate file
|
|
*/
|
|
cert?: string;
|
|
|
|
/**
|
|
* Path to client key file
|
|
*/
|
|
key?: string;
|
|
};
|
|
|
|
/**
|
|
* Connection pool configuration
|
|
*/
|
|
pool?: {
|
|
/**
|
|
* Minimum number of connections in pool
|
|
*/
|
|
min?: number;
|
|
|
|
/**
|
|
* Maximum number of connections in pool
|
|
*/
|
|
max?: number;
|
|
|
|
/**
|
|
* Connection idle timeout in milliseconds
|
|
*/
|
|
idleTimeoutMillis?: number;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Base TLS configuration interface
|
|
*/
|
|
export interface ITlsConfig {
|
|
/**
|
|
* Whether to enable TLS
|
|
*/
|
|
enabled?: boolean;
|
|
|
|
/**
|
|
* The domain name for the certificate
|
|
*/
|
|
domain?: string;
|
|
|
|
/**
|
|
* Path to certificate file
|
|
*/
|
|
certPath?: string;
|
|
|
|
/**
|
|
* Path to private key file
|
|
*/
|
|
keyPath?: string;
|
|
|
|
/**
|
|
* Path to CA certificate file
|
|
*/
|
|
caPath?: string;
|
|
|
|
/**
|
|
* Minimum TLS version to support
|
|
*/
|
|
minVersion?: 'TLSv1.2' | 'TLSv1.3';
|
|
|
|
/**
|
|
* Whether to auto-renew certificates
|
|
*/
|
|
autoRenew?: boolean;
|
|
|
|
/**
|
|
* Whether to reject unauthorized certificates
|
|
*/
|
|
rejectUnauthorized?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Base retry configuration interface
|
|
*/
|
|
export interface IRetryConfig {
|
|
/**
|
|
* Maximum number of retry attempts
|
|
*/
|
|
maxAttempts?: number;
|
|
|
|
/**
|
|
* Base delay between retries in milliseconds
|
|
*/
|
|
baseDelay?: number;
|
|
|
|
/**
|
|
* Maximum delay between retries in milliseconds
|
|
*/
|
|
maxDelay?: number;
|
|
|
|
/**
|
|
* Backoff factor for exponential backoff
|
|
*/
|
|
backoffFactor?: number;
|
|
|
|
/**
|
|
* Specific error codes that should trigger retries
|
|
*/
|
|
retryableErrorCodes?: string[];
|
|
|
|
/**
|
|
* Whether to add jitter to retry delays
|
|
*/
|
|
useJitter?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Base rate limiting configuration interface
|
|
*/
|
|
export interface IRateLimitConfig {
|
|
/**
|
|
* Whether rate limiting is enabled
|
|
*/
|
|
enabled?: boolean;
|
|
|
|
/**
|
|
* Maximum number of operations per period
|
|
*/
|
|
maxPerPeriod?: number;
|
|
|
|
/**
|
|
* Time period in milliseconds
|
|
*/
|
|
periodMs?: number;
|
|
|
|
/**
|
|
* Whether to apply per key (e.g., domain, user, etc.)
|
|
*/
|
|
perKey?: boolean;
|
|
|
|
/**
|
|
* Number of burst tokens allowed
|
|
*/
|
|
burstTokens?: number;
|
|
}
|
|
|
|
/**
|
|
* Basic HTTP server configuration
|
|
*/
|
|
export interface IHttpServerConfig {
|
|
/**
|
|
* Whether the HTTP server is enabled
|
|
*/
|
|
enabled?: boolean;
|
|
|
|
/**
|
|
* Host to bind to
|
|
*/
|
|
host?: string;
|
|
|
|
/**
|
|
* Port to listen on
|
|
*/
|
|
port?: number;
|
|
|
|
/**
|
|
* Path prefix for all routes
|
|
*/
|
|
basePath?: string;
|
|
|
|
/**
|
|
* CORS configuration
|
|
*/
|
|
cors?: boolean | {
|
|
/**
|
|
* Allowed origins
|
|
*/
|
|
origins?: string[];
|
|
|
|
/**
|
|
* Allowed methods
|
|
*/
|
|
methods?: string[];
|
|
|
|
/**
|
|
* Allowed headers
|
|
*/
|
|
headers?: string[];
|
|
|
|
/**
|
|
* Whether to allow credentials
|
|
*/
|
|
credentials?: boolean;
|
|
};
|
|
|
|
/**
|
|
* TLS configuration
|
|
*/
|
|
tls?: ITlsConfig;
|
|
|
|
/**
|
|
* Maximum request body size in bytes
|
|
*/
|
|
maxBodySize?: number;
|
|
|
|
/**
|
|
* Request timeout in milliseconds
|
|
*/
|
|
timeout?: number;
|
|
}
|
|
|
|
/**
|
|
* Basic queue configuration
|
|
*/
|
|
export interface IQueueConfig {
|
|
/**
|
|
* Type of storage for the queue
|
|
*/
|
|
storageType?: 'memory' | 'disk' | 'redis';
|
|
|
|
/**
|
|
* Path for persistent storage
|
|
*/
|
|
persistentPath?: string;
|
|
|
|
/**
|
|
* Redis configuration for queue
|
|
*/
|
|
redis?: {
|
|
/**
|
|
* Redis host
|
|
*/
|
|
host?: string;
|
|
|
|
/**
|
|
* Redis port
|
|
*/
|
|
port?: number;
|
|
|
|
/**
|
|
* Redis password
|
|
*/
|
|
password?: string;
|
|
|
|
/**
|
|
* Redis database number
|
|
*/
|
|
db?: number;
|
|
};
|
|
|
|
/**
|
|
* Maximum size of the queue
|
|
*/
|
|
maxSize?: number;
|
|
|
|
/**
|
|
* Maximum number of retry attempts
|
|
*/
|
|
maxRetries?: number;
|
|
|
|
/**
|
|
* Base delay between retries in milliseconds
|
|
*/
|
|
baseRetryDelay?: number;
|
|
|
|
/**
|
|
* Maximum delay between retries in milliseconds
|
|
*/
|
|
maxRetryDelay?: number;
|
|
|
|
/**
|
|
* Check interval for processing in milliseconds
|
|
*/
|
|
checkInterval?: number;
|
|
|
|
/**
|
|
* Maximum number of parallel processes
|
|
*/
|
|
maxParallelProcessing?: number;
|
|
}
|
|
|
|
/**
|
|
* Basic monitoring configuration
|
|
*/
|
|
export interface IMonitoringConfig {
|
|
/**
|
|
* Whether monitoring is enabled
|
|
*/
|
|
enabled?: boolean;
|
|
|
|
/**
|
|
* Metrics collection interval in milliseconds
|
|
*/
|
|
metricsInterval?: number;
|
|
|
|
/**
|
|
* Whether to expose Prometheus metrics
|
|
*/
|
|
exposePrometheus?: boolean;
|
|
|
|
/**
|
|
* Port for Prometheus metrics
|
|
*/
|
|
prometheusPort?: number;
|
|
|
|
/**
|
|
* Whether to collect detailed metrics
|
|
*/
|
|
detailedMetrics?: boolean;
|
|
|
|
/**
|
|
* Alert thresholds
|
|
*/
|
|
alertThresholds?: Record<string, number>;
|
|
|
|
/**
|
|
* Notification configuration
|
|
*/
|
|
notifications?: {
|
|
/**
|
|
* Whether to send notifications
|
|
*/
|
|
enabled?: boolean;
|
|
|
|
/**
|
|
* Email address to send notifications to
|
|
*/
|
|
email?: string;
|
|
|
|
/**
|
|
* Webhook URL to send notifications to
|
|
*/
|
|
webhook?: string;
|
|
};
|
|
} |