update
This commit is contained in:
@@ -1,59 +1,2 @@
|
||||
// Export configuration interfaces
|
||||
export * from './base.config.js';
|
||||
export * from './email.config.js';
|
||||
export * from './sms.config.js';
|
||||
export * from './platform.config.js';
|
||||
|
||||
// Export validation tools
|
||||
export * from './validator.js';
|
||||
export * from './schemas.js';
|
||||
|
||||
// Re-export commonly used types
|
||||
import type { IPlatformConfig } from './platform.config.js';
|
||||
import type { ISmsConfig } from './sms.config.js';
|
||||
import type {
|
||||
IBaseConfig,
|
||||
ITlsConfig,
|
||||
IHttpServerConfig,
|
||||
IRateLimitConfig,
|
||||
IQueueConfig
|
||||
} from './base.config.js';
|
||||
|
||||
// Default platform configuration
|
||||
export const defaultConfig: IPlatformConfig = {
|
||||
id: 'platform-service-config',
|
||||
version: '1.0.0',
|
||||
environment: 'production',
|
||||
name: 'PlatformService',
|
||||
enabled: true,
|
||||
logging: {
|
||||
level: 'info',
|
||||
structured: true,
|
||||
correlationTracking: true
|
||||
},
|
||||
server: {
|
||||
enabled: true,
|
||||
host: '0.0.0.0',
|
||||
port: 3000,
|
||||
cors: true
|
||||
},
|
||||
// Email configuration removed - use IUnifiedEmailServerOptions in DcRouter instead
|
||||
email: undefined,
|
||||
paths: {
|
||||
dataDir: 'data',
|
||||
logsDir: 'logs',
|
||||
tempDir: 'temp',
|
||||
emailTemplatesDir: 'templates/email'
|
||||
}
|
||||
};
|
||||
|
||||
// Export main types for convenience
|
||||
export type {
|
||||
IPlatformConfig,
|
||||
ISmsConfig,
|
||||
IBaseConfig,
|
||||
ITlsConfig,
|
||||
IHttpServerConfig,
|
||||
IRateLimitConfig,
|
||||
IQueueConfig
|
||||
};
|
||||
// Export validation tools only
|
||||
export * from './validator.js';
|
@@ -1,6 +1,5 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import { ValidationError } from '../errors/base.errors.js';
|
||||
import type { IBaseConfig } from './base.config.js';
|
||||
|
||||
/**
|
||||
* Validation result
|
||||
@@ -95,56 +94,6 @@ export type ValidationSchema = Record<string, {
|
||||
* Validates configuration objects against schemas and provides default values
|
||||
*/
|
||||
export class ConfigValidator {
|
||||
/**
|
||||
* Basic schema for IBaseConfig
|
||||
*/
|
||||
private static baseConfigSchema: ValidationSchema = {
|
||||
id: {
|
||||
type: 'string',
|
||||
required: false
|
||||
},
|
||||
version: {
|
||||
type: 'string',
|
||||
required: false
|
||||
},
|
||||
environment: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
enum: ['development', 'test', 'staging', 'production'],
|
||||
default: 'production'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false
|
||||
},
|
||||
enabled: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
logging: {
|
||||
type: 'object',
|
||||
required: false,
|
||||
schema: {
|
||||
level: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
enum: ['error', 'warn', 'info', 'debug'],
|
||||
default: 'info'
|
||||
},
|
||||
structured: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
correlationTracking: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
default: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate a configuration object against a schema
|
||||
@@ -261,15 +210,6 @@ export class ConfigValidator {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate base configuration
|
||||
*
|
||||
* @param config Base configuration
|
||||
* @returns Validation result for base configuration
|
||||
*/
|
||||
public static validateBaseConfig(config: IBaseConfig): IValidationResult {
|
||||
return this.validate(config, this.baseConfigSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply defaults to a configuration object based on a schema
|
||||
|
Reference in New Issue
Block a user