Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
[hotfix] SeedDB missing in env config
Browse files Browse the repository at this point in the history
Adds a check for the existence of the seedDB config setting, before
attempting to read config.seedDB.seed setting.

Solves the problem when the seedDB config setting is missing from a
environment config, that causes the application to throw an exception at
startup.

Also, adds the seedDB setting to the Cloud-Foundry env config.
  • Loading branch information
mleanos committed Oct 28, 2015
1 parent afd93b4 commit 28f1f57
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions config/env/cloud-foundry.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,29 @@ module.exports = {
pass: getCred('mean-mail', 'password') || 'MAILER_PASSWORD'
}
}
},
seedDB: {
seed: process.env.MONGO_SEED === 'true' ? true : false,
options: {
logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true,
seedUser: {
username: process.env.MONGO_SEED_USER_USERNAME || 'user',
provider: 'local',
email: process.env.MONGO_SEED_USER_EMAIL || '[email protected]',
firstName: 'User',
lastName: 'Local',
displayName: 'User Local',
roles: ['user']
},
seedAdmin: {
username: process.env.MONGO_SEED_ADMIN_USERNAME || 'admin',
provider: 'local',
email: process.env.MONGO_SEED_ADMIN_EMAIL || '[email protected]',
firstName: 'Admin',
lastName: 'Local',
displayName: 'Admin Local',
roles: ['user', 'admin']
}
}
}
};
2 changes: 1 addition & 1 deletion config/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var config = require('../config'),
seed = require('./seed');

function seedDB() {
if (config.seedDB.seed) {
if (config.seedDB && config.seedDB.seed) {
console.log(chalk.bold.red('Warning: Database seeding is turned on'));
seed.start();
}
Expand Down

0 comments on commit 28f1f57

Please sign in to comment.