Closed spdowling closed 7 years ago
The reason a deep clone is done, is to ensure there is no side affect Glue.compose - ie, the 'server' field of the manifest should not get modified. Consider your example:
const manifest = {
server: {
cache: [
{
name: 'query-cache',
engine: 'catbox-memory'
}
]
}
};
If making the code use a shallow clone, the following results:
> manifest.server.cache
[ { name: 'query-cache', engine: 'catbox-memory' } ]
> Glue.compose(manifest).then()
> manifest.server.cache
[ { name: 'query-cache', engine: [Function: MemoryCache] } ]
Hapi's coding style desires that functions do not have the side affect of modifying passed in arguments.
You say "config and glue weren't playing well together". What is it that is going wrong? Simply that the clone operation is overly expensive because of the 'config' decorations? Or did something actually malfunction, if so what?
Thanks for the response @csrl, sorry for not giving more detail, please find below a basic setup:
server.js
var Glue = require('glue')
var config = require('config')
var manifest = config.get('manifest')
Glue.compose(manifest, function (err, server) {
if (err) { throw err }
server.start(function (err) {
if (err) {
throw err
}
})
})
config/default.js
'use strict'
module.exports = {
manifest: {
server: {
cache: [
{
name: 'query-cache',
engine: 'catbox-memory'
}
],
debug: {
request: ['error']
}
}
}
}
I've attached the log in its entirety, but main issue seems to be that config has decorated the manifest object at all levels which throws then validation errors from Hapi when trying to load the server options provided in cache, since now cache includes additional methods and attributes that break the schema.
➜ testing node server.js
/Users/simon/Documents/Projects/testing/node_modules/hoek/lib/index.js:736
throw new Error(msgs.join(' ') || 'Unknown error');
^
Error: Invalid server options {
"cache": [
{
"name": "query-cache",
"engine": function MemoryCache(options) {\n\n Hoek.assert(this.constructor === internals.Connection, 'Memory cache client must be instantiated using new');\n Hoek.assert(!options || options.maxByteSize === undefined || options.maxByteSize >= 0, 'Invalid cache maxByteSize value');\n Hoek.assert(!options || options.allowMixedContent === undefined || typeof options.allowMixedContent === 'boolean', 'Invalid allowMixedContent value');\n\n this.settings = Hoek.applyToDefaults(internals.defaults, options || {});\n this.cache = null;\n}
}
],
"debug": {
"request": [
"error"
],
"_getCmdLineArg" [20]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_initParam" [19]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_isObject" [18]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripComments" [17]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripYamlComments" [16]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_extendDeep" [15]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_diffDeep" [14]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_equalsDeep" [13]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_cloneDeep" [12]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_attachProtoDeep" [11]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_parseFile" [10]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_loadFileConfigs" [9]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"getConfigSources" [8]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"makeImmutable" [7]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"makeHidden" [6]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"setModuleDefaults" [5]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"watch" [4]: function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"has" [3]: function (property) {\n // While get() throws an exception for undefined input, has() is designed to test validity, so false is appropriate\n if(property === null || property === undefined){\n return false;\n }\n var t = this;\n return (getImpl(t, property) !== undefined);\n},
"get" [2]: function (property) {\n if(property === null || property === undefined){\n throw new Error(\"Calling config.get with null or undefined argument\");\n }\n var t = this,\n value = getImpl(t, property);\n\n // Produce an exception if the property doesn't exist\n if (value === undefined) {\n throw new Error('Configuration property \"' + property + '\" is not defined');\n }\n\n // Make configurations immutable after first get (unless disabled)\n if (checkMutability) {\n if (!util.initParam('ALLOW_CONFIG_MUTATIONS', false)) {\n util.makeImmutable(config);\n }\n checkMutability = false;\n }\n\n if (value instanceof RawConfig) {\n value = value.resolve();\n }\n\n // Return the value\n return value;\n},
"util" [1]: {
"watch": function () { [native code] },
"setModuleDefaults": function () { [native code] },
"makeHidden": function () { [native code] },
"makeImmutable": function () { [native code] },
"getConfigSources": function () { [native code] },
"loadFileConfigs": function () { [native code] },
"resolveDeferredConfigs": function () { [native code] },
"parseFile": function () { [native code] },
"parseString": function () { [native code] },
"attachProtoDeep": function () { [native code] },
"cloneDeep": function () { [native code] },
"setPath": function () { [native code] },
"substituteDeep": function () { [native code] },
"getCustomEnvVars": function () { [native code] },
"equalsDeep": function () { [native code] },
"diffDeep": function () { [native code] },
"extendDeep": function () { [native code] },
"stripYamlComments": function () { [native code] },
"stripComments": function () { [native code] },
"isObject": function () { [native code] },
"initParam": function () { [native code] },
"getCmdLineArg": function () { [native code] },
"getEnv": function () { [native code] },
"getRegExpFlags": function () { [native code] },
"runStrictnessChecks": function () { [native code] },
"util": "[Circular ~.debug.util_$key$_1_$end$_]",
"get": function (property) {\n if(property === null || property === undefined){\n throw new Error(\"Calling config.get with null or undefined argument\");\n }\n var t = this,\n value = getImpl(t, property);\n\n // Produce an exception if the property doesn't exist\n if (value === undefined) {\n throw new Error('Configuration property \"' + property + '\" is not defined');\n }\n\n // Make configurations immutable after first get (unless disabled)\n if (checkMutability) {\n if (!util.initParam('ALLOW_CONFIG_MUTATIONS', false)) {\n util.makeImmutable(config);\n }\n checkMutability = false;\n }\n\n if (value instanceof RawConfig) {\n value = value.resolve();\n }\n\n // Return the value\n return value;\n},
"has": function (property) {\n // While get() throws an exception for undefined input, has() is designed to test validity, so false is appropriate\n if(property === null || property === undefined){\n return false;\n }\n var t = this;\n return (getImpl(t, property) !== undefined);\n},
"_loadFileConfigs": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_parseFile": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_attachProtoDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_cloneDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_equalsDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_diffDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_extendDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripYamlComments": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripComments": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_isObject": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_initParam": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_getCmdLineArg": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n }
}
},
"util": {
"watch": function () { [native code] },
"setModuleDefaults": function () { [native code] },
"makeHidden": function () { [native code] },
"makeImmutable": function () { [native code] },
"getConfigSources": function () { [native code] },
"loadFileConfigs": function () { [native code] },
"resolveDeferredConfigs": function () { [native code] },
"parseFile": function () { [native code] },
"parseString": function () { [native code] },
"attachProtoDeep": function () { [native code] },
"cloneDeep": function () { [native code] },
"setPath": function () { [native code] },
"substituteDeep": function () { [native code] },
"getCustomEnvVars": function () { [native code] },
"equalsDeep": function () { [native code] },
"diffDeep": function () { [native code] },
"extendDeep": function () { [native code] },
"stripYamlComments": function () { [native code] },
"stripComments": function () { [native code] },
"isObject": function () { [native code] },
"initParam": function () { [native code] },
"getCmdLineArg": function () { [native code] },
"getEnv": function () { [native code] },
"getRegExpFlags": function () { [native code] },
"runStrictnessChecks": function () { [native code] },
"util": "[Circular ~.util]",
"get": function (property) {\n if(property === null || property === undefined){\n throw new Error(\"Calling config.get with null or undefined argument\");\n }\n var t = this,\n value = getImpl(t, property);\n\n // Produce an exception if the property doesn't exist\n if (value === undefined) {\n throw new Error('Configuration property \"' + property + '\" is not defined');\n }\n\n // Make configurations immutable after first get (unless disabled)\n if (checkMutability) {\n if (!util.initParam('ALLOW_CONFIG_MUTATIONS', false)) {\n util.makeImmutable(config);\n }\n checkMutability = false;\n }\n\n if (value instanceof RawConfig) {\n value = value.resolve();\n }\n\n // Return the value\n return value;\n},
"has": function (property) {\n // While get() throws an exception for undefined input, has() is designed to test validity, so false is appropriate\n if(property === null || property === undefined){\n return false;\n }\n var t = this;\n return (getImpl(t, property) !== undefined);\n},
"_loadFileConfigs": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_parseFile": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_attachProtoDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_cloneDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_equalsDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_diffDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_extendDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripYamlComments": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripComments": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_isObject": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_initParam": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_getCmdLineArg": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n }
},
"get": function (property) {\n if(property === null || property === undefined){\n throw new Error(\"Calling config.get with null or undefined argument\");\n }\n var t = this,\n value = getImpl(t, property);\n\n // Produce an exception if the property doesn't exist\n if (value === undefined) {\n throw new Error('Configuration property \"' + property + '\" is not defined');\n }\n\n // Make configurations immutable after first get (unless disabled)\n if (checkMutability) {\n if (!util.initParam('ALLOW_CONFIG_MUTATIONS', false)) {\n util.makeImmutable(config);\n }\n checkMutability = false;\n }\n\n if (value instanceof RawConfig) {\n value = value.resolve();\n }\n\n // Return the value\n return value;\n},
"has": function (property) {\n // While get() throws an exception for undefined input, has() is designed to test validity, so false is appropriate\n if(property === null || property === undefined){\n return false;\n }\n var t = this;\n return (getImpl(t, property) !== undefined);\n},
"watch": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"setModuleDefaults": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"makeHidden": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"makeImmutable": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"getConfigSources": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_loadFileConfigs": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_parseFile": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_attachProtoDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_cloneDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_equalsDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_diffDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_extendDeep": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripYamlComments": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_stripComments": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_isObject": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_initParam": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n },
"_getCmdLineArg": function (){\n\n // Produce the warning\n if (!utilWarnings[oldName]) {\n console.error('WARNING: config.' + oldName + '() is deprecated. Use config.util.' + newName + '() instead.');\n console.error('WARNING: See https://github.com/lorenwest/node-config/wiki/Future-Compatibility#upcoming-incompatibilities');\n utilWarnings[oldName] = true;\n }\n\n // Forward the call\n return util[newName].apply(this, arguments);\n }
}
[1] "util" is not allowed
[2] "get" is not allowed
[3] "has" is not allowed
[4] "watch" is not allowed
[5] "setModuleDefaults" is not allowed
[6] "makeHidden" is not allowed
[7] "makeImmutable" is not allowed
[8] "getConfigSources" is not allowed
[9] "_loadFileConfigs" is not allowed
[10] "_parseFile" is not allowed
[11] "_attachProtoDeep" is not allowed
[12] "_cloneDeep" is not allowed
[13] "_equalsDeep" is not allowed
[14] "_diffDeep" is not allowed
[15] "_extendDeep" is not allowed
[16] "_stripYamlComments" is not allowed
[17] "_stripComments" is not allowed
[18] "_isObject" is not allowed
[19] "_initParam" is not allowed
[20] "_getCmdLineArg" is not allowed
at Object.exports.assert (/Users/simon/Documents/Projects/testing/node_modules/hoek/lib/index.js:736:11)
at Object.exports.apply (/Users/simon/Documents/Projects/testing/node_modules/glue/node_modules/hapi/lib/schema.js:17:10)
at new module.exports.internals.Server (/Users/simon/Documents/Projects/testing/node_modules/glue/node_modules/hapi/lib/server.js:32:22)
at Object.exports.compose (/Users/simon/Documents/Projects/testing/node_modules/glue/lib/index.js:65:20)
at Object.<anonymous> (/Users/simon/Documents/Projects/testing/server.js:6:6)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
I'd say this is an issue with config
, that stuff should not be enumerable.
Thanks Marsup.
I've raised this with config (lorenwest/node-config#434) and see what they come back with, otherwise I'll probably move back to Confidence instead.
Thanks all
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
I'm using both Glue and config (https://www.npmjs.com/package/config) in my server setup. No real issues for the most part, except when I introduced caching configuration in to my manifest.
Inside of my server.js I'm using both as follows:
Pretty standard, but seems that config and Glue weren't playing well together. After some hunting around it seems that when executing parseServer, the server is cloned. The current release does this using Hoek.clone which means that all of the decoration config has added to the object goes with it as well.
I've forked and replaced the Hoek.clone option with a lodash _.clone in its place and seems that the naturally shallow clone works without any side-effects.
I'm not sure what other alternatives would be more fitting in terms of style and the teams preferred approach, but seems a quick fix that'd be much appreciated.