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

Commit

Permalink
updating support for mongodb connection string to support special cha…
Browse files Browse the repository at this point in the history
…rs for username and password
  • Loading branch information
lirantal committed Nov 29, 2014
1 parent 1b3cc8c commit 5b7423c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
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',
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/secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

module.exports = {
port: 443,
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
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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));
Expand Down

0 comments on commit 5b7423c

Please sign in to comment.