docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
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.
Your configuration system must:
buildConfig() function that accepts multiple configuration objects and merges them into a single configuration objectYou need to merge configurations from:
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.
/**
* 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 };Provides deep object merging support