// This function imports a given language file and uses the default language set // in DEFAULT_LANG as a fallback to prevent any strings that aren't filled out // from appearing as blank. function i18nJSON (lang) { const defaultJSON = require(`./locale/${DEFAULT_LANG}/site.json`) const templateJSON = require(`./locale/${lang}/site.json`) return defaultsDeep({}, templateJSON, defaultJSON) }
created() { this.requests = new RequestStatistics(defaultsDeep({}, this.broker.options)); }
/** * Creates an instance of RequestStatistics. * * @param {any} options * * @memberof RequestStatistics */ constructor(options) { this.options = defaultsDeep({}, options, { cycleTime: 5 * 1000, bucketCount: 12 }); this.total = new StatRequestStore("total", this.options.bucketCount); this.actions = new Map(); this.cycleTimer = setInterval(() => { this.cycle(); }, this.options.cycleTime); this.cycleTimer.unref(); }
opts = defaultsDeep(opts, {
/** * Loads config from presets and assigns to the main config. * Merge priority order being: * - loaded file config > preset configs > child preset configs * * @param {Gasket} gasket - Gasket engine instance */ function assignPresetConfig(gasket) { const { presets } = gasket.loader.loadConfigured(gasket.config.plugins); const presetConfigs = flattenPresets(presets).map(p => p.module && p.module.config).filter(Boolean); Object.assign(gasket.config, defaultsDeep(gasket.config, ...presetConfigs)); }
/** * Adds additional docsSetup for modules, merging duplicates with a first * in wins approach. When a module is then add to be configured, a docSetup * will be looked up from what's been added by plugins here. * * @param {Object.<string, DocsSetup>} moduleDocsSetup - Setups for modules * @private */ _addModuleDocsSetup(moduleDocsSetup) { defaultsDeep(this._moduleDocsSetups, moduleDocsSetup); }
/** * Get database connection configuration * @return {Object} database configs */ getDBConnectionConfigs() { const dbC = this.we.config.database; let configs = dbC[this.env]; if (!configs) { this.we.log.error(`Database configuration not found for enviroment: ${this.env}`); return this.we.exit( ()=> { process.exit(); }); } // set we.js core model definition configs defaultsDeep(configs, this.defaultModelDefinitionConfigs); // disable database logging by deffault if (!configs || !configs.logging) { configs.logging = false; } return configs; }
/** * Set default values for the `options` param if not set * * @param {Object} [options] - The options to use (optional) * @returns {Object} - The options object with default values */ function _defaults (options) { return defaultsDeep(options, { json: { pretty: process.env.NODE_ENV === 'development' }, logger: { enabled: process.env.NODE_ENV !== 'test', format: process.env.NODE_ENV === 'development' ? 'dev' : 'common' } }) }
test('should report crash', { timeout: TEST_TIMEOUT }, function (t) { var server var app = express() app.use(bodyParser.json()) app.post('/transaction-events', function (req, res) { try { t.ok(req.body.e, 'Events are reported') console.log(req.body.e) var event = find(req.body.e, function (e) { return e.t === 'err' && e.d.t === 'system-error' }) t.ok(event != null, 'Error event exists') t.end() } finally { server.close() } }) server = app.listen(TEST_WEB_SERVER_PORT, function (err) { t.error(err, 'server starts listening at ' + TEST_WEB_SERVER_PORT) spawnSync('node', [path.join(__dirname, 'testee.js')], { stdio: [0, 1, 2], env: defaultsDeep({}, env, process.env) }) }) })
return defaultsDeep({}, environments[envParts.slice(0, i + 1).join('.')], acc); const devConfig = environments.development || environments.dev; if (devConfig) { normalizedConfig = defaultsDeep({}, normalizedConfig, devConfig); const localOverrides = tryRequire(path.join(root, localFile)); if (localOverrides) { normalizedConfig = defaultsDeep({}, localOverrides, normalizedConfig);
} else { if (args.opts.isolate === 'child-process') { tape(name_, defaultsDeep(opts_, { timeout: 10000 }), function (t) { var testName if (args.name !== '(anonymous)') { testName = sha1.digest() var childEnv = defaultsDeep({ TEST_NAME: testName, TEST_ISOLATE: 'child-process' if (spawnSync) { try { res = spawnSync(process.argv[0], process.argv.slice(1), defaultsDeep( { stdio: ['ignore', process.stdout, process.stderr] }, args.opts.childProcessOpts, res = spawnSyncFallback(process.argv[0], process.argv.slice(1), defaultsDeep( { stdio: ['ignore', 'pipe', 'ignore'] }, args.opts.childProcessOpts,
}); const windowConfig = defaultsDeep(config, { name: docsConfigSet.app.name });
/** * Loads config from presets and assigns to the main config. * Merge priority order being: * - loaded file config > preset configs > child preset configs * * @param {Gasket} gasket - Gasket engine instance */ function assignPresetConfig(gasket) { const { presets } = gasket.loader.loadConfigured(gasket.config.plugins); const presetConfigs = flattenPresets(presets).map(p => p.module && p.module.config).filter(Boolean); Object.assign(gasket.config, defaultsDeep(gasket.config, ...presetConfigs)); }
/** * Adds additional docsSetup for modules, merging duplicates with a first * in wins approach. When a module is then add to be configured, a docSetup * will be looked up from what's been added by plugins here. * * @param {Object.<string, DocsSetup>} moduleDocsSetup - Setups for modules * @private */ _addModuleDocsSetup(moduleDocsSetup) { defaultsDeep(this._moduleDocsSetups, moduleDocsSetup); }
return defaultsDeep({}, environments[envParts.slice(0, i + 1).join('.')], acc); const devConfig = environments.development || environments.dev; if (devConfig) { normalizedConfig = defaultsDeep({}, normalizedConfig, devConfig); const localOverrides = tryRequire(path.join(root, localFile)); if (localOverrides) { normalizedConfig = defaultsDeep({}, localOverrides, normalizedConfig);