<commit_before>'use strict';

var path = require('path'),
  // rootPath shouldn't end with forward slash
  rootPath = path.normalize(__dirname + '/..');
var env = require('node-env-file');

env(path.join(__dirname, '../.env'));

function getEnv(name) {
  if (!process.env.hasOwnProperty(name)) {
    throw new Error('Env setting: ' + name + ' is not configured!');
  }
  return process.env[name].trim();
}


module.exports = {
  //TODO from config.js clean up reduncacy later
  oauth0: {
    client: getEnv('TC_AUTH0_CLIENT'),
    secret: getEnv('TC_AUTH0_SECRET')
  },
  challenge: {
    apiUrl: 'http://lc1-challenge-service.herokuapp.com',
    defaultTitle: 'Untitled Challenge'
  },

  // end TODO

  root: rootPath,
  challengeServiceURI: 'http://lc1-challenge-service.herokuapp.com/',
  auth0: {
    Domain: process.env.TC_AUTH0_DOMAIN || 'serenity-tc.auth0.com',
    Client: process.env.TC_AUTH0_CLIENT || 'foo',
    Secret: process.env.TC_AUTH0_SECRET || 'bar'
  },
  /**
   * Uploads configuration
   * @type {Object}
   */
  uploads : {
    /**
     * Should be configured in storageProviders
     * @type {String}
     */

    storageProvider: process.env.STORAGE_PROVIDER || 'local'
  },
  /**
   * Storage providers can be configured here
   * A storage provider should support two operations
   * store and delete
   * @type {Object}
   */
  storageProviders : {
    local: {
      /**
       * This path is needed to load the provider during application load
       * NOTE: The path is relative to root of application and should not end in a forward slash
       * @type {String}
       */
      path: './server/routes/localUploadMiddleware',
      options: {
        /**
         * Unique Id for this storage provider
         * NOTE: Every storage provider should have a unique id
         * @type {Number}
         */
        id: 1,
        /**
         * These are upload directories for local storage provider
         * @type {String}
         */
        uploadsDirectory: './upload',
        tempDir: './temp'
      }
    },
    amazonS3: {
      /**
       * This path is needed to load the provider during application load
       * NOTE: The path is relative to root of application and should not end in a forward slash
       * @type {String}
       */
      path: './server/routes/s3UploadMiddleware',
      options: {
        /**
         * Unique Id for this storage provider
         * NOTE: Every storage provider should have a unique id
         * @type {Number}
         */
        id: 2,
        /**
         * AWS configuration for s3 upload service
         * @type {Object}
         */
        aws: {
          secure: false,
          key: process.env.AWS_KEY,
          secret: process.env.AWS_SECRET,
          bucket: process.env.AWS_BUCKET,
          region: process.env.AWS_REGION

        }
      }
    }
  }
};
<commit_msg>updates to default.js, by setting NODE_ENV=prodcution should not call .env file appirio-tech/lc1-project#288 May not need to set NODE_ENV anyway<commit_after>'use strict';

var path = require('path'),
  // rootPath shouldn't end with forward slash
  rootPath = path.normalize(__dirname + '/..');
var env = require('node-env-file');


function getEnv(name) {
  /*  if production and don't load .env file
   * must set NODE_ENV on heroku to production for this to work
   */
  if ( process.env.NODE_ENV !== 'production' ) {
    console.log('NOT running production');
    env(path.join(__dirname, '../.env'));
    if (!process.env.hasOwnProperty(name)) {
      throw new Error('Env setting: ' + name + ' is not configured!');
    }
  return process.env[name].trim();
  } else {
    console.log('Running PRODUCTION');
  }
}


module.exports = {
  challenge: {
    apiUrl: 'http://lc1-challenge-service.herokuapp.com',
    defaultTitle: 'Untitled Challenge'
  },
  root: rootPath,
  challengeServiceURI: 'http://lc1-challenge-service.herokuapp.com/',
  auth0: {
    Domain: process.env.TC_AUTH0_DOMAIN || 'serenity-tc.auth0.com',
    /* use process.env first, then .env file, last set here */
    Client: process.env.TC_AUTH0_CLIENT || getEnv('TC_AUTH0_CLIENT') || 'foo',
    Secret: process.env.TC_AUTH0_SECRET || getEnv('TC_AUTH0_SECRET') || 'bar'

  },
  /**
   * Uploads configuration
   * @type {Object}
   */
  uploads : {
    /**
     * Should be configured in storageProviders
     * @type {String}
     */

    storageProvider: process.env.STORAGE_PROVIDER || 'local'
  },
  /**
   * Storage providers can be configured here
   * A storage provider should support two operations
   * store and delete
   * @type {Object}
   */
  storageProviders : {
    local: {
      /**
       * This path is needed to load the provider during application load
       * NOTE: The path is relative to root of application and should not end in a forward slash
       * @type {String}
       */
      path: './server/routes/localUploadMiddleware',
      options: {
        /**
         * Unique Id for this storage provider
         * NOTE: Every storage provider should have a unique id
         * @type {Number}
         */
        id: 1,
        /**
         * These are upload directories for local storage provider
         * @type {String}
         */
        uploadsDirectory: './upload',
        tempDir: './temp'
      }
    },
    amazonS3: {
      /**
       * This path is needed to load the provider during application load
       * NOTE: The path is relative to root of application and should not end in a forward slash
       * @type {String}
       */
      path: './server/routes/s3UploadMiddleware',
      options: {
        /**
         * Unique Id for this storage provider
         * NOTE: Every storage provider should have a unique id
         * @type {Number}
         */
        id: 2,
        /**
         * AWS configuration for s3 upload service
         * @type {Object}
         */
        aws: {
          secure: false,
          key: process.env.AWS_KEY,
          secret: process.env.AWS_SECRET,
          bucket: process.env.AWS_BUCKET,
          region: process.env.AWS_REGION

        }
      }
    }
  }
};

console.log('DEBUG: from default.js, using auth0: %j',  module.exports.auth0 );
console.log('DEBUG: the process.env.NODE_ENV is ', process.env.NODE_ENV );
console.log('DEBUG: AWS_KEY is ', process.env.AWS_KEY);

{'fraction_non_alphanumeric': 0.12074156235144985, 'fraction_numerical': 0.005545872286483917, 'mean_word_length': 2.2319508448540706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1021012', 'n_tokens_mistral': 1914, 'n_tokens_neox': 1883, 'n_words': 538}