All files / src/config index.ts

90.9% Statements 10/11
75% Branches 3/4
100% Functions 1/1
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                  1x 2x 2x 2x     2x     2x         2x 1x   1x     2x        
import eventConfigDefault from './event-config.default.json'
import { getGlobalConfig, getEventConfig } from '../store'
import { deepMerge } from '../utils/merge'
import type { DeepPartial, EventConfig } from '../types'
 
/**
 * Loads the structural and content configuration.
 * Merges defaults with database overrides (if any).
 */
export const loadConfigs = (): EventConfig => {
    const globalConfig = getGlobalConfig()
    const eventConfig = getEventConfig()
    const baseConfig = eventConfigDefault as EventConfig
 
    // 1. Defaults
    let result = baseConfig
 
    // 2. Global Overrides
    Iif (globalConfig) {
        result = deepMerge(result, globalConfig as DeepPartial<EventConfig>) as EventConfig
    }
 
    // 3. Event Overrides
    if (eventConfig) {
        const mappedEventConfig = { ...eventConfig } as any
 
        result = deepMerge(result, mappedEventConfig as DeepPartial<EventConfig>) as EventConfig
    }
 
    return result
}
 
export { eventConfigDefault as defaultConfig }