Object.keys(this.middleware).reduce((acc, current) => { // Try to find the settings in the current environment, then in the main configurations. const currentSettings = merge(get(cloneDeep(this.middleware[current]), ['defaults', current], {}), flattenMiddlewaresConfig[current] || this.config.currentEnvironment[current] || this.config[current]); acc[current] = !isObject(currentSettings) ? {} : currentSettings; if (!acc[current].hasOwnProperty('enabled')) { this.log.warn(`(middleware:${current}) wasn't loaded due to missing key \`enabled\` in the configuration`); } // Ensure that enabled key exist by forcing to false. defaults(acc[current], { enabled : false }); return acc; }, {})
const getElementsOnALine = (manager, line, list) => { const firstElIndex = line === 0 ? 0 : manager.arrayOfEndLineElements[line - 1].index + 1; const lastElIndex = get(manager.arrayOfEndLineElements[line], 'index', list.size -1) + 1; const elements = manager.getElementsOnALine(range(firstElIndex, lastElIndex)); return { elements, lastElIndex }; }
static configureOptions(commandName, yargs, extensions) { const get = require('lodash/get'); const omit = require('lodash/omit'); extensions.forEach((extension) => { const options = get(extension, 'config.options.stop', false); if (!options) { return; } Object.assign(this.options, omit(options, Object.keys(this.options))); }); yargs = super.configureOptions(commandName, yargs, extensions); return yargs; }
/** * Health Check * * Returns a 200 status ok so services know the API is available. */ router.get("/", (req, res) => { // Language data. const languageData = language.getText(req.headers.locale); // Send a 200 status ok response with text saying the API is available. Defaults // to an English message. res.send({ message: get(languageData, ["common", "app", "available"]) }); });
/* eslint-disable camelcase */ function parse(content) { const data = get(content, 'db[0].data', content.data || null); /* istanbul ignore next */ const {id: role_id} = find(data.roles, {name: 'Owner'}) || {}; /* istanbul ignore next */ const {user_id} = find(data.roles_users, {role_id}) || {}; /* istanbul ignore next */ const {name, email} = find(data.users, {id: user_id}) || {}; /* istanbul ignore next */ const {value: blogTitle} = find(data.settings, {key: 'title'}) || {}; return {name, email, blogTitle}; }
const resolveEntry = (dir, entry) => { if (entry) return entry; // If no entry specified, take the main entry from package.json // if there's no package.json,either, take './index.js' try { const pkg = require(join(dir, './package.json')); return get(pkg, 'main'); } catch (err) { return './index.js'; } }