removed deprecated code

This commit is contained in:
Boki 2025-06-23 21:39:04 -04:00
parent 34c6c36695
commit ca5f09c459
10 changed files with 18 additions and 377 deletions

View file

@ -2,12 +2,12 @@
import { EnvLoader } from './loaders/env.loader';
import { FileLoader } from './loaders/file.loader';
import { ConfigManager } from './config-manager';
import type { AppConfig } from './schemas';
import { appConfigSchema } from './schemas';
import type { BaseAppConfig } from './schemas';
import { baseAppSchema } from './schemas';
import { z } from 'zod';
// Legacy singleton instance for backward compatibility
let configInstance: ConfigManager<AppConfig> | null = null;
let configInstance: ConfigManager<BaseAppConfig> | null = null;
// Synchronously load critical env vars for early initialization
function loadCriticalEnvVarsSync(): void {
@ -56,25 +56,6 @@ function loadCriticalEnvVarsSync(): void {
// Load critical env vars immediately
loadCriticalEnvVarsSync();
/**
* Initialize the global configuration synchronously.
* @deprecated Use initializeAppConfig with your own schema instead
*
* This loads configuration from all sources in the correct hierarchy:
* 1. Schema defaults (lowest priority)
* 2. default.json
* 3. [environment].json (e.g., development.json)
* 4. .env file values
* 5. process.env values (highest priority)
*/
export function initializeConfig(configPath?: string): AppConfig {
if (!configInstance) {
configInstance = new ConfigManager<AppConfig>({
configPath,
});
}
return configInstance.initialize(appConfigSchema);
}
/**
* Initialize configuration for a service in a monorepo.
@ -83,10 +64,10 @@ export function initializeConfig(configPath?: string): AppConfig {
* 2. Service-specific config directory (./config)
* 3. Environment variables
*/
export function initializeServiceConfig(): AppConfig {
export function initializeServiceConfig(): BaseAppConfig {
if (!configInstance) {
const environment = process.env.NODE_ENV || 'development';
configInstance = new ConfigManager<AppConfig>({
configInstance = new ConfigManager<BaseAppConfig>({
loaders: [
new FileLoader('../../config', environment), // Root config
new FileLoader('./config', environment), // Service config
@ -94,13 +75,13 @@ export function initializeServiceConfig(): AppConfig {
],
});
}
return configInstance.initialize(appConfigSchema);
return configInstance.initialize(baseAppSchema);
}
/**
* Get the current configuration
*/
export function getConfig(): AppConfig {
export function getConfig(): BaseAppConfig {
if (!configInstance) {
throw new Error('Configuration not initialized. Call initializeConfig() first.');
}
@ -110,7 +91,7 @@ export function getConfig(): AppConfig {
/**
* Get configuration manager instance
*/
export function getConfigManager(): ConfigManager<AppConfig> {
export function getConfigManager(): ConfigManager<BaseAppConfig> {
if (!configInstance) {
throw new Error('Configuration not initialized. Call initializeConfig() first.');
}
@ -140,21 +121,7 @@ export function getLogConfig() {
return getConfig().log;
}
// Deprecated alias for backward compatibility
export function getLoggingConfig() {
return getConfig().log;
}
// Deprecated - provider configs should be app-specific
// @deprecated Move provider configs to your app-specific config
export function getProviderConfig(_provider: string) {
const config = getConfig() as any;
const providers = config.providers;
if (!providers || !(_provider in providers)) {
throw new Error(`Provider configuration not found: ${_provider}`);
}
return (providers as Record<string, unknown>)[_provider];
}
export function getQueueConfig() {
return getConfig().queue;