Skip to content

Commit 7e53e8a

Browse files
razielraziel
raziel
authored and
raziel
committed
support docker-compose
1 parent fde073e commit 7e53e8a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ var bodyParser = require('body-parser'); // pull information from HTML POST (ex
1212
var methodOverride = require('method-override'); // simulate DELETE and PUT (express4)
1313

1414
// configuration ===============================================================
15-
mongoose.connect(database.url); // connect to mongoDB database on modulus.io
15+
try{
16+
mongoose.connect(database.url);
17+
}catch (err)
18+
{
19+
console.log(err);
20+
}// connect to mongoDB database on modulus.io
1621

1722
app.use(express.static(__dirname + '/public')); // set static path
1823
app.use(morgan('dev')); // log every request to the console

config/database.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/*eslint-env node */
22

3+
//in case mongodb installed locally
4+
//var mongourl = process.env.MONGO_URI? process.env.MONGO_URI : 'mongodb://localhost:27017/exampleDb';
5+
6+
..
7+
var mongourl = process.env.MONGO_URI? process.env.MONGO_URI : 'mongodb://mongo:27017/exampleDb';
8+
39
module.exports = {
410
// mongo database connection url
5-
url : process.env.MONGO_URI
11+
url : mongourl
612
};

0 commit comments

Comments
 (0)