fixed format issues

This commit is contained in:
Boki 2025-06-26 16:12:27 -04:00
parent a700818a06
commit 08f713d98b
55 changed files with 5680 additions and 5533 deletions

View file

@ -28,10 +28,7 @@ export class ConfigManager<T = Record<string, unknown>> {
this.loaders = options.loaders;
} else {
const configPath = options.configPath || join(process.cwd(), 'config');
this.loaders = [
new FileLoader(configPath, this.environment),
new EnvLoader(''),
];
this.loaders = [new FileLoader(configPath, this.environment), new EnvLoader('')];
}
}
@ -61,7 +58,11 @@ export class ConfigManager<T = Record<string, unknown>> {
const mergedConfig = this.merge(...configs) as T;
// Add environment if not present
if (typeof mergedConfig === 'object' && mergedConfig !== null && !('environment' in mergedConfig)) {
if (
typeof mergedConfig === 'object' &&
mergedConfig !== null &&
!('environment' in mergedConfig)
) {
(mergedConfig as Record<string, unknown>)['environment'] = this.environment;
}
@ -225,4 +226,4 @@ export class ConfigManager<T = Record<string, unknown>> {
return result;
}
}
}

View file

@ -18,6 +18,9 @@ export {
} from './schemas';
// createAppConfig function for apps/stock
export function createAppConfig<T>(schema: unknown, options?: ConfigManagerOptions): ConfigManager<T> {
export function createAppConfig<T>(
schema: unknown,
options?: ConfigManagerOptions
): ConfigManager<T> {
return new ConfigManager<T>(options);
}
}

View file

@ -133,10 +133,7 @@ export class EnvLoader implements ConfigLoader {
private shouldPreserveStringForKey(key: string): boolean {
// Keys that should preserve string values even if they look like numbers
const preserveStringKeys = [
'QM_WEBMASTER_ID',
'IB_MARKET_DATA_TYPE'
];
const preserveStringKeys = ['QM_WEBMASTER_ID', 'IB_MARKET_DATA_TYPE'];
return preserveStringKeys.includes(key);
}

View file

@ -24,23 +24,27 @@ export const eodProviderConfigSchema = baseProviderConfigSchema.extend({
// Interactive Brokers provider
export const ibProviderConfigSchema = baseProviderConfigSchema.extend({
gateway: z.object({
host: z.string().default('localhost'),
port: z.number().default(5000),
clientId: z.number().default(1),
}).default({
host: 'localhost',
port: 5000,
clientId: 1,
}),
account: z.string().optional(),
marketDataType: z.union([
z.enum(['live', 'delayed', 'frozen']),
z.enum(['1', '2', '3']).transform((val) => {
const mapping = { '1': 'live', '2': 'frozen', '3': 'delayed' } as const;
return mapping[val];
gateway: z
.object({
host: z.string().default('localhost'),
port: z.number().default(5000),
clientId: z.number().default(1),
})
.default({
host: 'localhost',
port: 5000,
clientId: 1,
}),
]).default('delayed'),
account: z.string().optional(),
marketDataType: z
.union([
z.enum(['live', 'delayed', 'frozen']),
z.enum(['1', '2', '3']).transform(val => {
const mapping = { '1': 'live', '2': 'frozen', '3': 'delayed' } as const;
return mapping[val];
}),
])
.default('delayed'),
});
// QuoteMedia provider