or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-1/

Application Configuration System

Build a configuration management system that combines multiple configuration sources into a final configuration object. The system should handle default configurations, environment-specific settings, and user overrides.

@generates

Requirements

Your configuration system must:

  1. Provide a buildConfig() function that accepts multiple configuration objects and merges them into a single configuration object
  2. Support deep merging of nested configuration properties
  3. Ensure later configuration sources override earlier ones when conflicts occur
  4. Preserve all non-conflicting properties from all sources
  5. Return a new configuration object without modifying the input sources

Example Scenario

You need to merge configurations from:

  • Default application settings
  • Environment-specific settings (development, staging, production)
  • User-provided overrides

For example:

const defaultConfig = {
  app: {
    name: "MyApp",
    version: "1.0.0",
    port: 3000
  },
  database: {
    host: "localhost",
    port: 5432,
    ssl: false
  },
  features: {
    auth: true,
    logging: false
  }
};

const envConfig = {
  app: {
    port: 8080
  },
  database: {
    host: "db.example.com",
    ssl: true
  }
};

const userConfig = {
  database: {
    port: 3306
  },
  features: {
    logging: true,
    analytics: true
  }
};

const finalConfig = buildConfig(defaultConfig, envConfig, userConfig);

The result should preserve app.name and app.version from defaults, use app.port from envConfig, merge database settings from all three sources, and combine all features.

Test Cases

  • It merges two configuration objects with nested properties @test
  • It merges three configuration objects with later sources taking precedence @test
  • It preserves properties that only exist in one source @test
  • It does not modify the original input objects @test

API

/**
 * Builds a final configuration by merging multiple configuration sources
 * @param {...Object} configs - Configuration objects to merge, in order of precedence (later overrides earlier)
 * @returns {Object} A new configuration object with all sources merged
 */
function buildConfig(...configs) {
  // Implementation here
}

module.exports = { buildConfig };

Dependencies { .dependencies }

mixin-deep { .dependency }

Provides deep object merging support