This commit is contained in:
Boki 2026-11-26 22:23:07 -05:00
parent c353ddbe01
commit ce9e2df67c
310 changed files with 2550 additions and 36861 deletions

View file

@ -189,6 +189,8 @@ export class ConfigManager<T = Record<string, unknown>> {
case 'production':
case 'prod':
return 'production';
case 'qa':
return 'qa';
case 'test':
return 'test';
case 'development':

View file

@ -133,13 +133,43 @@ 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',
'MONGODB_URI',
'MONGODB_READ_URI',
'MONGODB_PASSWORD',
'POSTGRES_PASSWORD',
'DRAGONFLY_PASSWORD',
'QUESTDB_PASSWORD',
];
return preserveStringKeys.includes(key);
}
private getProviderMapping(envKey: string): { path: string[] } | null {
// Provider-specific and special environment variable mappings
const providerMappings: Record<string, string[]> = {
// Database mappings
MONGODB_URI: ['database', 'mongodb', 'uri'],
MONGODB_READ_URI: ['database', 'mongodb', 'readUri'],
MONGODB_READ_ONLY: ['database', 'mongodb', 'readOnly'],
MONGODB_DATABASE: ['database', 'mongodb', 'database'],
MONGODB_HOST: ['database', 'mongodb', 'host'],
MONGODB_PORT: ['database', 'mongodb', 'port'],
MONGODB_USERNAME: ['database', 'mongodb', 'user'],
MONGODB_PASSWORD: ['database', 'mongodb', 'password'],
POSTGRES_HOST: ['database', 'postgres', 'host'],
POSTGRES_PORT: ['database', 'postgres', 'port'],
POSTGRES_DATABASE: ['database', 'postgres', 'database'],
POSTGRES_USERNAME: ['database', 'postgres', 'user'],
POSTGRES_PASSWORD: ['database', 'postgres', 'password'],
POSTGRES_SSL: ['database', 'postgres', 'ssl'],
DRAGONFLY_HOST: ['database', 'dragonfly', 'host'],
DRAGONFLY_PORT: ['database', 'dragonfly', 'port'],
DRAGONFLY_PASSWORD: ['database', 'dragonfly', 'password'],
QUESTDB_HOST: ['database', 'questdb', 'host'],
QUESTDB_PORT: ['database', 'questdb', 'httpPort'],
// WebShare provider mappings
WEBSHARE_API_KEY: ['webshare', 'apiKey'],
WEBSHARE_API_URL: ['webshare', 'apiUrl'],

View file

@ -1,6 +1,6 @@
import { z } from 'zod';
export const environmentSchema = z.enum(['development', 'test', 'production']);
export const environmentSchema = z.enum(['development', 'qa', 'test', 'production']);
export const baseConfigSchema = z.object({
environment: environmentSchema.optional(),

View file

@ -37,6 +37,8 @@ export const questdbConfigSchema = z.object({
export const mongodbConfigSchema = z.object({
enabled: z.boolean().default(true),
uri: z.string().url(), // URI is required and contains all connection info
readUri: z.string().url().optional(), // Optional read-only URI (e.g. dev data-pipeline reading QA MongoDB)
readOnly: z.boolean().default(false).optional(),
database: z.string(), // Database name for reference
poolSize: z.number().min(1).max(100).default(10),
// Optional fields for cases where URI parsing might fail

View file

@ -1,6 +1,6 @@
import { z } from 'zod';
export type Environment = 'development' | 'test' | 'production';
export type Environment = 'development' | 'qa' | 'test' | 'production';
export interface ConfigLoader {
load(): Record<string, unknown>;

View file

@ -28,6 +28,7 @@ describe('Config Schemas', () => {
describe('environmentSchema', () => {
it('should accept valid environments', () => {
expect(environmentSchema.parse('development')).toBe('development');
expect(environmentSchema.parse('qa')).toBe('qa');
expect(environmentSchema.parse('test')).toBe('test');
expect(environmentSchema.parse('production')).toBe('production');
});