moved to zod, packages messed up still

This commit is contained in:
Bojan Kucera 2025-06-07 14:24:28 -04:00
parent 15dd03c0ec
commit a8ee4022bf
35 changed files with 3245 additions and 691 deletions

View file

@ -1,40 +1,42 @@
/**
* Loki log aggregation configuration using envalid
* Loki log aggregation configuration using Zod
* Centralized logging configuration for the Stock Bot platform
*/
import { cleanEnv, str, port, bool, num } from 'envalid';
import { cleanEnv, envValidators } from './env-utils';
const { str, port, bool, num } = envValidators;
/**
* Loki configuration with validation and defaults
*/
export const lokiConfig = cleanEnv(process.env, {
// Loki Server
LOKI_HOST: str({ default: 'localhost', desc: 'Loki host' }),
LOKI_PORT: port({ default: 3100, desc: 'Loki port' }),
LOKI_URL: str({ default: '', desc: 'Complete Loki URL (overrides host/port)' }),
LOKI_HOST: str('localhost', 'Loki host'),
LOKI_PORT: port(3100, 'Loki port'),
LOKI_URL: str('', 'Complete Loki URL (overrides host/port)'),
// Authentication
LOKI_USERNAME: str({ default: '', desc: 'Loki username (if auth enabled)' }),
LOKI_PASSWORD: str({ default: '', desc: 'Loki password (if auth enabled)' }),
LOKI_TENANT_ID: str({ default: '', desc: 'Loki tenant ID (for multi-tenancy)' }),
LOKI_USERNAME: str('', 'Loki username (if auth enabled)'),
LOKI_PASSWORD: str('', 'Loki password (if auth enabled)'),
LOKI_TENANT_ID: str('', 'Loki tenant ID (for multi-tenancy)'),
// Push Configuration
LOKI_PUSH_TIMEOUT: num({ default: 10000, desc: 'Push timeout in ms' }),
LOKI_BATCH_SIZE: num({ default: 1024, desc: 'Batch size for log entries' }),
LOKI_BATCH_WAIT: num({ default: 5, desc: 'Batch wait time in ms' }),
LOKI_PUSH_TIMEOUT: num(10000, 'Push timeout in ms'),
LOKI_BATCH_SIZE: num(1024, 'Batch size for log entries'),
LOKI_BATCH_WAIT: num(5, 'Batch wait time in ms'),
// Retention Settings
LOKI_RETENTION_PERIOD: str({ default: '30d', desc: 'Log retention period' }),
LOKI_MAX_CHUNK_AGE: str({ default: '1h', desc: 'Maximum chunk age' }),
LOKI_RETENTION_PERIOD: str('30d', 'Log retention period'),
LOKI_MAX_CHUNK_AGE: str('1h', 'Maximum chunk age'),
// TLS Settings
LOKI_TLS_ENABLED: bool({ default: false, desc: 'Enable TLS for Loki' }),
LOKI_TLS_INSECURE: bool({ default: false, desc: 'Skip TLS verification' }),
LOKI_TLS_ENABLED: bool(false, 'Enable TLS for Loki'),
LOKI_TLS_INSECURE: bool(false, 'Skip TLS verification'),
// Log Labels
LOKI_DEFAULT_LABELS: str({ default: '', desc: 'Default labels for all log entries (JSON format)' }),
LOKI_SERVICE_LABEL: str({ default: 'stock-bot', desc: 'Service label for log entries' }),
LOKI_ENVIRONMENT_LABEL: str({ default: 'development', desc: 'Environment label for log entries' }),
LOKI_DEFAULT_LABELS: str('', 'Default labels for all log entries (JSON format)'),
LOKI_SERVICE_LABEL: str('stock-bot', 'Service label for log entries'),
LOKI_ENVIRONMENT_LABEL: str('development', 'Environment label for log entries'),
});
// Export typed configuration object