How to use the config.env function in config

To help you get started, we’ve selected a few config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opencollective / opencollective-api / server / lib / email.js View on Github external
console.log('>>> preview email', filepath);
    }

    if (options.attachments) {
      options.attachments.map(attachment => {
        const filepath = path.resolve(`/tmp/${attachment.filename}`);
        fs.writeFileSync(filepath, attachment.content);
        console.log('>>> preview attachment', filepath);
      });
    }
  }

  if (process.env.ONLY) {
    debug('Only sending email to ', process.env.ONLY);
    to = process.env.ONLY;
  } else if (config.env !== 'production') {
    if (!to) {
      debug('emailLib.sendMessage error: No recipient defined');
      return Promise.resolve();
    }
    let sendToBcc = true;
    // Don't send to BCC if sendEvenIfNotProduction and NOT in testing env
    if (options.sendEvenIfNotProduction === true && !['ci', 'circleci', 'test'].includes(config.env)) {
      sendToBcc = false;
    }
    if (sendToBcc) {
      to = `emailbcc+${to.replace(/@/g, '-at-')}@opencollective.com`;
    }
  }

  if (recipients.length === 0) {
    debug('emailLib.sendMessage error: No recipient to send to, only sending to bcc', options.bcc);
github opencollective / opencollective-api / server / models / User.js View on Github external
description: userData.description,
      longDescription: userData.longDescription,
      website: userData.website,
      twitterHandle: userData.twitterHandle,
      githubHandle: userData.githubHandle,
      currency: userData.currency,
      hostFeePercent: userData.hostFeePercent,
      isActive: true,
      CreatedByUserId: userData.CreatedByUserId || user.id,
      data: { UserId: user.id },
    };
    user.collective = await models.Collective.create(userCollectiveData, sequelizeParams);

    // It's difficult to predict when the image will be updated by findImageForUser
    // So we skip that in test environment to make it more predictable
    if (config.env !== 'test' && config.env !== 'circleci') {
      user.collective.findImageForUser(user);
    }
    user.CollectiveId = user.collective.id;
    await user.save(sequelizeParams);
    return user;
  };
github scarwu / MHWCalculator / src / assets / scripts / app.jsx View on Github external
import FunctionalButton from 'components/common/functionalButton';
import FunctionalSelector from 'components/common/functionalSelector';
import ConditionOptions from 'components/conditionOptions';
import CandidateBundles from 'components/candidateBundles';
import EquipsDisplayer from 'components/equipsDisplayer';
import CharacterStatus from 'components/characterStatus';

// Load State Control
import CommonState from 'states/common';
import ModalState from 'states/modal';

// Load Config & Constant
import Config from 'config';
import Constant from 'constant';

if ('production' === Config.env) {
    if (Config.buildTime !== Status.get('sys:buildTime')) {
        ModalState.setter.showChangelog();
    }

    Status.set('sys:buildTime', Config.buildTime);
}

/**
 * Variables
 */
const langList = Object.keys(Constant.langs).map((lang) => {
    return { key: lang, value: Constant.langs[lang] };
});

/**
 * Handle Functions
github qious / simple-proxy-server / server / lib / utils.js View on Github external
let getOAuthConfig = function (secure, state) {
  let redirect_uri = '/api/wechat/callback';
  // 开发环境下使用前端的 protocal 与 host ,方便开发
  if (config.env === 'development' && state && state.startsWith('http:')) {
    let result = url.parse(state);
    redirect_uri = url.format({
      protocol: result.protocol,
      host: result.host,
      pathname: redirect_uri,
    });
  } else if (secure) {
    redirect_uri = this.getBaseHttpsUrl() + redirect_uri;
  } else {
    redirect_uri = this.getBaseHttpUrl() + redirect_uri;
  }

  let {corp_id, usertype} = config.wechat;
  return {corp_id, redirect_uri, state, usertype};
};
github streetmix / streetmix / lib / middleware / styles.js View on Github external
function compileStyles () {
  vfs.src(path.join(process.cwd(), STYLE_SOURCE))
    .pipe(plumber({ errorHandler: logger.error }))
    .pipe(gulpif(config.env !== 'production', sourcemaps.init()))
    .pipe(sass())
    .pipe(postcss(plugins))
    .pipe(gulpif(config.env !== 'production', sourcemaps.write()))
    .pipe(tap(function (file) {
      compiledStyles = file.contents
    }))
}
github qious / ss-panel-server / lib / wechat.js View on Github external
api.send = function (to, message, callback) {
    if (config.env !== 'production') {
      return callback(null, {
        errcode: 0,
        errmsg: 'ok'
      })
    }
    return send.call(api, to, message, callback)
  }