Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion config/env/development.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict';

module.exports = {
db: 'mongodb://localhost/mean-dev',
db: {
uri: 'mongodb://localhost/mean-dev',
options: {
user: '',
pass: ''
}
},
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'dev',
Expand Down
8 changes: 7 additions & 1 deletion config/env/production.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict';

module.exports = {
db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean',
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so many process URIs? In my opinion, let the user change the one included if necessary, but no need to include one for every database service.

options: {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user and pass can be specified in the URI, I would do it that way since it's the standard way.

user: '',
pass: ''
}
},
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'combined',
Expand Down
8 changes: 7 additions & 1 deletion config/env/secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

module.exports = {
port: 8443,
db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://localhost/mean',
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://localhost/mean',
options: {
user: '',
pass: ''
}
},
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'combined',
Expand Down
8 changes: 7 additions & 1 deletion config/env/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict';

module.exports = {
db: 'mongodb://localhost/mean-test',
db: {
uri: 'mongodb://localhost/mean-test',
options: {
user: '',
pass: ''
}
},
port: 3001,
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
Expand Down
9 changes: 7 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ var init = require('./config/init')(),
*/

// Bootstrap db connection
var db = mongoose.connect(config.db, function(err) {
var db = mongoose.connect(config.db.uri, config.db.options, function(err) {
if (err) {
console.error(chalk.red('Could not connect to MongoDB!'));
console.log(chalk.red(err));
}
});
mongoose.connection.on('error', function(err) {
console.error(chalk.red('MongoDB connection error: ' + err));
process.exit(-1);
}
);

// Init the express application
var app = require('./config/express')(db);
Expand All @@ -37,7 +42,7 @@ console.log('--');
console.log(chalk.green(config.app.title + ' application started'));
console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV));
console.log(chalk.green('Port:\t\t\t\t' + config.port));
console.log(chalk.green('Database:\t\t\t' + config.db));
console.log(chalk.green('Database:\t\t\t' + config.db.uri));
if (process.env.NODE_ENV === 'secure') {
console.log(chalk.green('HTTPs:\t\t\t\ton'));
}
Expand Down