const setTooling = (options, tokens) => { // Add in push/pull/switch options.tooling.pull = pull.getPantheonPull(options, tokens); options.tooling.push = push.getPantheonPush(options, tokens); options.tooling.switch = change.getPantheonSwitch(options, tokens); // Add in the framework-correct tooling options.tooling = _.merge({}, options.tooling, utils.getPantheonTooling(options.framework)); return options; }
async item(res, { query = {}, populate = [], files = null } = {}) { return _item(res, this.ctx.model.ContentCategory, { files: files, query: query, populate: !_.isEmpty(populate) ? populate : ['contentTemp'] }) }
_.each(this.views, (view) => { if (view && typeof view.destroy === "function") { view.destroy(); } });
/* * Warn user of unsupported services * This event exists to */ app.events.on('post-start', 9, () => { const allServices = _.map(app.lagoon.services, 'name'); const supportedServices = _.map(getLandoServices(app.lagoon.services), 'name'); const unsupportedServices = _.difference(allServices, supportedServices); if (!_.isEmpty(unsupportedServices)) { app.addWarning(warnings.unsupportedServices(unsupportedServices.join(', '))); } });
/* * Helper to run the app task runner */ const appRunner = command => (argv, lando) => { const app = lando.getApp(argv._app.root); return lando.events.emit('pre-app-runner', app) .then(() => lando.events.emit('pre-command-runner', app)) .then(() => app.init().then(() => _.find(app.tasks, {command}).run(argv))); }
async handler(ctx) { await this.Promise.delay(_.random(500, 2500)); this.logger.info("First called.", ctx.params); return ctx.params; }
slowGet(ctx) { let post = _.cloneDeep(posts.find(post => post.id == ctx.params.id)); return this.Promise.delay(2000) .then(() => ctx.call("v2.users.slowGet", { id: post.author, withPostCount: true })) .then(user => { post.author = _.pick(user, ["userName", "email", "id", "firstName", "lastName", "postsCount"]); return post; }) .catch(err => this.logger.error(err)); }
/** * Merge `metadata` property in schema * * @static * @param {Object} src Source schema property * @param {Object} target Target schema property * * @returns {Object} Merged schema */ static mergeSchemaMetadata(src, target) { return _.defaultsDeep(src, target); }
/* * Helper to get the applications environment variables */ const getEnvironmentVariables = appConfig => _(_.get(appConfig, 'variables.env', {})) .map((value, key) => ([key, (_.isObject(value)) ? JSON.stringify(value) : value])) .fromPairs() .value()
const sendMailByTimingTask = async (ctx, taskId, emailInfo, sendUserInfo) => { if (!_.isEmpty(global['sendMailTimingTask_' + taskId])) { global['sendMailTimingTask_' + taskId].cancel(); } global['sendMailTimingTask_' + taskId] = schedule.scheduleJob(emailInfo.timing, async function () { if (!_.isEmpty(sendUserInfo)) { sendEmailByTask(ctx, taskId, emailInfo, sendUserInfo); } }); }
constructor(registry, broker, opts) { super(registry, broker, opts); this.opts = _.defaultsDeep(opts, { sampleCount: 3, lowCpuUsage: 10 }); }